From 8fa031415664256dd738e5724b5ce6df91fcac9b Mon Sep 17 00:00:00 2001 From: Julien Moutinho <julm+hjugement@autogeree.net> Date: Mon, 22 Jul 2019 00:21:54 +0000 Subject: [PATCH] protocol: fix ToJSON ElectionCrypto --- hjugement-protocol/hjugement-protocol.cabal | 2 +- hjugement-protocol/src/Voting/Protocol/Election.hs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hjugement-protocol/hjugement-protocol.cabal b/hjugement-protocol/hjugement-protocol.cabal index 51b5e94..cd472c8 100644 --- a/hjugement-protocol/hjugement-protocol.cabal +++ b/hjugement-protocol/hjugement-protocol.cabal @@ -2,7 +2,7 @@ name: hjugement-protocol -- PVP: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.0.4.20190711 +version: 0.0.5.20190722 category: Politic synopsis: A cryptographic protocol for the Majority Judgment. description: diff --git a/hjugement-protocol/src/Voting/Protocol/Election.hs b/hjugement-protocol/src/Voting/Protocol/Election.hs index 2b03f26..0649c92 100644 --- a/hjugement-protocol/src/Voting/Protocol/Election.hs +++ b/hjugement-protocol/src/Voting/Protocol/Election.hs @@ -492,7 +492,7 @@ instance ToJSON (Election c) where <> "questions" .= election_questions <> "uuid" .= election_uuid ) -instance FromJSON (Election c) where +instance FromJSON (Election ()) where parseJSON = JSON.withObject "Election" $ \o -> Election <$> o .: "name" <*> o .: "description" @@ -519,21 +519,17 @@ instance ToJSON (ElectionCrypto c) where toJSON (ElectionCrypto_FFC ffc pubKey) = JSON.object [ "group" .= ffc - , "y" .= nat pubKey + , "y" .= pubKey ] toEncoding (ElectionCrypto_FFC ffc pubKey) = JSON.pairs ( "group" .= ffc - <> "y" .= nat pubKey + <> "y" .= pubKey ) -instance FromJSON (ElectionCrypto c) where +instance FromJSON (ElectionCrypto ()) where parseJSON = JSON.withObject "ElectionCrypto" $ \o -> do ffc <- o .: "group" pubKey <- reify ffc $ \(_::Proxy s) -> nat <$> ((.:) @(PublicKey s) o "y") - {- - unless (nat ffc_groupGen < ffc_fieldCharac) $ - JSON.typeMismatch "FFC: groupGen is not lower than fieldCharac" (JSON.Object o) - -} return $ ElectionCrypto_FFC ffc (G (F pubKey)) -- 2.47.2