Skip to content

Module BSV::Primitives::Schnorr

BRC-94 Schnorr zero-knowledge proof protocol.

Provides generation and verification of Schnorr proofs for verifiable revelation of ECDH shared secrets. Given two public keys A and B and a shared secret S = a*B (where a is A's private key), the prover can demonstrate knowledge of the discrete log relationship without revealing the private key.

  • @see https://github.com/bitcoin-sv/BRCs/blob/master/peer-to-peer/0094.md BRC-94

Public Class Methods

generate_proof(private_key, public_key_a, public_key_b, shared_secret)

Generate a Schnorr proof of knowledge of a shared secret.

Proves that the prover knows the private key a such that +shared_secret = a * public_key_b+, without revealing a. - @param private_key [PrivateKey] the prover's private key (a) - @param public_key_a [PublicKey] the prover's public key (A = aG) - @param public_key_b [PublicKey] the counterparty's public key (B) - @param shared_secret [PublicKey] the ECDH shared secret (S = aB) - @return [Proof] the Schnorr proof

verify_proof(public_key_a, public_key_b, shared_secret, proof)

Verify a Schnorr proof of knowledge of a shared secret.

Checks the two verification equations: 1. zG == R + eA 2. zB == S' + eS - @param public_key_a [PublicKey] the prover's public key - @param public_key_b [PublicKey] the counterparty's public key - @param shared_secret [PublicKey] the claimed shared secret - @param proof [Proof] the Schnorr proof to verify - @return [Boolean] +true+ if the proof is valid