Class BLSSigner
- java.lang.Object
-
- org.bouncycastle.crypto.signers.BLSSigner
-
- All Implemented Interfaces:
Signer
public class BLSSigner extends java.lang.Object implements Signer
Generic BLS12-381 signer implementing the BCSignerinterface.Signs and verifies under a configurable BLS hash-to-curve domain separation tag, defaulting to the BasicScheme DST
BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_. TheBLSSigner(byte[])constructor lets callers select the ProofOfPossession DST (BLS12_381ProofOfPossession.DST) for Eth2 interop, or supply any other RFC 9380 DST.Note that the MessageAugmentation suite is intentionally NOT supported here, since its hash input is
pk || msg— the pubkey must be available at sign time, which doesn't fit theSigner"sk + buffered message" contract cleanly. Callers wanting AUG should useBLS12_381MessageAugmentationdirectly.Produces and accepts 96-byte Zcash-format compressed G2 signatures, the same encoding used by Eth2 / IETF draft-irtf-cfrg-bls-signature.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]generateSignature()generate a signature for the message we've been loaded with using the key we were initialised with.voidinit(boolean forSigning, CipherParameters param)Initialise the signer for signing or verification.voidreset()reset the internal statevoidupdate(byte b)update the internal digest with the byte bvoidupdate(byte[] in, int off, int len)update the internal digest with the byte array inbooleanverifySignature(byte[] signature)return true if the internal state represents the signature described in the passed in array.
-
-
-
Constructor Detail
-
BLSSigner
public BLSSigner()
Construct a signer with the BasicScheme DST (BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_).
-
BLSSigner
public BLSSigner(byte[] dst)
Construct a signer with an explicit hash-to-curve DST. For Eth2 interop passBLS12_381ProofOfPossession.DST.
-
-
Method Detail
-
init
public void init(boolean forSigning, CipherParameters param)Description copied from interface:SignerInitialise the signer for signing or verification.
-
update
public void update(byte b)
Description copied from interface:Signerupdate the internal digest with the byte b
-
update
public void update(byte[] in, int off, int len)Description copied from interface:Signerupdate the internal digest with the byte array in
-
generateSignature
public byte[] generateSignature() throws CryptoExceptionDescription copied from interface:Signergenerate a signature for the message we've been loaded with using the key we were initialised with.- Specified by:
generateSignaturein interfaceSigner- Throws:
CryptoException
-
verifySignature
public boolean verifySignature(byte[] signature)
Description copied from interface:Signerreturn true if the internal state represents the signature described in the passed in array.- Specified by:
verifySignaturein interfaceSigner
-
-