verify method

bool verify(
  1. SchnorrkelSignature signature,
  2. MerlinTranscript signingContextScript
)

Verifies a Schnorrkel signature using the public key and a transcript.

This method verifies a Schnorrkel signature by appending context-specific information from the signing context script and performing the necessary cryptographic operations. It checks the validity of the provided signature.

Parameters:

  • signature: The Schnorrkel signature to be verified.
  • signingContextScript: A transcript containing context-specific information for signature verification.

Returns: A boolean indicating whether the signature is valid (true) or not (false).

Example Usage:

SchnorrkelPublicKey publicKey = ...;
SchnorrkelSignature signature = ...;
MerlinTranscript signingContextScript = ...;
bool isSignatureValid = publicKey.verify(signature, signingContextScript);

The verify method is used to verify a Schnorrkel signature using the public key and context-specific information. It returns true if the signature is valid, and false otherwise

Implementation

bool verify(
    SchnorrkelSignature signature, MerlinTranscript signingContextScript) {
  signingContextScript.additionalData(
      "proto-name".codeUnits, "Schnorr-sig".codeUnits);
  signingContextScript.additionalData("sign:pk".codeUnits, toBytes());
  signingContextScript.additionalData("sign:R".codeUnits, signature.r);
  final kBigint = signingContextScript.toBigint("sign:c".codeUnits, 64);
  final r = ((-toPoint()) * kBigint) +
      (Curves.generatorED25519 * signature.sBigint);
  return BytesUtils.bytesEqual(r.toBytes(), signature.r);
}