Skip to content

Define Aggregate crypto interface (to mint certs) and corresponding prototype implem#1937

Closed
tbagrel1 wants to merge 11 commits into
mainfrom
peras/aggregate-crypto-cert
Closed

Define Aggregate crypto interface (to mint certs) and corresponding prototype implem#1937
tbagrel1 wants to merge 11 commits into
mainfrom
peras/aggregate-crypto-cert

WIP interface design for vote aggregation

10425bc
Select commit
Loading
Failed to load commit list.
IOG Hydra / ci/hydra-build:x86_64-linux.native.formattingLinting.fourmolu failed Mar 26, 2026 in 13s

Build failed

1 failed steps

Details

Failed Steps

Step 1

Derivation

/nix/store/r6qvfivwdgqxg3702hmy5m123hp0wgr2-check-fourmolu-exe-fourmolu.drv

Log

unpacking source archive /nix/store/9wiicvfnwd8cik419r0cqs4h76d40csd-9lvgxnpwcafzkqqvfdypcvrnvpy9aj3k-source
source root is 9lvgxnpwcafzkqqvfdypcvrnvpy9aj3k-source
The custom options for formatting this repo are:
fourmolu 0.18.0.0
using ghc-lib-parser 9.12.3.20251228
> indentation: 2
> column-limit: 100
> import-export-style: leading
> haddock-style: single-line
> single-constraint-parens: never
> single-deriving-parens: never
> import-grouping: single

Formatting haskell files...
Loaded config from: fourmolu.yaml
diff -ru /nix/store/9wiicvfnwd8cik419r0cqs4h76d40csd-9lvgxnpwcafzkqqvfdypcvrnvpy9aj3k-source/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Committee/WFALS.hs ./ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Committee/WFALS.hs
--- /nix/store/9wiicvfnwd8cik419r0cqs4h76d40csd-9lvgxnpwcafzkqqvfdypcvrnvpy9aj3k-source/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Committee/WFALS.hs      1970-01-01 00:00:01.000000000 +0000
+++ ./ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Committee/WFALS.hs        2026-03-26 15:00:56.858549120 +0000
@@ -568,84 +568,86 @@
     WFALSCommitteeSelection crypto ->
     Cert (WFALSCommitteeSelection crypto) ->
     Either (WFALSCommitteeSelectionError crypto) (NonEmpty (WFALSCommitteeMember crypto))
-  verifyCert selection WFALSCert
-                         { certElectionId
-                         , certVoteMessage
-                         , persistentVoters
-                         , nonPersistentVotersToEligibility
-                         , groupSignature
-                         } = do
-    -- Check that the cert's election ID matches the committee selection's election ID
-    if certElectionId /= csElectionId selection
-      then Left CertElectionIdMismatch
-      else pure ()
-
-    let pvIndices = bitmapToIndices persistentVoters
-
-    -- Look up persistent members
-    sortedPvMembers <-
-      sortOn memberSeatIndex
-        <$> mapM (\seatIndex -> lookupPersistentCommitteeMember selection seatIndex) pvIndices
-
-    -- Look up non-persistent members
-    sortedNpvMembers <-
-      sortOn memberSeatIndex
-        <$> mapM
-          (\(seatIndex, vrfOut) -> lookupNonPersistentCommitteeMember selection seatIndex vrfOut)
-          (Map.toList nonPersistentVotersToEligibility)
-
-    let allMembers = sortedPvMembers ++ sortedNpvMembers
-    members <- assert (sortOn memberSeatIndex allMembers == allMembers) $
-      case NE.nonEmpty allMembers of
-        Nothing -> Left EmptyCert
-        Just ne -> Right ne
-
-    -- Extract keys for verification
-    let
-      sortedPvSignPubKeys = getVoteSignaturePublicKey (Proxy @crypto) . memberPubKeys <$> sortedPvMembers
-
-      sortedNpvPubKeys = memberPubKeys <$> sortedNpvMembers
-      sortedNpvSignPubKeys = getVoteSignaturePublicKey (Proxy @crypto) <$> sortedNpvPubKeys
-      sortedNpvVRFVerifyKeys = getVRFVerifyKey (Proxy @crypto) <$> sortedNpvPubKeys
-
-      sortedNpvVRFOutputs = nonPersistentMemberVRFOutput <$> sortedNpvMembers
-
-      vrfElectionInput = mkVRFElectionInput @crypto (epochNonce selection) certElectionId
-
-    -- Group VRF verification
-    () <- assert (length sortedNpvVRFVerifyKeys == length sortedNpvVRFOutputs) $
-      case (NE.nonEmpty sortedNpvVRFVerifyKeys, NE.nonEmpty sortedNpvVRFOutputs) of
-        (Just vrfVerifyKeys, Just vrfOutputs) ->
-          -- We do group verification of the VRF output
-          -- Crypto schemes can use the trivial CryptoSupportsNaiveGroupVRF instance, which under the hood just verifies each VRF output individually, if they want to opt out of this optimization
-          let groupVerifyKey = sconcat $ liftVRFVerifyKey (Proxy @crypto) <$> vrfVerifyKeys
-              groupVRFOutput = sconcat $ liftVRFOutput (Proxy @crypto) <$> vrfOutputs
-           in first InvalidGroupVRF $
-                verifyGroupVRF (Proxy @crypto) groupVerifyKey vrfElectionInput groupVRFOutput
-        (Nothing, Nothing) -> pure ()
-        _ ->
-          error
-            "The two lists have initially the same length, so they should both be empty or both be non-empty"
-
-    -- Group signature verification
-    let sortedSignPubKeys = sortedPvSignPubKeys ++ sortedNpvSignPubKeys
-    () <- assert (length sortedSignPubKeys == length allMembers) $
-      case NE.nonEmpty sortedSignPubKeys of
-        Just signPubKeys ->
-          let groupPublicKey = sconcat $ liftVoteSignaturePublicKey (Proxy @crypto) <$> signPubKeys
-           in first InvalidGroupVoteSignature $
-                verifyGroupVoteSignature
-                  (Proxy @crypto)
-                  groupPublicKey
-                  certElectionId
-                  certVoteMessage
-                  groupSignature
-        Nothing -> pure ()
-
-    Right members
-   where
-    memberPubKeys m = let (_, _, pk, _, _) = committeeMemberCandidate m in pk
-    memberSeatIndex m = let (seatIndex, _, _, _, _) = committeeMemberCandidate m in seatIndex
+  verifyCert
+    selection
+    WFALSCert
+      { certElectionId
+      , certVoteMessage
+      , persistentVoters
+      , nonPersistentVotersToEligibility
+      , groupSignature
+      } = do
+      -- Check that the cert's election ID matches the committee selection's election ID
+      if certElectionId /= csElectionId selection
+        then Left CertElectionIdMismatch
+        else pure ()
+
+      let pvIndices = bitmapToIndices persistentVoters
+
+      -- Look up persistent members
+      sortedPvMembers <-
+        sortOn memberSeatIndex
+          <$> mapM (\seatIndex -> lookupPersistentCommitteeMember selection seatIndex) pvIndices
+
+      -- Look up non-persistent members
+      sortedNpvMembers <-
+        sortOn memberSeatIndex
+          <$> mapM
+            (\(seatIndex, vrfOut) -> lookupNonPersistentCommitteeMember selection seatIndex vrfOut)
+            (Map.toList nonPersistentVotersToEligibility)
+
+      let allMembers = sortedPvMembers ++ sortedNpvMembers
+      members <- assert (sortOn memberSeatIndex allMembers == allMembers) $
+        case NE.nonEmpty allMembers of
+          Nothing -> Left EmptyCert
+          Just ne -> Right ne
+
+      -- Extract keys for verification
+      let
+        sortedPvSignPubKeys = getVoteSignaturePublicKey (Proxy @crypto) . memberPubKeys <$> sortedPvMembers
+
+        sortedNpvPubKeys = memberPubKeys <$> sortedNpvMembers
+        sortedNpvSignPubKeys = getVoteSignaturePublicKey (Proxy @crypto) <$> sortedNpvPubKeys
+        sortedNpvVRFVerifyKeys = getVRFVerifyKey (Proxy @crypto) <$> sortedNpvPubKeys
+
+        sortedNpvVRFOutputs = nonPersistentMemberVRFOutput <$> sortedNpvMembers
+
+        vrfElectionInput = mkVRFElectionInput @crypto (epochNonce selection) certElectionId
+
+      -- Group VRF verification
+      () <- assert (length sortedNpvVRFVerifyKeys == length sortedNpvVRFOutputs) $
+        case (NE.nonEmpty sortedNpvVRFVerifyKeys, NE.nonEmpty sortedNpvVRFOutputs) of
+          (Just vrfVerifyKeys, Just vrfOutputs) ->
+            -- We do group verification of the VRF output
+            -- Crypto schemes can use the trivial CryptoSupportsNaiveGroupVRF instance, which under the hood just verifies each VRF output individually, if they want to opt out of this optimization
+            let groupVerifyKey = sconcat $ liftVRFVerifyKey (Proxy @crypto) <$> vrfVerifyKeys
+                groupVRFOutput = sconcat $ liftVRFOutput (Proxy @crypto) <$> vrfOutputs
+             in first InvalidGroupVRF $
+                  verifyGroupVRF (Proxy @crypto) groupVerifyKey vrfElectionInput groupVRFOutput
+          (Nothing, Nothing) -> pure ()
+          _ ->
+            error
+              "The two lists have initially the same length, so they should both be empty or both be non-empty"
+
+      -- Group signature verification
+      let sortedSignPubKeys = sortedPvSignPubKeys ++ sortedNpvSignPubKeys
+      () <- assert (length sortedSignPubKeys == length allMembers) $
+        case NE.nonEmpty sortedSignPubKeys of
+          Just signPubKeys ->
+            let groupPublicKey = sconcat $ liftVoteSignaturePublicKey (Proxy @crypto) <$> signPubKeys
+             in first InvalidGroupVoteSignature $
+                  verifyGroupVoteSignature
+                    (Proxy @crypto)
+                    groupPublicKey
+                    certElectionId
+                    certVoteMessage
+                    groupSignature
+          Nothing -> pure ()
+
+      Right members
+     where
+      memberPubKeys m = let (_, _, pk, _, _) = committeeMemberCandidate m in pk
+      memberSeatIndex m = let (seatIndex, _, _, _, _) = committeeMemberCandidate m in seatIndex
 
-    nonPersistentMemberVRFOutput (NonPersistentCommitteeMember _ vrfOutput _ _) = vrfOutput
-    nonPersistentMemberVRFOutput _ = error "This function should only be called on non-persistent members"
+      nonPersistentMemberVRFOutput (NonPersistentCommitteeMember _ vrfOutput _ _) = vrfOutput
+      nonPersistentMemberVRFOutput _ = error "This function should only be called on non-persistent members"
*** fourmolu-exe-fourmolu-0.18.0.0 found changes that need addressed first