Skip to content

Commit ca11f80

Browse files
committed
Generate G and H points per-party instead of from a single seed.
The domain separation label for the G and H vectors is the 5-byte string whose first byte is 'G' or 'H' and whose remaining 4 bytes are the little-endian encodings of the party's index.
1 parent 53d7643 commit ca11f80

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/generators.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,26 @@ impl Default for PedersenGenerators {
115115
impl Generators {
116116
/// Creates generators for `m` range proofs of `n` bits each.
117117
pub fn new(pedersen_gens: PedersenGenerators, n: usize, m: usize) -> Self {
118-
let G = GeneratorsChain::new(pedersen_gens.B.compress().as_bytes())
119-
.take(n * m)
118+
use byteorder::{ByteOrder, LittleEndian};
119+
120+
let G = (0..m)
121+
.flat_map(|i| {
122+
let party_index = i as u32;
123+
let mut label = [b'G', 0, 0, 0, 0];
124+
LittleEndian::write_u32(&mut label[1..5], party_index);
125+
126+
GeneratorsChain::new(&label).take(n)
127+
})
120128
.collect();
121-
let H = GeneratorsChain::new(pedersen_gens.B_blinding.compress().as_bytes())
122-
.take(n * m)
129+
130+
let H = (0..m)
131+
.flat_map(|i| {
132+
let party_index = i as u32;
133+
let mut label = [b'H', 0, 0, 0, 0];
134+
LittleEndian::write_u32(&mut label[1..5], party_index);
135+
136+
GeneratorsChain::new(&label).take(n)
137+
})
123138
.collect();
124139

125140
Generators {

0 commit comments

Comments
 (0)