[−][src]Struct one_of_many_proofs::proofs::ProofGens
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]
&self,
transcript: &mut Transcript,
l: usize,
a_j: &Vec<Scalar>
) -> ProofResult<(RistrettoPoint, BitProof, Scalar)>
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]
&self,
transcript: &mut Transcript,
B: &RistrettoPoint,
proof: &BitProof
) -> ProofResult<Scalar>
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for ProofGens
[src]
Auto Trait Implementations
impl RefUnwindSafe for ProofGens
impl Send for ProofGens
impl Sync for ProofGens
impl Unpin for ProofGens
impl UnwindSafe for ProofGens
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
fn cast(self) -> U
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> FromBits<T> for T
fn from_bits(t: T) -> T
impl<T> FromCast<T> for T
fn from_cast(t: T) -> T
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
fn into_bits(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,