Add new tool to repository for initializing the first challenge file.

This commit is contained in:
Sean Bowe 2017-11-08 21:09:43 -07:00
parent 83583caa92
commit 60297403e6
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031

24
src/bin/new.rs Normal file

@ -0,0 +1,24 @@
extern crate powersoftau;
use powersoftau::*;
use std::fs::OpenOptions;
use std::io::{Write, BufWriter};
fn main() {
let writer = OpenOptions::new()
.read(false)
.write(true)
.create_new(true)
.open("challenge").expect("unable to create `./challenge`");
let mut writer = BufWriter::new(writer);
// Write a blank BLAKE2b hash:
writer.write_all(&blank_hash().as_slice()).expect("unable to write blank hash to `./challenge`");
let acc = Accumulator::new();
acc.serialize(&mut writer, UseCompression::No).expect("unable to write fresh accumulator to `./challenge`");
writer.flush().expect("unable to flush accumulator to disk");
println!("Wrote a fresh accumulator to `./challenge`");
}