dleqVerify method

bool dleqVerify(
  1. MerlinTranscript script,
  2. VRFInOut out,
  3. VRFProof proof, {
  4. bool isKusamaVRF = true,
})

Verifies a Discrete Logarithm Equality (DLEQ) proof for a Verifiable Random Function (VRF) output.

This method verifies the validity of a DLEQ proof for a VRF output by comparing it to a transcript and the provided proof.

Parameters:

  • script: A transcript containing context-specific information used for DLEQ proof verification.
  • out: The VRF input and output pair to be verified.
  • proof: The DLEQ proof associated with the VRF output.
  • isKusamaVRF (optional): A boolean indicating whether it's a Kusama VRF. Default is true.

Returns: A boolean indicating whether the DLEQ proof for the VRF output is valid (true) or not (false).

Example Usage:

MerlinTranscript script = ...;
VRFInOut vrfInOut = ...;
VRFProof proof = ...;
bool isDLEQProofValid = dleqVerify(script, vrfInOut, proof);

The dleqVerify method is used to verify the validity of a Discrete Logarithm Equality (DLEQ) proof for a Verifiable Random Function (VRF) output by comparing it to a transcript and the provided proof. It returns true if the DLEQ proof is valid, and false otherwise.

Implementation

bool dleqVerify(MerlinTranscript script, VRFInOut out, VRFProof proof,
    {bool isKusamaVRF = true}) {
  script.additionalData("proto-name".codeUnits, "DLEQProof".codeUnits);
  script.additionalData("vrf:h".codeUnits, out.input);
  if (!isKusamaVRF) {
    script.additionalData("vrf:pk".codeUnits, toBytes());
  }
  final pr =
      (toPoint() * proof.cBigint) + (Curves.generatorED25519 * proof.sBigint);
  script.additionalData("vrf:R=g^r".codeUnits, pr.toBytes());
  final hr =
      (out.outputPoint * proof.cBigint) + (out.inputPoint * proof.sBigint);
  script.additionalData("vrf:h^r".codeUnits, hr.toBytes());
  if (isKusamaVRF) {
    script.additionalData("vrf:pk".codeUnits, toBytes());
  }
  script.additionalData("vrf:h^sk".codeUnits, out.output);
  final c = script.toBytesWithReduceScalar("prove".codeUnits, 64);
  return bytesEqual(c, proof.c);
}