pub struct ZkpProver {}Expand description
Prover for creating zero-knowledge proofs
Implementations§
Source§impl ZkpProver
impl ZkpProver
Sourcepub fn prove_secret_value(
&mut self,
secret_value: &[u8],
_public_statement: &[u8],
) -> Result<ZkpProof, Error>
pub fn prove_secret_value( &mut self, secret_value: &[u8], _public_statement: &[u8], ) -> Result<ZkpProof, Error>
Prove knowledge of a secret value without revealing it
This generates a STARK proof that the prover knows a preimage secret_value
whose Poseidon-128 hash equals the public commitment. The proof uses
Poseidon for constraint encoding (industry-standard for STARKs; e.g. StarkWare,
RISC Zero, Succinct). For a NIST-only hash, use prove_secret_value_nist.
§Arguments
secret_value- The secret preimage to prove knowledge ofpublic_statement- Additional public data (currently unused; reserved for future use)
§Returns
A zero-knowledge proof that can be verified without revealing the secret
§Example
use lib_q_zkp::{ZkpProver, ZkpVerifier};
let mut prover = ZkpProver::new();
let secret = b"my secret password";
let public = b"challenge";
let proof = prover.prove_secret_value(secret, public)?;Sourcepub fn prove_secret_value_nist(
&mut self,
secret_value: &[u8],
_public_statement: &[u8],
) -> Result<ZkpProof, Error>
pub fn prove_secret_value_nist( &mut self, secret_value: &[u8], _public_statement: &[u8], ) -> Result<ZkpProof, Error>
Prove knowledge of a secret value using NIST cSHAKE256 (100% NIST compliance)
Same semantics as prove_secret_value but uses
cSHAKE256 with domain b"HashPreimageNistAir" for the commitment. Use this when
NIST-only hashes are required; prover cost is higher than Poseidon-based proofs.
§Arguments
secret_value- The secret preimage to prove knowledge of_public_statement- Reserved for future use
Sourcepub fn prove_computation(
&mut self,
circuit: &ArithmeticCircuit<BinomialExtensionField<Mersenne31, 2>>,
witness: &[BinomialExtensionField<Mersenne31, 2>],
public: &[BinomialExtensionField<Mersenne31, 2>],
) -> Result<ZkpProof, Error>
pub fn prove_computation( &mut self, circuit: &ArithmeticCircuit<BinomialExtensionField<Mersenne31, 2>>, witness: &[BinomialExtensionField<Mersenne31, 2>], public: &[BinomialExtensionField<Mersenne31, 2>], ) -> Result<ZkpProof, Error>
Prove a computation using a circuit
This generates a STARK proof that the prover knows witness values that satisfy all constraints in the arithmetic circuit.
§Arguments
circuit- The arithmetic circuit defining the computationwitness- The witness values (private inputs)public- The public input values
§Returns
A zero-knowledge proof of computation correctness
§Example
use lib_q_zkp::{ZkpProver, circuit::CircuitBuilder};
use lib_q_stark_field::extension::Complex;
use lib_q_stark_mersenne31::Mersenne31;
type Val = Complex<Mersenne31>;
// Build a circuit: prove knowledge of a, b such that a * b = public_output
let mut builder = CircuitBuilder::<Val>::new(2, 1);
let a = builder.wire(0);
let b = builder.wire(1);
let output = builder.wire(2);
let product = builder.mul(a, b);
builder.assert_eq(product, output);
let circuit = builder.build();
// Generate proof
let witness = vec![Val::from(3u32), Val::from(4u32)];
let public = vec![Val::from(12u32)];
let mut prover = ZkpProver::new();
let proof = prover.prove_computation(&circuit, &witness, &public)?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZkpProver
impl RefUnwindSafe for ZkpProver
impl Send for ZkpProver
impl Sync for ZkpProver
impl Unpin for ZkpProver
impl UnsafeUnpin for ZkpProver
impl UnwindSafe for ZkpProver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more