Skip to Content
oxcrypto

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:

SelectorPublic keySignatureSignature DST
BLS.MIN_PK48-byte G1 point96-byte G2 pointBLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
BLS.MIN_SIG96-byte G2 point48-byte G1 pointBLS_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's KeyGen from 32 bytes of operating system randomness. load_private_bytes takes the 32-byte big-endian scalar and rejects zero and values at or above the group order.
  • load_public_bytes takes a compressed point and rejects the identity and points outside the prime-order subgroup.
  • prove_possession() and verify_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 raises ValueError.
  • 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 where public_keys[i] signed messages[i]. Mismatched lengths raise ValueError.

The draft defines no PKCS#8 or SPKI encoding, so keys load and serialize as raw bytes only.

Standarddraft-irtf-cfrg-bls-signature-07, Internet-Draft (CFRG)
Crateblst 0.3.17 (Apache-2.0), stable; builds C and assembly with the cc crate
AuditNCC Group, January 2021; formal verification by Galois is ongoing
MSRVBuilds with the project MSRV 1.88
ExperimentalYes
Test vectorsethereum/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.

On this page