vrfSign method

Tuple<VRFInOut, VRFProof> vrfSign(
  1. MerlinTranscript script, {
  2. GenerateRandom? nonceGenerator,
  3. bool kusamaVRF = true,
  4. MerlinTranscript? verifyScript,
})

Generates a Verifiable Random Function (VRF) output and its proof for a given transcript.

This method generates a VRF output and its corresponding proof for a provided transcript by performing VRF computations using the secret key and the transcript's context-specific information.

Parameters:

  • script: A transcript containing context-specific information for VRF signing.

Returns: A tuple containing a VRFInOut representing the VRF output and a VRFProof as its proof.

Example Usage:

MerlinTranscript script = ...;
SchnorrkelSecretKey secretKey = ...;
var (vrfOutput, vrfProof) = secretKey.vrfSign(script);

The vrfSign method generates a VRF output and its proof for a given transcript using the secret key and context-specific information. It returns a tuple with the VRF output and its proof.

Implementation

Tuple<VRFInOut, VRFProof> vrfSign(MerlinTranscript script,
    {GenerateRandom? nonceGenerator,
    bool kusamaVRF = true,
    MerlinTranscript? verifyScript}) {
  final publicHashPoint = publicKey().vrfHash(script);
  final keyBig = BigintUtils.fromBytes(key(), byteOrder: Endian.little);
  final mul = publicHashPoint * keyBig;
  final vrf = VRFInOut._(publicHashPoint.toBytes(), mul.toBytes());
  return Tuple(
      vrf,
      dleqProve(vrf,
          nonceGenerator: nonceGenerator,
          kusamaVRF: kusamaVRF,
          verifyScript: verifyScript));
}