Skip to main content
Version: v1.0.0-beta.0

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<let N: u32>(
public_key_x: Field,
public_key_y: Field,
signature: [u8; 64],
message: [u8; N],
) -> bool
Source code: noir_stdlib/src/schnorr.nr#L4-L11

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()
);

...

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#L15-L22

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