zk/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Traits for working with zero-knowledge proofs.

use rand_core::RngCore;

/// Trait for a zero-knowledge proof about some statement.
pub trait Proof: Sized {
    /// The parameters necessary to create a proof.
    type ProvingKey;

    /// The parameters necessary to verify a proof.
    type VerifyingKey;

    /// The input commonly known to both the prover and verifier.
    type Instance;

    /// The private input to the prover.
    type Witness;

    /// Errors that may occur while creating or verifying proofs.
    type Error;

    /// Creates a proof that the given instance and witness satisfy the statement.
    fn create<R: RngCore>(
        pk: &Self::ProvingKey,
        instance: &Self::Instance,
        witness: &Self::Witness,
        rng: R,
    ) -> Result<Self, Self::Error>;

    /// Verifies that this proof satisfies the statement for the given instance.
    fn verify(&self, vk: &Self::VerifyingKey, instance: &Self::Instance)
        -> Result<(), Self::Error>;
}