@@ -13,24 +13,24 @@ use sha3::{Sha3XofReader, Shake256};
1313
1414/// Represents a pair of base points for Pedersen commitments.
1515#[ derive( Copy , Clone ) ]
16- pub struct PedersenGenerators {
16+ pub struct PedersenGens {
1717 /// Base for the committed value
1818 pub B : RistrettoPoint ,
1919
2020 /// Base for the blinding factor
2121 pub B_blinding : RistrettoPoint ,
2222}
2323
24- impl PedersenGenerators {
24+ impl PedersenGens {
2525 /// Creates a Pedersen commitment using the value scalar and a blinding factor.
2626 pub fn commit ( & self , value : Scalar , blinding : Scalar ) -> RistrettoPoint {
2727 RistrettoPoint :: multiscalar_mul ( & [ value, blinding] , & [ self . B , self . B_blinding ] )
2828 }
2929}
3030
31- impl Default for PedersenGenerators {
31+ impl Default for PedersenGens {
3232 fn default ( ) -> Self {
33- PedersenGenerators {
33+ PedersenGens {
3434 B : GeneratorsChain :: new ( b"Bulletproofs.Generators.B" )
3535 . next ( )
3636 . unwrap ( ) ,
@@ -81,79 +81,65 @@ impl Iterator for GeneratorsChain {
8181 }
8282}
8383
84- /// The `Generators ` struct contains all the generators needed for
84+ /// The `BulletproofGens ` struct contains all the generators needed for
8585/// aggregating `m` range proofs of `n` bits each.
8686#[ derive( Clone ) ]
87- pub struct Generators {
88- /// Bases for Pedersen commitments
89- pub pedersen_gens : PedersenGenerators ,
87+ pub struct BulletproofGens {
9088 /// The maximum number of usable generators for each party.
9189 pub gens_capacity : usize ,
9290 /// Number of values or parties
9391 pub party_capacity : usize ,
94- /// Per-bit generators for the bit values
92+ /// Precomputed \\(\mathbf G\\) generators for each party.
9593 G_vec : Vec < Vec < RistrettoPoint > > ,
96- /// Per-bit generators for the bit blinding factors
94+ /// Precomputed \\(\mathbf H\\) generators for each party.
9795 H_vec : Vec < Vec < RistrettoPoint > > ,
9896}
9997
100- impl Generators {
101- /// Create a new `Generators ` object.
98+ impl BulletproofGens {
99+ /// Create a new `BulletproofGens ` object.
102100 ///
103101 /// # Inputs
104102 ///
105- /// * `pedersen_gens` is a pair of generators used for Pedersen
106- /// commitments.
107103 /// * `gens_capacity` is the number of generators to precompute
108104 /// for each party. For rangeproofs, it is sufficient to pass
109105 /// `64`, the maximum bitsize of the rangeproofs. For circuit
110106 /// proofs, the capacity must be greater than the number of
111107 /// multipliers, rounded up to the next power of two.
112108 /// * `party_capacity` is the maximum number of parties that can
113109 /// produce an aggregated proof.
114- pub fn new (
115- pedersen_gens : PedersenGenerators ,
116- gens_capacity : usize ,
117- party_capacity : usize ,
118- ) -> Self {
110+ pub fn new ( gens_capacity : usize , party_capacity : usize ) -> Self {
119111 use byteorder:: { ByteOrder , LittleEndian } ;
120112
121- let G_vec = ( 0 ..party_capacity)
122- . map ( |i| {
123- let party_index = i as u32 ;
124- let mut label = [ b'G' , 0 , 0 , 0 , 0 ] ;
125- LittleEndian :: write_u32 ( & mut label[ 1 ..5 ] , party_index) ;
126-
127- GeneratorsChain :: new ( & label)
128- . take ( gens_capacity)
129- . collect :: < Vec < _ > > ( )
130- } ) . collect ( ) ;
131-
132- let H_vec = ( 0 ..party_capacity)
133- . map ( |i| {
134- let party_index = i as u32 ;
135- let mut label = [ b'H' , 0 , 0 , 0 , 0 ] ;
136- LittleEndian :: write_u32 ( & mut label[ 1 ..5 ] , party_index) ;
137-
138- GeneratorsChain :: new ( & label)
139- . take ( gens_capacity)
140- . collect :: < Vec < _ > > ( )
141- } ) . collect ( ) ;
142-
143- Generators {
144- pedersen_gens,
113+ BulletproofGens {
145114 gens_capacity,
146115 party_capacity,
147- G_vec ,
148- H_vec ,
116+ G_vec : ( 0 ..party_capacity)
117+ . map ( |i| {
118+ let party_index = i as u32 ;
119+ let mut label = [ b'G' , 0 , 0 , 0 , 0 ] ;
120+ LittleEndian :: write_u32 ( & mut label[ 1 ..5 ] , party_index) ;
121+
122+ GeneratorsChain :: new ( & label)
123+ . take ( gens_capacity)
124+ . collect :: < Vec < _ > > ( )
125+ } ) . collect ( ) ,
126+ H_vec : ( 0 ..party_capacity)
127+ . map ( |i| {
128+ let party_index = i as u32 ;
129+ let mut label = [ b'H' , 0 , 0 , 0 , 0 ] ;
130+ LittleEndian :: write_u32 ( & mut label[ 1 ..5 ] , party_index) ;
131+
132+ GeneratorsChain :: new ( & label)
133+ . take ( gens_capacity)
134+ . collect :: < Vec < _ > > ( )
135+ } ) . collect ( ) ,
149136 }
150137 }
151138
152139 /// Returns j-th share of generators, with an appropriate
153140 /// slice of vectors G and H for the j-th range proof.
154- pub fn share ( & self , j : usize ) -> GeneratorsView {
155- GeneratorsView {
156- pedersen_gens : & self . pedersen_gens ,
141+ pub fn share ( & self , j : usize ) -> BulletproofGensShare {
142+ BulletproofGensShare {
157143 gens : & self ,
158144 share : j,
159145 }
@@ -214,22 +200,20 @@ impl<'a> Iterator for AggregatedGensIter<'a> {
214200 }
215201}
216202
217- /// The `GeneratorsView ` is produced by `Generators ::share()`.
203+ /// The `BulletproofGensShare ` is produced by `BulletproofGens ::share()`.
218204///
219- /// The `Generators ` struct represents generators for an aggregated
220- /// range proof `m` proofs of `n` bits each; the `GeneratorsView `
205+ /// The `BulletproofGens ` struct represents generators for an aggregated
206+ /// range proof `m` proofs of `n` bits each; the `BulletproofGensShare `
221207/// represents the generators for one of the `m` parties' shares.
222208#[ derive( Copy , Clone ) ]
223- pub struct GeneratorsView < ' a > {
224- /// Bases for Pedersen commitments
225- pub pedersen_gens : & ' a PedersenGenerators ,
209+ pub struct BulletproofGensShare < ' a > {
226210 /// The parent object that this is a view into
227- gens : & ' a Generators ,
211+ gens : & ' a BulletproofGens ,
228212 /// Which share we are
229213 share : usize ,
230214}
231215
232- impl < ' a > GeneratorsView < ' a > {
216+ impl < ' a > BulletproofGensShare < ' a > {
233217 /// Return an iterator over this party's G generators with given size `n`.
234218 pub ( crate ) fn G ( & self , n : usize ) -> impl Iterator < Item = & ' a RistrettoPoint > {
235219 self . gens . G_vec [ self . share ] . iter ( ) . take ( n)
@@ -248,7 +232,7 @@ mod tests {
248232
249233 #[ test]
250234 fn aggregated_gens_iter_matches_flat_map ( ) {
251- let gens = Generators :: new ( PedersenGenerators :: default ( ) , 64 , 8 ) ;
235+ let gens = BulletproofGens :: new ( 64 , 8 ) ;
252236
253237 let helper = |n : usize , m : usize | {
254238 let agg_G: Vec < RistrettoPoint > = gens. G ( n, m) . cloned ( ) . collect ( ) ;
0 commit comments