Skip to content

Commit f00a481

Browse files
committed
Change point generator to accept range and properly fix issue from previous commit
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent de8eb14 commit f00a481

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

bbs_plus/src/setup.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ macro_rules! impl_sig_params {
258258
&concat_slices!(label, b" : g1"),
259259
);
260260
let h_bytes = concat_slices!(label, b" : h_");
261-
// h_0 and h[i] for i in 1 to message_count
261+
// h_i for i in 0 to message_count
262262
let h = n_projective_group_elements::<E::$group_affine, D>(
263-
1 + message_count,
263+
0..message_count + 1,
264264
&h_bytes,
265265
);
266266
let g1_and_h: Vec<_> = iter::once(g1).chain(h).collect();
@@ -523,13 +523,11 @@ impl<E: Pairing> SignatureParams23G1<E> {
523523
affine_group_element_from_byte_slices!(label, b" : g1"),
524524
affine_group_element_from_byte_slices!(label, b" : g2"),
525525
{
526-
let mut h: Vec<_> = n_projective_group_elements::<E::G1Affine, D>(
527-
1 + message_count,
526+
let h: Vec<_> = n_projective_group_elements::<E::G1Affine, D>(
527+
1..message_count + 1,
528528
&concat_slices!(label, b" : h_"),
529529
)
530530
.collect();
531-
// TODO: Fix me by making above point generator accept a range
532-
h.remove(0);
533531
E::G1::normalize_batch(&h)
534532
}
535533
);

coconut/src/setup/signature_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<E: Pairing> SignatureParams<E> {
3838
let (g, g_tilde, h) = join!(
3939
affine_group_element_from_byte_slices!(label, b" : g"),
4040
affine_group_element_from_byte_slices!(label, b" : g_tilde"),
41-
n_affine_group_elements::<_, D>(message_count, &concat_slices!(label, b" : h_"))
41+
n_affine_group_elements::<_, D>(0..message_count, &concat_slices!(label, b" : h_"))
4242
.collect()
4343
);
4444

utils/src/misc.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,30 @@ pub fn le_bytes_iter(n: u32) -> impl_indexed_iter!(<Item = [u8; 4]>) {
7979
cfg_into_iter!(0..n).map(u32::to_le_bytes)
8080
}
8181

82-
/// Produces `n` projective group elements by combining the supplied bytes with the `u32::to_le_bytes` counter bytes.
82+
/// Produces an iterator of little endian bytes of each element contained in the range `counter_range`
83+
pub fn le_bytes_iter_from_given_range(
84+
counter_range: Range<u32>,
85+
) -> impl_indexed_iter!(<Item = [u8; 4]>) {
86+
cfg_into_iter!(counter_range).map(u32::to_le_bytes)
87+
}
88+
89+
/// Produces an iterator of projective group elements created by hashing a label and a counter in the range `counter_range`
8390
pub fn n_projective_group_elements<'iter, G, D>(
84-
n: u32,
91+
counter_range: Range<u32>,
8592
bytes: &'iter [u8],
8693
) -> impl_indexed_iter!(<Item = G::Group> + 'iter)
8794
where
8895
G: AffineRepr + SendIfParallel,
8996
D: Digest,
9097
{
91-
le_bytes_iter(n).map(move |ctr_bytes| -> G::Group {
98+
le_bytes_iter_from_given_range(counter_range).map(move |ctr_bytes| -> G::Group {
9299
projective_group_elem_from_try_and_incr::<G, D>(&concat_slices!(bytes.as_ref(), ctr_bytes))
93100
})
94101
}
95102

96-
/// Produces `n` affine group elements by combining the supplied bytes with the `u32::to_le_bytes` counter bytes.
103+
/// Produces an iterator affine group elements created by hashing a label and a counter in the range `counter_range`
97104
pub fn n_affine_group_elements<'iter, G, D>(
98-
n: u32,
105+
n: Range<u32>,
99106
bytes: &'iter [u8],
100107
) -> impl_indexed_iter!(<Item = G> + 'iter)
101108
where

0 commit comments

Comments
 (0)