hjugement-cli 0.0.0.20191031 → 0.0.0.20191104
raw patch · 5 files changed
+24/−11 lines, 5 filesdep ~hjugement-protocol
Dependency ranges changed: hjugement-protocol
Files
- hjugement-cli.cabal +2/−2
- src/Hjugement/CLI/Administrator.hs +2/−1
- src/Hjugement/CLI/Trustee.hs +4/−3
- src/Hjugement/CLI/Utils.hs +12/−3
- src/Hjugement/CLI/Voter.hs +4/−2
hjugement-cli.cabal view
@@ -2,7 +2,7 @@ -- PVP: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.0.0.20191031+version: 0.0.0.20191104 category: Politic synopsis: Majority Judgment and Helios-C command line tool description:@@ -74,7 +74,7 @@ -- -fhide-source-paths build-depends: hjugement >= 2.0.2- , hjugement-protocol >= 0.0.9+ , hjugement-protocol >= 0.0.10 , aeson >= 1.3 , base >= 4.6 && < 5 , base64-bytestring >= 1.0
src/Hjugement/CLI/Administrator.hs view
@@ -177,7 +177,8 @@ glob@Global_Params{..} = runMaybeT $ do loadElection glob (global_dir FP.</> "election.json") $ \(_elec :: VP.Election VP.FFC v c) -> do- keys <- runPipeWithError glob $ Pip.toListM' $+ keys :: [VP.TrusteePublicKey VP.FFC v c]+ <- runPipeWithError glob $ Pip.toListM' $ readJSON glob $ global_dir FP.</> "public_keys.jsons" decs <- runPipeWithError glob $ Pip.toListM' $ readJSON glob $ global_dir FP.</> "partial_decryptions.jsons"
src/Hjugement/CLI/Trustee.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE StrictData #-}@@ -112,7 +113,7 @@ (TrusteeDecrypt_Params <$> api_param_privkey <*> api_param_url)- <?> response @(Maybe (VP.DecryptionShare VP.FFC () ()))+ <?> response @(Maybe (VP.DecryptionShare VP.FFC VP.StableVersion ())) where api_param_privkey = "Read private key from file "<>ref"FILE"<>"."@@ -129,7 +130,7 @@ let pubKey = VP.publicKey secKey let trusteeKeysPath = trusteeDecrypt_url FP.</> "public_keys.jsons" outputInfo glob "check that the public key is amongst the public keys of the election"- keys <- runPipeWithError glob $+ keys :: [VP.TrusteePublicKey VP.FFC v c] <- runPipeWithError glob $ Pip.toListM' $ readJSON glob trusteeKeysPath >-> Pip.filter ((pubKey ==) . VP.trustee_PublicKey)@@ -161,4 +162,4 @@ <- Pip.liftIO $ Rand.getStdRandom $ runState $ VP.proveDecryptionShare encTally secKey- return (coerce decShare :: VP.DecryptionShare VP.FFC () ())+ return (coerce decShare :: VP.DecryptionShare VP.FFC VP.StableVersion ())
src/Hjugement/CLI/Utils.hs view
@@ -24,6 +24,7 @@ import Data.Ord (Ord(..)) import Data.Semigroup (Semigroup(..)) import Data.Text (Text)+import Data.Typeable (Typeable) import Prelude (min, max, (-)) import Symantic.CLI as CLI import System.IO (IO)@@ -93,8 +94,16 @@ instance CLI.IOType VP.Credential instance CLI.FromSegment VP.Credential where fromSegment = return . left show . VP.readCredential . Text.pack-instance IOType (VP.DecryptionShare VP.FFC () ())-instance Outputable (VP.DecryptionShare VP.FFC () ()) where+instance+ ( Typeable branch+ , Typeable tags+ ) => IOType (VP.DecryptionShare VP.FFC (VP.V branch tags) ())+instance+ ( VP.VersionBranchVal branch+ , VP.VersionTagsVal tags+ , Typeable branch+ , Typeable tags+ ) => Outputable (VP.DecryptionShare VP.FFC (VP.V branch tags) ()) where output decShare = output $ JSON.encode (decShare)<>"\n" api_help full =@@ -305,7 +314,7 @@ IO.FilePath -> (forall v c. VP.Reifies v VP.Version =>- VP.GroupParams crypto c =>+ VP.CryptoParams crypto c => VP.Election crypto v c -> MaybeT m r) -> MaybeT m r loadElection glob filePath k =
src/Hjugement/CLI/Voter.hs view
@@ -140,7 +140,8 @@ loadElection glob (voterVerify_url FP.</> "election.json") $ \(elec@VP.Election{..} :: VP.Election VP.FFC v c) -> do outputInfo glob $ "verifying ballots"- (fails :: Natural, (encTally :: VP.EncryptedTally VP.FFC v c, _numBallots)) <- runPipeWithError glob $+ (fails :: Natural, (encTally :: VP.EncryptedTally VP.FFC v c, _numBallots))+ <- runPipeWithError glob $ Pip.foldM' (\(fails, acc@(_, numBallots)) ballot@VP.Ballot{..} -> do let ballotNum = numBallots + fails@@ -177,7 +178,8 @@ else do tally :: VP.Tally VP.FFC v c <- loadJSON glob resultPath outputInfo glob $ "decrypting tally using trustees' decryption shares"- trustees <- runPipeWithError glob $ Pip.toListM' $+ trustees :: [VP.TrusteePublicKey VP.FFC v c]+ <- runPipeWithError glob $ Pip.toListM' $ readJSON glob $ voterVerify_url FP.</> "public_keys.jsons" let trustPubKeys = VP.trustee_PublicKey <$> trustees decs <- runPipeWithError glob $ Pip.toListM' $