NCC-CSWZ001-002: adds num exp as input to beacon_constrained and adds input validation

This commit is contained in:
Kobi Gurkan 2020-04-28 18:36:23 +03:00 committed by poma
parent 6bca852b8b
commit 19037214ec
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
2 changed files with 12 additions and 6 deletions

@ -19,8 +19,8 @@ const CHECK_INPUT_CORRECTNESS: CheckForCorrectness = CheckForCorrectness::No;
#[allow(clippy::modulo_one)]
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() != 6 {
println!("Usage: \n<challenge_file> <response_file> <circuit_power> <batch_size> <beacon_hash>");
if args.len() != 7 {
println!("Usage: \n<challenge_file> <response_file> <circuit_power> <batch_size> <beacon_hash> <num_iterations_exp>");
std::process::exit(exitcode::USAGE);
}
let challenge_filename = &args[1];
@ -28,6 +28,12 @@ fn main() {
let circuit_power = args[3].parse().expect("could not parse circuit power");
let batch_size = args[4].parse().expect("could not parse batch size");
let beacon_hash = &args[5];
let num_iterations_exp = &args[6].parse::<usize>().unwrap();
if *num_iterations_exp < 10 || *num_iterations_exp > 63 {
println!("in_num_iterations_exp should be in [10, 63] range");
std::process::exit(exitcode::DATAERR);
}
let parameters = CeremonyParams::<Bn256>::new(circuit_power, batch_size);
@ -51,14 +57,14 @@ fn main() {
let mut cur_hash = hex::decode(beacon_hash).unwrap();
// Performs 2^n hash iterations over it
const N: u64 = 10;
let n: usize = *num_iterations_exp;
for i in 0..(1u64 << N) {
for i in 0..(1u64 << n) {
// Print 1024 of the interstitial states
// so that verification can be
// parallelized
if i % (1u64 << (N - 10)) == 0 {
if i % (1u64 << (n - 10)) == 0 {
print!("{}: ", i);
for b in cur_hash.iter() {
print!("{:02x}", b);

@ -21,7 +21,7 @@ cargo run --release --bin verify_transform_constrained challenge2 response2 chal
yes | cargo run --release --bin compute_constrained challenge3 response3 $SIZE $BATCH
cargo run --release --bin verify_transform_constrained challenge3 response3 challenge4 $SIZE $BATCH
cargo run --release --bin beacon_constrained challenge4 response4 $SIZE $BATCH 0000000000000000000a558a61ddc8ee4e488d647a747fe4dcc362fe2026c620
cargo run --release --bin beacon_constrained challenge4 response4 $SIZE $BATCH 0000000000000000000a558a61ddc8ee4e488d647a747fe4dcc362fe2026c620 10
cargo run --release --bin verify_transform_constrained challenge4 response4 challenge5 $SIZE $BATCH
cargo run --release --bin prepare_phase2 response4 $SIZE $BATCH