Function secp256k1Verify

  • Verify whether a message was signed with the private key belonging to the public key.

    Parameters

    • message: Bytes

      the data that was signed

    • signature: Bytes

      the signature generated by signing the message

    • publicKey: Bytes

      the public key counterpart of the private key used to sign the message.

    Returns bool

    Example

    const message = Bytes.fromUtf8String("Hello, SEDA!");
    const signature = Bytes.fromHexString(
    "58376cc76f4d4959b0adf8070ecf0079db889915a75370f6e39a8451ba5be0c35f091fa4d2fda3ced5b6e6acd1dbb4a45f2c6a1e643622ee4cf8b802b373d38f",
    );
    const publicKey = Bytes.fromHexString(
    "02a2bebd272aa28e410cc74cef28e5ce74a9ffc94caf817ed9bd23b01ce2068c7b",
    );
    const isValidSignature = secp256k1Verify(message, signature, publicKey);

    Console.log(isValidSignature ? "valid" : "invalid"); // "valid"