Class BIP340Signer
- All Implemented Interfaces:
Signer
Public keys are the 32-byte big-endian X coordinate of the unique even-Y curve point with that X.
Signatures are the fixed 64-byte concatenation bytes(R) || bytes(s) — neither encoding
matches BC's ECDSA defaults.
Auxiliary randomness follows the usual BC low-level signer convention: the signer is randomized by
default. A ParametersWithRandom on init(boolean, CipherParameters) supplies the source for the fresh 32-byte
aux_rand drawn per generateSignature() call (BIP-340 §3.2, recommended for side-channel
hardening); when none is supplied the default CryptoServicesRegistrar source is substituted, as
for SM2Signer / ECDSASigner. Deterministic Schnorr (aux_rand = 0^32) is BIP-340 compliant
but must be requested explicitly via BIP340Signer(boolean) — the absence of a supplied
SecureRandom does not silently select it.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a randomized BIP-340 signer: a per-signatureaux_randis drawn from the suppliedParametersWithRandomsource, or the defaultCryptoServicesRegistrarsource when none is supplied.BIP340Signer(boolean deterministic) -
Method Summary
Modifier and TypeMethodDescriptionstatic ECPublicKeyParametersdecodePublicKey(byte[] xOnly) Lift a 32-byte x-only BIP-340 public key to anECPublicKeyParameterscarrying the unique even-Y secp256k1 point with that X.byte[]generate a signature for the message we've been loaded with using the key we were initialised with.static ECDomainParameterssecp256k1 domain parameters.voidinit(boolean forSigning, CipherParameters parameters) 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 Details
-
BIP340Signer
public BIP340Signer()Create a randomized BIP-340 signer: a per-signatureaux_randis drawn from the suppliedParametersWithRandomsource, or the defaultCryptoServicesRegistrarsource when none is supplied. -
BIP340Signer
public BIP340Signer(boolean deterministic) - Parameters:
deterministic- whentrue, sign deterministically withaux_rand = 0^32(BIP-340 §3.3 default signing with empty auxiliary randomness) and ignore any supplied SecureRandom; whenfalse(the usual case) draw a per-signature 32-byteaux_randfrom the supplied or default SecureRandom.
-
-
Method Details
-
getDomain
secp256k1 domain parameters. Use to constructECPrivateKeyParameters/ call anECKeyPairGeneratorfor BIP-340. -
decodePublicKey
Lift a 32-byte x-only BIP-340 public key to anECPublicKeyParameterscarrying the unique even-Y secp256k1 point with that X. Returnsnullfor the cases BIP-340 §3.1 defines as verification failures: wrong length, X out of[0, p), or no curve point with that X. -
init
Description copied from interface:SignerInitialise the signer for signing or verification. -
update
-
update
-
generateSignature
public byte[] generateSignature()Description 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
-
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
-
reset
-