Skip to content

Commit bbbc53b

Browse files
olegnnlovesh
authored andcommitted
Tweaks, simplifications
1 parent 7a68563 commit bbbc53b

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

bbs_plus/src/setup.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ macro_rules! impl_sig_params {
257257
let g1 = projective_group_elem_from_try_and_incr::<E::$group_affine, D>(
258258
&concat_slices!(label, b" : g1"),
259259
);
260+
let h_bytes = concat_slices!(label, b" : h_");
260261
// h_0 and h[i] for i in 1 to message_count
261-
let h = n_projective_group_elements::<E::$group_affine, D, _>(
262+
let h = n_projective_group_elements::<E::$group_affine, D>(
262263
1 + message_count,
263-
concat_slices!(label, b" : h_"),
264+
&h_bytes,
264265
);
265266
let g1_and_h: Vec<_> = iter::once(g1).chain(h).collect();
266267

@@ -522,9 +523,9 @@ impl<E: Pairing> SignatureParams23G1<E> {
522523
affine_group_element_from_byte_slices!(label, b" : g1"),
523524
affine_group_element_from_byte_slices!(label, b" : g2"),
524525
{
525-
let h: Vec<_> = n_projective_group_elements::<E::G1Affine, D, _>(
526+
let h: Vec<_> = n_projective_group_elements::<E::G1Affine, D>(
526527
message_count,
527-
concat_slices!(label, b" : h_"),
528+
&concat_slices!(label, b" : h_"),
528529
)
529530
.collect();
530531

coconut/src/setup/keypair/secret.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ark_serialize::*;
88
use ark_std::rand::RngCore;
99
use serde::{Deserialize, Serialize};
1010
use serde_with::serde_as;
11-
use utils::{misc::n_bytes_iter, serde_utils::ArkObjectBytes};
11+
use utils::{misc::le_bytes_iter, serde_utils::ArkObjectBytes};
1212
use zeroize::{Zeroize, ZeroizeOnDrop};
1313

1414
#[cfg(feature = "parallel")]
@@ -65,7 +65,7 @@ impl<F: PrimeField> SecretKey<F> {
6565
{
6666
let hasher = new_hasher(Self::Y_SALT);
6767

68-
n_bytes_iter(message_count)
68+
le_bytes_iter(message_count)
6969
.map(|ctr| concat_slices!(seed, ctr))
7070
.map(|seed| hasher.hash_to_field(&seed, 1).pop().unwrap())
7171
.collect()

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>(message_count, &concat_slices!(label, b" : h_"))
4242
.collect()
4343
);
4444

delegatable_credentials/src/set_commitment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::{
2929
util::{generator_pair, generator_pair_deterministic},
3030
};
3131
use dock_crypto_utils::{
32-
ff::powers, hashing_utils::field_elem_from_try_and_incr, misc::n_bytes_iter, msm::WindowTable,
32+
ff::powers, hashing_utils::field_elem_from_try_and_incr, misc::le_bytes_iter, msm::WindowTable,
3333
poly::poly_from_roots, serde_utils::*,
3434
};
3535

@@ -596,7 +596,7 @@ impl<E: Pairing> AggregateSubsetWitness<E> {
596596
commitments: &[SetCommitment<E>],
597597
subsets: &[BTreeSet<E::ScalarField>],
598598
) -> Vec<E::ScalarField> {
599-
n_bytes_iter(n)
599+
le_bytes_iter(n)
600600
.zip(commitments)
601601
.zip(subsets)
602602
.map(|((ctr_bytes, c), s)| {

utils/src/misc.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::ops::Range;
22

33
use crate::{
4-
aliases::{DoubleEndedExactSizeIterator, SendIfParallel, SyncIfParallel},
4+
aliases::{DoubleEndedExactSizeIterator, SendIfParallel},
55
concat_slices,
66
hashing_utils::projective_group_elem_from_try_and_incr,
77
impl_indexed_iter,
@@ -75,33 +75,34 @@ where
7575
}
7676

7777
/// Produces an iterator emitting `n` items `u32::to_le_bytes` of the counter starting from zero.
78-
pub fn n_bytes_iter(n: u32) -> impl_indexed_iter!(<Item = [u8; 4]>) {
78+
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

8282
/// Produces `n` projective group elements by combining the supplied bytes with the `u32::to_le_bytes` counter bytes.
83-
pub fn n_projective_group_elements<G, D, B>(
83+
pub fn n_projective_group_elements<'iter, G, D>(
8484
n: u32,
85-
bytes: B,
86-
) -> impl_indexed_iter!(<Item = G::Group>)
85+
bytes: &'iter [u8],
86+
) -> impl_indexed_iter!(<Item = G::Group> + 'iter)
8787
where
8888
G: AffineRepr + SendIfParallel,
8989
D: Digest,
90-
B: AsRef<[u8]> + SendIfParallel + SyncIfParallel,
9190
{
92-
n_bytes_iter(n).map(move |ctr_bytes| -> G::Group {
91+
le_bytes_iter(n).map(move |ctr_bytes| -> G::Group {
9392
projective_group_elem_from_try_and_incr::<G, D>(&concat_slices!(bytes.as_ref(), ctr_bytes))
9493
})
9594
}
9695

9796
/// Produces `n` affine group elements by combining the supplied bytes with the `u32::to_le_bytes` counter bytes.
98-
pub fn n_affine_group_elements<G, D, B>(n: u32, bytes: B) -> impl_indexed_iter!(<Item = G>)
97+
pub fn n_affine_group_elements<'iter, G, D>(
98+
n: u32,
99+
bytes: &'iter [u8],
100+
) -> impl_indexed_iter!(<Item = G> + 'iter)
99101
where
100102
G: AffineRepr + SendIfParallel,
101103
D: Digest,
102-
B: AsRef<[u8]> + SendIfParallel + SyncIfParallel,
103104
{
104-
n_projective_group_elements::<G, D, B>(n, bytes).map(CurveGroup::into_affine)
105+
n_projective_group_elements::<G, D>(n, bytes).map(CurveGroup::into_affine)
105106
}
106107

107108
/// Generates a random using given `rng`.

0 commit comments

Comments
 (0)