Skip to main content
Version: dev

Schnorr Signatures

schnorr::verify_signature

Verifier for Schnorr signatures over the embedded curve (for BN254 it is Grumpkin). See schnorr::verify_signature_slice for a version that works directly on slices.

schnorr_verify
pub fn verify_signature<N>(
public_key_x: Field,
public_key_y: Field,
signature: [u8; 64],
message: [u8; N]
) -> bool
Source code: noir_stdlib/src/schnorr.nr#L2-L9

where _signature can be generated like so using the npm package @noir-lang/barretenberg

const { BarretenbergWasm } = require('@noir-lang/barretenberg/dest/wasm');
const { Schnorr } = require('@noir-lang/barretenberg/dest/crypto/schnorr');

...

const barretenberg = await BarretenbergWasm.new();
const schnorr = new Schnorr(barretenberg);
const pubKey = schnorr.computePublicKey(privateKey);
const message = ...
const signature = Array.from(
schnorr.constructSignature(hash, privateKey).toBuffer()
);

...
info

This is a black box function. Read this section to learn more about black box functions in Noir.

schnorr::verify_signature_slice

Verifier for Schnorr signatures over the embedded curve (for BN254 it is Grumpkin) where the message is a slice.

schnorr_verify_slice
pub fn verify_signature_slice(
public_key_x: Field,
public_key_y: Field,
signature: [u8; 64],
message: [u8]
) -> bool
Source code: noir_stdlib/src/schnorr.nr#L13-L20
info

This is a black box function. Read this section to learn more about black box functions in Noir.