Accept filenames as command line arguments
This commit is contained in:
parent
a49ebce8f1
commit
e8b14ddb00
7
powersoftau/Cargo.lock
generated
7
powersoftau/Cargo.lock
generated
@ -147,6 +147,11 @@ name = "either"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "exitcode"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ff_ce"
|
||||
version = "0.7.1"
|
||||
@ -310,6 +315,7 @@ dependencies = [
|
||||
"blake2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"exitcode 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -490,6 +496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum crypto-mac 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "779015233ac67d65098614aec748ac1c756ab6677fa2e14cf8b37c08dfed1198"
|
||||
"checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a"
|
||||
"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac"
|
||||
"checksum exitcode 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
|
||||
"checksum ff_ce 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "18af1ea1b80a4b474fae13af4c58cf0a5a2bc33832d5fa70f68a4b286178fdb5"
|
||||
"checksum ff_derive_ce 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d245b4e76c5b36bb7721ea15b7fbc61bebf0c5d2890eaf49fe1e2a3eed36db9"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
@ -20,6 +20,7 @@ typenum = "1.9.0"
|
||||
byteorder = "1.1.0"
|
||||
hex-literal = "0.1"
|
||||
rust-crypto = "0.2"
|
||||
exitcode = "1.1.2"
|
||||
|
||||
memmap = "0.7.0"
|
||||
itertools = "0.8.0"
|
||||
|
@ -28,6 +28,14 @@ const CHECK_INPUT_CORRECTNESS: CheckForCorrectness = CheckForCorrectness::No;
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 3 {
|
||||
println!("Usage: \n<challenge_file> <response_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let challenge_filename = &args[1];
|
||||
let response_filename = &args[2];
|
||||
|
||||
println!("Will contribute a random beacon to accumulator for 2^{} powers of tau", Bn256CeremonyParameters::REQUIRED_POWER);
|
||||
println!("In total will generate up to {} powers", Bn256CeremonyParameters::TAU_POWERS_G1_LENGTH);
|
||||
|
||||
@ -81,13 +89,14 @@ fn main() {
|
||||
|
||||
println!("Done creating a beacon RNG");
|
||||
|
||||
// Try to load `./challenge` from disk.
|
||||
// Try to load challenge file from disk.
|
||||
let reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("challenge").expect("unable open `./challenge` in this directory");
|
||||
.open(challenge_filename)
|
||||
.expect("unable open challenge file in this directory");
|
||||
|
||||
{
|
||||
let metadata = reader.metadata().expect("unable to get filesystem metadata for `./challenge`");
|
||||
let metadata = reader.metadata().expect("unable to get filesystem metadata for challenge file");
|
||||
let expected_challenge_length = match INPUT_IS_COMPRESSED {
|
||||
UseCompression::Yes => {
|
||||
Bn256CeremonyParameters::CONTRIBUTION_BYTE_SIZE
|
||||
@ -98,18 +107,19 @@ fn main() {
|
||||
};
|
||||
|
||||
if metadata.len() != (expected_challenge_length as u64) {
|
||||
panic!("The size of `./challenge` should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
panic!("The size of challenge file should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
}
|
||||
}
|
||||
|
||||
let readable_map = unsafe { MmapOptions::new().map(&reader).expect("unable to create a memory map for input") };
|
||||
|
||||
// Create `./response` in this directory
|
||||
// Create response file in this directory
|
||||
let writer = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open("response").expect("unable to create `./response` in this directory");
|
||||
.open(response_filename)
|
||||
.expect("unable to create response file in this directory");
|
||||
|
||||
let required_output_length = match COMPRESS_THE_OUTPUT {
|
||||
UseCompression::Yes => {
|
||||
@ -143,7 +153,7 @@ fn main() {
|
||||
|
||||
(&mut writable_map[0..]).write(current_accumulator_hash.as_slice()).expect("unable to write a challenge hash to mmap");
|
||||
|
||||
writable_map.flush().expect("unable to write hash to `./response`");
|
||||
writable_map.flush().expect("unable to write hash to response file");
|
||||
}
|
||||
|
||||
// Construct our keypair using the RNG we created above
|
||||
@ -161,7 +171,7 @@ fn main() {
|
||||
CHECK_INPUT_CORRECTNESS,
|
||||
&privkey
|
||||
).expect("must transform with the key");
|
||||
println!("Finihsing writing your contribution to `./response`...");
|
||||
println!("Finishing writing your contribution to response file...");
|
||||
|
||||
// Write the public key
|
||||
pubkey.write::<Bn256CeremonyParameters>(&mut writable_map, COMPRESS_THE_OUTPUT).expect("unable to write public key");
|
||||
@ -171,8 +181,8 @@ fn main() {
|
||||
let contribution_hash = BachedAccumulator::<Bn256, Bn256CeremonyParameters>::calculate_hash(&output_readonly);
|
||||
|
||||
print!("Done!\n\n\
|
||||
Your contribution has been written to `./response`\n\n\
|
||||
The BLAKE2b hash of `./response` is:\n");
|
||||
Your contribution has been written to response file\n\n\
|
||||
The BLAKE2b hash of response file is:\n");
|
||||
|
||||
for line in contribution_hash.as_slice().chunks(16) {
|
||||
print!("\t");
|
||||
|
@ -4,6 +4,7 @@ extern crate memmap;
|
||||
extern crate rand;
|
||||
extern crate blake2;
|
||||
extern crate byteorder;
|
||||
extern crate exitcode;
|
||||
|
||||
use powersoftau::bn256::{Bn256CeremonyParameters};
|
||||
use powersoftau::batched_accumulator::{BachedAccumulator};
|
||||
@ -23,6 +24,14 @@ const COMPRESS_THE_OUTPUT: UseCompression = UseCompression::Yes;
|
||||
const CHECK_INPUT_CORRECTNESS: CheckForCorrectness = CheckForCorrectness::No;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 3 {
|
||||
println!("Usage: \n<challenge_file> <response_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let challenge_filename = &args[1];
|
||||
let response_filename = &args[2];
|
||||
|
||||
println!("Will contribute to accumulator for 2^{} powers of tau", Bn256CeremonyParameters::REQUIRED_POWER);
|
||||
println!("In total will generate up to {} powers", Bn256CeremonyParameters::TAU_POWERS_G1_LENGTH);
|
||||
|
||||
@ -64,13 +73,13 @@ fn main() {
|
||||
ChaChaRng::from_seed(&seed)
|
||||
};
|
||||
|
||||
// Try to load `./challenge` from disk.
|
||||
// Try to load challenge file from disk.
|
||||
let reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("challenge").expect("unable open `./challenge` in this directory");
|
||||
|
||||
.open(challenge_filename)
|
||||
.expect("unable open challenge file");
|
||||
{
|
||||
let metadata = reader.metadata().expect("unable to get filesystem metadata for `./challenge`");
|
||||
let metadata = reader.metadata().expect("unable to get filesystem metadata for challenge file");
|
||||
let expected_challenge_length = match INPUT_IS_COMPRESSED {
|
||||
UseCompression::Yes => {
|
||||
Bn256CeremonyParameters::CONTRIBUTION_BYTE_SIZE
|
||||
@ -81,18 +90,19 @@ fn main() {
|
||||
};
|
||||
|
||||
if metadata.len() != (expected_challenge_length as u64) {
|
||||
panic!("The size of `./challenge` should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
panic!("The size of challenge file should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
}
|
||||
}
|
||||
|
||||
let readable_map = unsafe { MmapOptions::new().map(&reader).expect("unable to create a memory map for input") };
|
||||
|
||||
// Create `./response` in this directory
|
||||
// Create response file in this directory
|
||||
let writer = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open("response").expect("unable to create `./response` in this directory");
|
||||
.open(response_filename)
|
||||
.expect("unable to create response file");
|
||||
|
||||
let required_output_length = match COMPRESS_THE_OUTPUT {
|
||||
UseCompression::Yes => {
|
||||
@ -127,7 +137,7 @@ fn main() {
|
||||
|
||||
(&mut writable_map[0..]).write(current_accumulator_hash.as_slice()).expect("unable to write a challenge hash to mmap");
|
||||
|
||||
writable_map.flush().expect("unable to write hash to `./response`");
|
||||
writable_map.flush().expect("unable to write hash to response file");
|
||||
}
|
||||
|
||||
{
|
||||
@ -164,7 +174,7 @@ fn main() {
|
||||
&privkey
|
||||
).expect("must transform with the key");
|
||||
|
||||
println!("Finihsing writing your contribution to `./response`...");
|
||||
println!("Finishing writing your contribution to response file...");
|
||||
|
||||
// Write the public key
|
||||
pubkey.write::<Bn256CeremonyParameters>(&mut writable_map, COMPRESS_THE_OUTPUT).expect("unable to write public key");
|
||||
@ -176,8 +186,8 @@ fn main() {
|
||||
let contribution_hash = BachedAccumulator::<Bn256, Bn256CeremonyParameters>::calculate_hash(&output_readonly);
|
||||
|
||||
print!("Done!\n\n\
|
||||
Your contribution has been written to `./response`\n\n\
|
||||
The BLAKE2b hash of `./response` is:\n");
|
||||
Your contribution has been written to response file\n\n\
|
||||
The BLAKE2b hash of response file is:\n");
|
||||
|
||||
for line in contribution_hash.as_slice().chunks(16) {
|
||||
print!("\t");
|
||||
|
@ -11,23 +11,31 @@ use std::io::{Write, BufWriter};
|
||||
use bellman_ce::pairing::bn256::Bn256;
|
||||
|
||||
fn main() {
|
||||
let writer = OpenOptions::new()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open("challenge").expect("unable to create `./challenge`");
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: \n<challenge_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let challenge_filename = &args[1];
|
||||
|
||||
let mut writer = BufWriter::new(writer);
|
||||
let file = OpenOptions::new()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(challenge_filename)
|
||||
.expect("unable to create challenge file");
|
||||
|
||||
let mut writer = BufWriter::new(file);
|
||||
|
||||
// Write a blank BLAKE2b hash:
|
||||
writer.write_all(&blank_hash().as_slice()).expect("unable to write blank hash to `./challenge`");
|
||||
writer.write_all(&blank_hash().as_slice()).expect("unable to write blank hash to challenge file");
|
||||
|
||||
let parameters = Bn256CeremonyParameters{};
|
||||
|
||||
let acc: Accumulator<Bn256, _> = Accumulator::new(parameters);
|
||||
println!("Writing an empty accumulator to disk");
|
||||
acc.serialize(&mut writer, UseCompression::No).expect("unable to write fresh accumulator to `./challenge`");
|
||||
acc.serialize(&mut writer, UseCompression::No).expect("unable to write fresh accumulator to challenge file");
|
||||
writer.flush().expect("unable to flush accumulator to disk");
|
||||
|
||||
println!("Wrote a fresh accumulator to `./challenge`");
|
||||
println!("Wrote a fresh accumulator to challenge file");
|
||||
}
|
||||
|
@ -17,14 +17,22 @@ use powersoftau::parameters::PowersOfTauParameters;
|
||||
const COMPRESS_NEW_CHALLENGE: UseCompression = UseCompression::No;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: \n<challenge_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let challenge_filename = &args[1];
|
||||
|
||||
println!("Will generate an empty accumulator for 2^{} powers of tau", Bn256CeremonyParameters::REQUIRED_POWER);
|
||||
println!("In total will generate up to {} powers", Bn256CeremonyParameters::TAU_POWERS_G1_LENGTH);
|
||||
|
||||
|
||||
let file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open("challenge").expect("unable to create `./challenge`");
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(challenge_filename)
|
||||
.expect("unable to create challenge file");
|
||||
|
||||
let expected_challenge_length = match COMPRESS_NEW_CHALLENGE {
|
||||
UseCompression::Yes => {
|
||||
@ -42,7 +50,7 @@ fn main() {
|
||||
// Write a blank BLAKE2b hash:
|
||||
let hash = blank_hash();
|
||||
(&mut writable_map[0..]).write(hash.as_slice()).expect("unable to write a default hash to mmap");
|
||||
writable_map.flush().expect("unable to write blank hash to `./challenge`");
|
||||
writable_map.flush().expect("unable to write blank hash to challenge file");
|
||||
|
||||
println!("Blank hash for an empty challenge:");
|
||||
for line in hash.as_slice().chunks(16) {
|
||||
@ -76,5 +84,5 @@ fn main() {
|
||||
println!("");
|
||||
}
|
||||
|
||||
println!("Wrote a fresh accumulator to `./challenge`");
|
||||
println!("Wrote a fresh accumulator to challenge file");
|
||||
}
|
||||
|
@ -29,11 +29,18 @@ fn log_2(x: u64) -> u32 {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Try to load `./response` from disk.
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: \n<response_filename>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let response_filename = &args[1];
|
||||
|
||||
// Try to load response file from disk.
|
||||
let reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("response")
|
||||
.expect("unable open `./response` in this directory");
|
||||
.open(response_filename)
|
||||
.expect("unable open response file in this directory");
|
||||
let response_readable_map = unsafe { MmapOptions::new().map(&reader).expect("unable to create a memory map for input") };
|
||||
|
||||
let current_accumulator = BachedAccumulator::<Bn256, Bn256CeremonyParameters>::deserialize(
|
||||
|
@ -61,7 +61,7 @@ fn get_challenge_file_hash(
|
||||
let mut writable_map = unsafe { MmapOptions::new().map_mut(&writer).expect("unable to create a memory map for output") };
|
||||
|
||||
(&mut writable_map[0..]).write(&last_response_file_hash[..]).expect("unable to write a default hash to mmap");
|
||||
writable_map.flush().expect("unable to write blank hash to `./challenge`");
|
||||
writable_map.flush().expect("unable to write blank hash to challenge file");
|
||||
|
||||
if is_initial {
|
||||
BachedAccumulator::<Bn256, Bn256CeremonyParameters>::generate_initial(&mut writable_map, UseCompression::No).expect("generation of initial accumulator is successful");
|
||||
@ -119,7 +119,7 @@ fn get_response_file_hash(
|
||||
let mut writable_map = unsafe { MmapOptions::new().map_mut(&writer).expect("unable to create a memory map for output") };
|
||||
|
||||
(&mut writable_map[0..]).write(&last_challenge_file_hash[..]).expect("unable to write a default hash to mmap");
|
||||
writable_map.flush().expect("unable to write blank hash to `./challenge`");
|
||||
writable_map.flush().expect("unable to write blank hash to challenge file");
|
||||
|
||||
acc.serialize(
|
||||
&mut writable_map,
|
||||
@ -158,7 +158,8 @@ fn new_accumulator_for_verify() -> BachedAccumulator<Bn256, Bn256CeremonyParamet
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(file_name).expect("unable to create `./tmp_initial_challenge`");
|
||||
.open(file_name)
|
||||
.expect("unable to create `./tmp_initial_challenge`");
|
||||
|
||||
let expected_challenge_length = Bn256CeremonyParameters::ACCUMULATOR_BYTE_SIZE;
|
||||
file.set_len(expected_challenge_length as u64).expect("unable to allocate large enough file");
|
||||
@ -171,7 +172,8 @@ fn new_accumulator_for_verify() -> BachedAccumulator<Bn256, Bn256CeremonyParamet
|
||||
let reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open(file_name)
|
||||
.expect("unable open `./transcript` in this directory");
|
||||
.expect("unable open transcript file in this directory");
|
||||
|
||||
let readable_map = unsafe { MmapOptions::new().map(&reader).expect("unable to create a memory map for input") };
|
||||
let initial_accumulator = BachedAccumulator::deserialize(
|
||||
&readable_map,
|
||||
@ -183,11 +185,19 @@ fn new_accumulator_for_verify() -> BachedAccumulator<Bn256, Bn256CeremonyParamet
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Try to load `./transcript` from disk.
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: \n<transcript_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let transcript_filename = &args[1];
|
||||
|
||||
// Try to load transcript file from disk.
|
||||
let reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("transcript")
|
||||
.expect("unable open `./transcript` in this directory");
|
||||
.open(transcript_filename)
|
||||
.expect("unable open transcript file in this directory");
|
||||
|
||||
let transcript_readable_map = unsafe { MmapOptions::new().map(&reader).expect("unable to create a memory map for input") };
|
||||
|
||||
// Initialize the accumulator
|
||||
|
@ -23,15 +23,25 @@ const CONTRIBUTION_IS_COMPRESSED: UseCompression = UseCompression::Yes;
|
||||
const COMPRESS_NEW_CHALLENGE: UseCompression = UseCompression::No;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 4 {
|
||||
println!("Usage: \n<challenge_file> <response_file> <new_challenge_file>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let challenge_filename = &args[1];
|
||||
let response_filename = &args[2];
|
||||
let new_challenge_filename = &args[3];
|
||||
|
||||
println!("Will verify and decompress a contribution to accumulator for 2^{} powers of tau", Bn256CeremonyParameters::REQUIRED_POWER);
|
||||
|
||||
// Try to load `./challenge` from disk.
|
||||
// Try to load challenge file from disk.
|
||||
let challenge_reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("challenge").expect("unable open `./challenge` in this directory");
|
||||
.open(challenge_filename)
|
||||
.expect("unable open challenge file in this directory");
|
||||
|
||||
{
|
||||
let metadata = challenge_reader.metadata().expect("unable to get filesystem metadata for `./challenge`");
|
||||
let metadata = challenge_reader.metadata().expect("unable to get filesystem metadata for challenge file");
|
||||
let expected_challenge_length = match PREVIOUS_CHALLENGE_IS_COMPRESSED {
|
||||
UseCompression::Yes => {
|
||||
Bn256CeremonyParameters::CONTRIBUTION_BYTE_SIZE - Bn256CeremonyParameters::PUBLIC_KEY_SIZE
|
||||
@ -41,19 +51,20 @@ fn main() {
|
||||
}
|
||||
};
|
||||
if metadata.len() != (expected_challenge_length as u64) {
|
||||
panic!("The size of `./challenge` should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
panic!("The size of challenge file should be {}, but it's {}, so something isn't right.", expected_challenge_length, metadata.len());
|
||||
}
|
||||
}
|
||||
|
||||
let challenge_readable_map = unsafe { MmapOptions::new().map(&challenge_reader).expect("unable to create a memory map for input") };
|
||||
|
||||
// Try to load `./response` from disk.
|
||||
// Try to load response file from disk.
|
||||
let response_reader = OpenOptions::new()
|
||||
.read(true)
|
||||
.open("response").expect("unable open `./response` in this directory");
|
||||
.open(response_filename)
|
||||
.expect("unable open response file in this directory");
|
||||
|
||||
{
|
||||
let metadata = response_reader.metadata().expect("unable to get filesystem metadata for `./response`");
|
||||
let metadata = response_reader.metadata().expect("unable to get filesystem metadata for response file");
|
||||
let expected_response_length = match CONTRIBUTION_IS_COMPRESSED {
|
||||
UseCompression::Yes => {
|
||||
Bn256CeremonyParameters::CONTRIBUTION_BYTE_SIZE
|
||||
@ -63,7 +74,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
if metadata.len() != (expected_response_length as u64) {
|
||||
panic!("The size of `./response` should be {}, but it's {}, so something isn't right.", expected_response_length, metadata.len());
|
||||
panic!("The size of response file should be {}, but it's {}, so something isn't right.", expected_response_length, metadata.len());
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +123,7 @@ fn main() {
|
||||
|
||||
let response_hash = BachedAccumulator::<Bn256, Bn256CeremonyParameters>::calculate_hash(&response_readable_map);
|
||||
|
||||
println!("Hash of the `response` file for verification:");
|
||||
println!("Hash of the response file for verification:");
|
||||
for line in response_hash.as_slice().chunks(16) {
|
||||
print!("\t");
|
||||
for section in line.chunks(4) {
|
||||
@ -152,20 +163,21 @@ fn main() {
|
||||
}
|
||||
|
||||
if COMPRESS_NEW_CHALLENGE == UseCompression::Yes {
|
||||
println!("Don't need to recompress the contribution, please copy `./response` as `./new_challenge`");
|
||||
println!("Don't need to recompress the contribution, please copy response file as new challenge");
|
||||
} else {
|
||||
println!("Verification succeeded! Writing to `./new_challenge`...");
|
||||
println!("Verification succeeded! Writing to new challenge file...");
|
||||
|
||||
// Create `./new_challenge` in this directory
|
||||
// Create new challenge file in this directory
|
||||
let writer = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open("new_challenge").expect("unable to create `./new_challenge` in this directory");
|
||||
.open(new_challenge_filename)
|
||||
.expect("unable to create new challenge file in this directory");
|
||||
|
||||
|
||||
|
||||
// Recomputation stips the public key and uses hashing to link with the previous contibution after decompression
|
||||
// Recomputation strips the public key and uses hashing to link with the previous contribution after decompression
|
||||
writer.set_len(Bn256CeremonyParameters::ACCUMULATOR_BYTE_SIZE as u64).expect("must make output file large enough");
|
||||
|
||||
let mut writable_map = unsafe { MmapOptions::new().map_mut(&writer).expect("unable to create a memory map for output") };
|
||||
@ -173,7 +185,7 @@ fn main() {
|
||||
{
|
||||
(&mut writable_map[0..]).write(response_hash.as_slice()).expect("unable to write a default hash to mmap");
|
||||
|
||||
writable_map.flush().expect("unable to write hash to `./new_challenge`");
|
||||
writable_map.flush().expect("unable to write hash to new challenge file");
|
||||
}
|
||||
|
||||
BachedAccumulator::<Bn256, Bn256CeremonyParameters>::decompress(
|
||||
@ -187,7 +199,7 @@ fn main() {
|
||||
|
||||
let recompressed_hash = BachedAccumulator::<Bn256, Bn256CeremonyParameters>::calculate_hash(&new_challenge_readable_map);
|
||||
|
||||
println!("Here's the BLAKE2b hash of the decompressed participant's response as `new_challenge` file:");
|
||||
println!("Here's the BLAKE2b hash of the decompressed participant's response as new_challenge file:");
|
||||
|
||||
for line in recompressed_hash.as_slice().chunks(16) {
|
||||
print!("\t");
|
||||
@ -200,7 +212,7 @@ fn main() {
|
||||
println!("");
|
||||
}
|
||||
|
||||
println!("Done! `./new_challenge` contains the new challenge file. The other files");
|
||||
println!("Done! new challenge file contains the new challenge file. The other files");
|
||||
println!("were left alone.");
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm challenge
|
||||
rm response
|
||||
rm new_challenge
|
||||
rm challenge_old
|
||||
rm response_old
|
||||
rm challenge*
|
||||
rm response*
|
||||
rm transcript
|
||||
rm phase1radix*
|
||||
rm tmp_*
|
||||
|
||||
cargo run --release --bin new_constrained
|
||||
cargo run --release --bin compute_constrained
|
||||
cargo run --release --bin verify_transform_constrained
|
||||
set -e
|
||||
|
||||
mv challenge challenge_old
|
||||
mv response response_old
|
||||
cargo run --release --bin new_constrained challenge1
|
||||
cargo run --release --bin compute_constrained challenge1 response1
|
||||
cargo run --release --bin verify_transform_constrained challenge1 response1 challenge2
|
||||
|
||||
mv new_challenge challenge
|
||||
cargo run --release --bin beacon_constrained
|
||||
cargo run --release --bin verify_transform_constrained
|
||||
cargo run --release --bin beacon_constrained challenge2 response2
|
||||
cargo run --release --bin verify_transform_constrained challenge2 response2 challenge3
|
||||
|
||||
cat response_old response > transcript
|
||||
cargo run --release --bin verify
|
||||
cargo run --release --bin beacon_constrained challenge3 response3
|
||||
cargo run --release --bin verify_transform_constrained challenge3 response3 challenge4
|
||||
|
||||
cargo run --release --bin beacon_constrained challenge4 response4
|
||||
cargo run --release --bin verify_transform_constrained challenge4 response4 challenge5
|
||||
|
||||
cat response1 response2 response3 response4 > transcript
|
||||
cargo run --release --bin verify transcript
|
Loading…
Reference in New Issue
Block a user