BLS
BLS signatures over BLS12-381 with aggregation and proofs of possession.
Warning
Experimental: draft-irtf-cfrg-bls-signature is an Internet-Draft, and its ciphersuites may change before publication.
from oxcrypto.signature.bls import BLS
keys = [BLS.MIN_PK.generate() for _ in range(3)]
publics = [key.public_key() for key in keys]
assert all(p.verify_possession(k.prove_possession()) for k, p in zip(keys, publics))
signature = BLS.MIN_PK.aggregate([key.sign(b"message") for key in keys])
assert BLS.MIN_PK.fast_aggregate_verify(signature, b"message", publics)Experimental. The specification is an Internet-Draft and may still change.
oxcrypto implements the proof-of-possession scheme of draft-irtf-cfrg-bls-signature with SHA-256 hash-to-curve:
| Selector | Public key | Signature | Signature DST |
|---|---|---|---|
BLS.MIN_PK | 48-byte G1 point | 96-byte G2 point | BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_ |
BLS.MIN_SIG | 96-byte G2 point | 48-byte G1 point | BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_POP_ |
Proofs of possession use the matching BLS_POP_ DST. BLS.MIN_PK is the
ciphersuite used by Ethereum consensus.
generate()derives a key with the draft'sKeyGenfrom 32 bytes of operating system randomness.load_private_bytestakes the 32-byte big-endian scalar and rejects zero and values at or above the group order.load_public_bytestakes a compressed point and rejects the identity and points outside the prime-order subgroup.prove_possession()andverify_possession(proof)create and check a proof that the signer holds the private key.aggregate(signatures)combines signatures; an empty list or a malformed signature raisesValueError.fast_aggregate_verify(signature, message, public_keys)checks an aggregate over one shared message. Verify each key's proof of possession before trusting the result; without it, rogue-key attacks are possible.aggregate_verify(signature, messages, public_keys)checks an aggregate wherepublic_keys[i]signedmessages[i]. Mismatched lengths raiseValueError.
The draft defines no PKCS#8 or SPKI encoding, so keys load and serialize as raw bytes only.
| Standard | draft-irtf-cfrg-bls-signature-07, Internet-Draft (CFRG) |
| Crate | blst 0.3.17 (Apache-2.0), stable; builds C and assembly with the cc crate |
| Audit | NCC Group, January 2021; formal verification by Galois is ongoing |
| MSRV | Builds with the project MSRV 1.88 |
| Experimental | Yes |
| Test vectors | ethereum/bls12-381-tests v0.1.2 (sign, verify, aggregate, fast_aggregate_verify, aggregate_verify) for MIN_PK; no published MIN_SIG proof-of-possession vectors, so MIN_SIG is covered by round trips and failure cases |
Zeroization
oxcrypto stores the private scalar in a buffer it zeroizes on drop and
rebuilds a blst SecretKey for each operation. Read from the blst 0.3.17
source (oxcrypto has not verified it independently): SecretKey is zeroized
on drop and KeyGen wipes its HKDF state.
Note
Short-lived copies of the scalar on the stack during signing are not wiped,
and Python bytes passed in or returned are not wiped.
Constant-time signing is attributed to
blst and has not been verified by oxcrypto.