vrfVerify method

  1. @override
bool vrfVerify(
  1. List<int> message,
  2. List<int> vrfSign, {
  3. List<int>? context,
  4. List<int>? extra,
})
override

Implementation

@override
bool vrfVerify(List<int> message, List<int> vrfSign,
    {List<int>? context, List<int>? extra}) {
  if (vrfSign.length != _SubstrateEcdsaSignerCons.vrfLength) {
    throw ArgumentException(
        "Invalid vrf length. excepted: ${_SubstrateEcdsaSignerCons.vrfLength} got: ${vrfSign.length}");
  }
  final List<int> signature =
      vrfSign.sublist(QuickCrypto.blake2b256DigestSize);
  final verifySignature = verify(message, signature);

  if (verifySignature) {
    final vrfHash = vrfSign.sublist(0, QuickCrypto.blake2b256DigestSize);
    final vrf = QuickCrypto.blake2b256Hash([
      ...BytesUtils.tryToBytes(context) ?? [],
      ...BytesUtils.tryToBytes(extra) ?? [],
      ...signature,
    ]);
    return BytesUtils.bytesEqual(vrf, vrfHash);
  }
  return false;
}