-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix not commited trusted setup utils
- Loading branch information
Showing
4 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ bin/ | |
pkg/ | ||
wasm-pack.log | ||
.vscode | ||
!zwaves_setup/src/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use bellman::{Circuit, ConstraintSystem, SynthesisError}; | ||
use sapling_crypto::jubjub::{JubjubEngine, JubjubParams, JubjubBls12}; | ||
use pairing::bls12_381::{Bls12, Fr}; | ||
use rand::os::OsRng; | ||
use rand::Rng; | ||
|
||
use std::fs::File; | ||
use std::io::{Write, Read}; | ||
use zwaves_circuit::circuit::{UtxoAccumulator, Transfer}; | ||
|
||
use hex::encode; | ||
|
||
|
||
fn main() -> std::io::Result<()> { | ||
let rng = &mut OsRng::new().unwrap(); | ||
let jubjub_params = JubjubBls12::new(); | ||
|
||
let params_file = File::open("mpc_params_accumulator")?; | ||
let mut params = phase2::MPCParameters::read(¶ms_file, true)?; | ||
drop(params_file); | ||
|
||
let contributions = params.verify(UtxoAccumulator::<Bls12> { | ||
params: &jubjub_params, | ||
note_hashes: [None, None], | ||
index: None, | ||
old_proof: None, | ||
new_proof: None | ||
}).expect("parameters should be valid!"); | ||
|
||
|
||
let hash = params.contribute(rng); | ||
|
||
println!("Contributed with hash {}", encode(hash.as_ref())); | ||
|
||
|
||
let params_file = File::create("mpc_params_accumulator")?; | ||
params.write(params_file)?; | ||
|
||
|
||
let params_file = File::open("mpc_params_transfer")?; | ||
let mut params = phase2::MPCParameters::read(¶ms_file, true)?; | ||
drop(params_file); | ||
|
||
let contributions = params.verify(Transfer::<Bls12> { | ||
params: &jubjub_params, | ||
receiver: None, | ||
in_note: [None, None], | ||
out_note: [None, None], | ||
in_proof: [None, None], | ||
root_hash: None, | ||
sk: None, | ||
packed_asset:None, | ||
}).expect("parameters should be valid!"); | ||
|
||
|
||
let hash = params.contribute(rng); | ||
|
||
println!("Contributed with hash {}", encode(hash.as_ref())); | ||
|
||
|
||
let params_file = File::create("mpc_params_transfer")?; | ||
params.write(params_file)?; | ||
|
||
|
||
println!("MPC params saved OK"); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use bellman::{Circuit, ConstraintSystem, SynthesisError}; | ||
use sapling_crypto::jubjub::{JubjubEngine, JubjubParams, JubjubBls12}; | ||
use pairing::bls12_381::{Bls12, Fr}; | ||
|
||
|
||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
use zwaves_circuit::circuit::{Transfer, UtxoAccumulator}; | ||
use hex::encode; | ||
|
||
|
||
fn main() -> std::io::Result<()> { | ||
let jubjub_params = JubjubBls12::new(); | ||
|
||
|
||
let params_file = File::open("mpc_params_accumulator")?; | ||
let mut params = phase2::MPCParameters::read(¶ms_file, true)?; | ||
drop(params_file); | ||
|
||
let contributions = params.verify(UtxoAccumulator::<Bls12> { | ||
params: &jubjub_params, | ||
note_hashes: [None, None], | ||
index: None, | ||
old_proof: None, | ||
new_proof: None | ||
}).expect("parameters should be valid!"); | ||
|
||
println!("List of all contributions:"); | ||
|
||
contributions.into_iter().enumerate().for_each(|(i, h)| { | ||
println!("{}. {}", i, encode(h.as_ref())); | ||
}); | ||
|
||
|
||
|
||
let params_file = File::open("mpc_params_transfer")?; | ||
let mut params = phase2::MPCParameters::read(¶ms_file, true)?; | ||
drop(params_file); | ||
|
||
let contributions = params.verify(Transfer::<Bls12> { | ||
params: &jubjub_params, | ||
receiver: None, | ||
in_note: [None, None], | ||
out_note: [None, None], | ||
in_proof: [None, None], | ||
root_hash: None, | ||
packed_asset: None, | ||
sk: None | ||
}).expect("parameters should be valid!"); | ||
|
||
println!("List of all contributions:"); | ||
|
||
contributions.into_iter().enumerate().for_each(|(i, h)| { | ||
println!("{}. {}", i, encode(h.as_ref())); | ||
}); | ||
|
||
|
||
|
||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use sapling_crypto::jubjub::{JubjubEngine, JubjubParams, JubjubBls12}; | ||
use pairing::bls12_381::{Bls12, Fr}; | ||
use std::fs::File; | ||
use std::io::Write; | ||
|
||
use zwaves_circuit::circuit::{UtxoAccumulator, Transfer}; | ||
|
||
|
||
|
||
|
||
|
||
fn main() -> std::io::Result<()> { | ||
let jubjub_params = JubjubBls12::new(); | ||
/* | ||
let params = phase2::MPCParameters::new(UtxoAccumulator::<Bls12> { | ||
params: &jubjub_params, | ||
note_hashes: [None, None], | ||
index: None, | ||
old_proof: None, | ||
new_proof: None | ||
}).unwrap(); | ||
let params_file = File::create("mpc_params_accumulator")?; | ||
params.write(params_file)?;*/ | ||
|
||
|
||
let params = phase2::MPCParameters::new(Transfer::<Bls12> { | ||
params: &jubjub_params, | ||
receiver: None, | ||
in_note: [None, None], | ||
out_note: [None, None], | ||
in_proof: [None, None], | ||
root_hash: None, | ||
packed_asset: None, | ||
sk: None | ||
}).unwrap(); | ||
|
||
let params_file = File::create("mpc_params_transfer")?; | ||
params.write(params_file)?; | ||
|
||
println!("MPC params saved OK"); | ||
Ok(()) | ||
} |