get_info tool

This commit is contained in:
poma 2020-05-12 07:04:19 +03:00
parent 9420c72716
commit 5b3c3151a7
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
2 changed files with 43 additions and 3 deletions

@ -0,0 +1,40 @@
extern crate phase2;
extern crate exitcode;
use std::io;
use std::fs::OpenOptions;
use phase2::parameters::MPCParameters;
use phase2::keypair::PublicKey;
use phase2::hash_writer::HashWriter;
fn get_hash(pubkey: &PublicKey) -> [u8; 64] {
// Calculate the hash of the public key and return it
let sink = io::sink();
let mut sink = HashWriter::new(sink);
pubkey.write(&mut sink).unwrap();
let h = sink.into_hash();
let mut response = [0u8; 64];
response.copy_from_slice(h.as_ref());
response
}
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() != 2 {
println!("Usage: \n<params>");
std::process::exit(exitcode::USAGE);
}
let params_filename = &args[1];
let disallow_points_at_infinity = false;
let reader = OpenOptions::new()
.read(true)
.open(params_filename)
.expect("unable to open.");
let params = MPCParameters::read(reader, disallow_points_at_infinity, true).expect("unable to read params");
println!("CS hash: 0x{}", hex::encode(params.cs_hash.to_vec()));
for i in 0..params.contributions.len() {
println!("Contribution {} hash: 0x{}", i + 1, hex::encode(get_hash(&params.contributions[i]).to_vec()));
}
}

@ -79,9 +79,9 @@ use super::utils::*;
/// they contain a transcript of contributions at the end, which can be verified.
#[derive(Clone)]
pub struct MPCParameters {
params: Parameters<Bn256>,
cs_hash: [u8; 64],
contributions: Vec<PublicKey>
pub params: Parameters<Bn256>,
pub cs_hash: [u8; 64],
pub contributions: Vec<PublicKey>
}
impl PartialEq for MPCParameters {