[][src]Struct one_of_many_proofs::proofs::ProofGens

pub struct ProofGens {
    pub n_bits: usize,
    // some fields omitted
}

A collection of generator points that can be used to compute various proofs in this module. To create an instance of ProofGens it is recommended to call ProofGens::new(n), where n is the number of bits to be used in proofs and verifications.

Fields

n_bits: usize

Implementations

impl ProofGens[src]

pub fn new(n_bits: usize) -> ProofResult<ProofGens>[src]

Create a new instance of ProofGens with enough generator points to support proof and verification over an n_bit sized set.

// Support 10 bit membership proofs
let gens = ProofGens::new(10);

pub fn max_set_size(&self) -> usize[src]

Returns the maximum set size that can be processed in a proof or verification. For example, a 10 bit proof would only be able to support proofs over a set with at most 2^10 = 1024 members. Note, proofs over smaller sets will be extended by repeating the first member.

pub fn commit(&self, v: &Scalar, r: &Scalar) -> ProofResult<RistrettoPoint>[src]

Create a pedersen commitment, with value v and blinding factor r.

pub fn commit_bits(
    &self,
    transcript: &mut Transcript,
    l: usize,
    a_j: &Vec<Scalar>
) -> ProofResult<(RistrettoPoint, BitProof, Scalar)>
[src]

Commit to the bits in l, and generate the corresponding proof. Note, l must be within the supported set size, eg, for an n bit proof, l mus reside within the range: 0 <= l < 2^n.

This proof uses a merlin transcript to generate a challenge scalar for use as a non-interactive proof protocol.

This function returns the bit commitment, B, its assosciated BitProof, and the challenge scalar x.

// Compute the generators necessary for 5 bit proofs
let gens = ProofGens::new(5).unwrap();
let l = 7; // Some index within the range 0 <= `l` <= 2^5

// The proof requires us to provide random noise values. For secure
// applications, be sure to use a more secure RNG.
let a_j = (0..gens.n_bits)
    .map(|_| Scalar::random(&mut OsRng))
    .collect::<Vec<Scalar>>();

// Create a new transcript and compute the bit commitment and its proof
let mut t = Transcript::new(b"doctest example");
let (B, proof, x) = gens.commit_bits(&mut t, l, &a_j).unwrap();

pub fn verify_bits(
    &self,
    transcript: &mut Transcript,
    B: &RistrettoPoint,
    proof: &BitProof
) -> ProofResult<Scalar>
[src]

Verify a bit commitment proof.

// Create new transcript and verify a bit commitment against its proof
let mut t = Transcript::new(b"doctest example");
assert!(gens.verify_bits(&mut t, &B, &proof).is_ok());

Trait Implementations

impl Clone for ProofGens[src]

impl Debug for ProofGens[src]

impl<'de> Deserialize<'de> for ProofGens[src]

impl Serialize for ProofGens[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> FromBits<T> for T

impl<T> FromCast<T> for T

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,