| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Committee.Crypto.BLS
Description
BLS crypto helpers to instantiate voting committees.
NOTE: this module is meant to be imported qualified.
Synopsis
- data KeyRole
- type KeyScope = ByteString
- data PrivateKey (r ∷ KeyRole)
- rawDeserialisePrivateKey ∷ ∀ (r ∷ KeyRole). KeyScope → ByteString → Maybe (PrivateKey r)
- rawSerialisePrivateKey ∷ ∀ (r ∷ KeyRole). PrivateKey r → ByteString
- coercePrivateKey ∷ ∀ (r2 ∷ KeyRole) (r1 ∷ KeyRole). PrivateKey r1 → PrivateKey r2
- derivePublicKey ∷ ∀ (r ∷ KeyRole). PrivateKey r → PublicKey r
- data PublicKey (r ∷ KeyRole)
- rawDeserialisePublicKey ∷ ∀ (r ∷ KeyRole). KeyScope → ByteString → Maybe (PublicKey r)
- rawSerialisePublicKey ∷ ∀ (r ∷ KeyRole). PublicKey r → ByteString
- coercePublicKey ∷ ∀ (r2 ∷ KeyRole) (r1 ∷ KeyRole). PublicKey r1 → PublicKey r2
- data Signature (r ∷ KeyRole)
- data ProofOfPossession
- class HasBLSContext (r ∷ KeyRole) where
- blsCtx ∷ Proxy r → KeyScope → BLS12381SignContext
- signWithRole ∷ ∀ (r ∷ KeyRole) msg. (SignableRepresentation msg, HasBLSContext r) ⇒ PrivateKey r → msg → Signature r
- verifyWithRole ∷ ∀ (r ∷ KeyRole) msg. (SignableRepresentation msg, HasBLSContext r) ⇒ PublicKey r → msg → Signature r → Either String ()
- createProofOfPossession ∷ PrivateKey 'POP → KeyHash 'StakePool → ProofOfPossession
- verifyProofOfPossession ∷ PublicKey 'POP → KeyHash 'StakePool → ProofOfPossession → Either String ()
- aggregatePublicKeys ∷ ∀ (r ∷ KeyRole). NE [PublicKey r] → Either String (PublicKey r)
- aggregateSignatures ∷ ∀ (r ∷ KeyRole). NE [Signature r] → Either String (Signature r)
- signatureNatural ∷ Signature 'VRF → Natural
- signatureNaturalMax ∷ Natural
- toNormalizedVRFOutput ∷ Signature 'VRF → NormalizedVRFOutput
- linearizeAndVerifyVRFs ∷ SignableRepresentation msg ⇒ NE [PublicKey 'VRF] → msg → NE [Signature 'VRF] → Either String ()
BLS crypto helpers to instantiate voting committees
Key roles
type KeyScope = ByteString Source #
Key scope, later instantiated with usage and network id (e.g. PERAS/MAINNET)
data PrivateKey (r ∷ KeyRole) Source #
BLS private key type, parameterized by key role
Instances
| Show (PrivateKey r) Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS Methods showsPrec ∷ Int → PrivateKey r → ShowS # show ∷ PrivateKey r → String # showList ∷ [PrivateKey r] → ShowS # | |
| Eq (PrivateKey r) Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS | |
rawDeserialisePrivateKey ∷ ∀ (r ∷ KeyRole). KeyScope → ByteString → Maybe (PrivateKey r) Source #
rawSerialisePrivateKey ∷ ∀ (r ∷ KeyRole). PrivateKey r → ByteString Source #
coercePrivateKey ∷ ∀ (r2 ∷ KeyRole) (r1 ∷ KeyRole). PrivateKey r1 → PrivateKey r2 Source #
derivePublicKey ∷ ∀ (r ∷ KeyRole). PrivateKey r → PublicKey r Source #
data PublicKey (r ∷ KeyRole) Source #
BLS public key type, parameterized by key role
rawDeserialisePublicKey ∷ ∀ (r ∷ KeyRole). KeyScope → ByteString → Maybe (PublicKey r) Source #
rawSerialisePublicKey ∷ ∀ (r ∷ KeyRole). PublicKey r → ByteString Source #
data Signature (r ∷ KeyRole) Source #
BLS signature type, parameterized by key role
data ProofOfPossession Source #
BLS proof of possession type
Instances
| FromCBOR ProofOfPossession Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS | |
| ToCBOR ProofOfPossession Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS Methods toCBOR ∷ ProofOfPossession → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ProofOfPossession → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ProofOfPossession] → Size Source # | |
| Show ProofOfPossession Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS Methods showsPrec ∷ Int → ProofOfPossession → ShowS # show ∷ ProofOfPossession → String # showList ∷ [ProofOfPossession] → ShowS # | |
| Eq ProofOfPossession Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS Methods | |
class HasBLSContext (r ∷ KeyRole) where Source #
Role-separated BLS contexts for signatures
Instances
| HasBLSContext 'POP Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS | |
| HasBLSContext 'SIGN Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS | |
| HasBLSContext 'VRF Source # | |
Defined in Ouroboros.Consensus.Committee.Crypto.BLS | |
signWithRole ∷ ∀ (r ∷ KeyRole) msg. (SignableRepresentation msg, HasBLSContext r) ⇒ PrivateKey r → msg → Signature r Source #
Sign a message with a private key, producing a signature
verifyWithRole ∷ ∀ (r ∷ KeyRole) msg. (SignableRepresentation msg, HasBLSContext r) ⇒ PublicKey r → msg → Signature r → Either String () Source #
Verify a signature on a message with a public key
createProofOfPossession ∷ PrivateKey 'POP → KeyHash 'StakePool → ProofOfPossession Source #
Create a proof of possession signature for a private key
verifyProofOfPossession ∷ PublicKey 'POP → KeyHash 'StakePool → ProofOfPossession → Either String () Source #
Verify a proof of possession signature for a public key
Aggregate keys and signatures
aggregatePublicKeys ∷ ∀ (r ∷ KeyRole). NE [PublicKey r] → Either String (PublicKey r) Source #
Aggregate multiple public keys into a single one.
PRECONDITION: all keys must have the same scope.
PRECONDITION: this assumes that proofs of possession have already been verified for all keys in advance.
aggregateSignatures ∷ ∀ (r ∷ KeyRole). NE [Signature r] → Either String (Signature r) Source #
Aggregate multiple signatures into a single one
VRF signature manipulation
signatureNatural ∷ Signature 'VRF → Natural Source #
Convert a BLS signature to a natural number for use in local sortition
signatureNaturalMax ∷ Natural Source #
The maximum natural number that can be produced by a BLS signature
toNormalizedVRFOutput ∷ Signature 'VRF → NormalizedVRFOutput Source #
Create a normalized VRF output from a BLS signature
Linearized VRF output verification
linearizeAndVerifyVRFs ∷ SignableRepresentation msg ⇒ NE [PublicKey 'VRF] → msg → NE [Signature 'VRF] → Either String () Source #
Verify a list of VRF outputs against on the same input using linearization.
The idea is to first aggregate all public keys and VRF outputs into a single aggregate ones. These can then be verified in one go, saving the (higher) cost of multiple signature verifications.
However, since we later derive a numeric value from each individual VRF output, verifying the aggregate signature alone is not sufficient. This is because an attacker could swap their (bad) VRF output with someone else's (better) one, and a naive signature aggregation and verification approach would still succeed.
Instead, each VRF output is first linearized using a scalar derived from the signature itself, and then aggregated together. This way, if an attacker tries to swap their VRF output with someone else's, the linearization will produce a different aggregate signature that will fail verification.
PRECONDITION: all keys must have the same scope.
PRECONDITION: the number of signatures must match the number of keys.