-
Notifications
You must be signed in to change notification settings - Fork 21
/
util.rs
36 lines (29 loc) · 1.02 KB
/
util.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Supranational LLC
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
use ark_ec::{AffineCurve, ProjectiveCurve};
use ark_std::UniformRand;
pub fn generate_points_scalars<G: AffineCurve>(
len: usize,
batch_size: usize
) -> (Vec<G>, Vec<G::ScalarField>) {
let rand_gen: usize = 1 << 15;
let mut rng = ChaCha20Rng::from_entropy();
let mut points =
<G::Projective as ProjectiveCurve>::batch_normalization_into_affine(
&(0..rand_gen)
.map(|_| G::Projective::rand(&mut rng))
.collect::<Vec<_>>(),
);
// Sprinkle in some infinity points
// points[3] = G::zero();
while points.len() < len {
points.append(&mut points.clone());
}
let scalars = (0..len * batch_size)
.map(|_| G::ScalarField::rand(&mut rng))
.collect::<Vec<_>>();
(points, scalars)
}