mirror of
https://github.com/fluencelabs/lazy-snark
synced 2025-04-25 06:52:14 +00:00
wip: add read uncompressed bin
This commit is contained in:
parent
eaf44393b7
commit
e68c3ecb04
@ -479,6 +479,7 @@ fn main() {
|
||||
generate_random_parameters(circuit, &mut rng).expect("must generate parameters")
|
||||
};
|
||||
|
||||
// write vk in binary form
|
||||
let vk_file = File::create(PathBuf::from("./vk.key")).unwrap();
|
||||
parameters.vk.write(vk_file).unwrap();
|
||||
|
||||
@ -489,19 +490,10 @@ fn main() {
|
||||
create_random_proof(circuit, ¶meters, &mut rng).expect("must create a proof")
|
||||
};
|
||||
|
||||
// write proof in binary form
|
||||
let proof_file = File::create(PathBuf::from("./proof.key")).unwrap();
|
||||
proof.write(proof_file).unwrap();
|
||||
|
||||
|
||||
|
||||
|
||||
let a : G1Affine = proof.a;
|
||||
println!("proof a g1: {}", a);
|
||||
println!("proof a g1 uncompressed: {}", a.into_uncompressed().as_ref());
|
||||
|
||||
|
||||
|
||||
|
||||
println!("public inputs: {}", public_inputs[0]);
|
||||
|
||||
let is_valid = verify_proof(&prepared_vk, &proof, &public_inputs).expect("must verify a proof");
|
||||
|
2
test_back_fluence/proof.bin
Normal file
2
test_back_fluence/proof.bin
Normal file
@ -0,0 +1,2 @@
|
||||
<4{ €¤
|
||||
"ę˘ŇĽV".sOU˝qw!ɆQ<E280A0>r]©żçۨ{×7•!.ěçŐŞ;¨ˇň~4ČşŚJÇC.
Bxć˛[.1úB\|‘Ńî˝®°ď"‹YTâ ŔŠ’\dRą}›<>`<0E>3Ş“(J‹Ť<E280B9>ÖŻeÁ
÷ëµě
|
2
test_back_fluence/proof2.bin
Normal file
2
test_back_fluence/proof2.bin
Normal file
@ -0,0 +1,2 @@
|
||||
<4{ €¤
|
||||
"ę˘ŇĽV".sOU˝qw!ɆQ<E280A0>r]÷âĘb<C498>DË|,ĘĚŠ»I0Í"mÍ7ůč8`ůBˇw}
|
Binary file not shown.
@ -53,13 +53,22 @@ fn main() {
|
||||
use bellman::groth16::Proof;
|
||||
use bellman::groth16::VerifyingKey;
|
||||
|
||||
use bellman::pairing::{
|
||||
Engine,
|
||||
CurveAffine,
|
||||
EncodedPoint
|
||||
};
|
||||
|
||||
|
||||
use crate::{
|
||||
SynthesisError
|
||||
};
|
||||
|
||||
use std::io::{self, Read};
|
||||
use std::sync::Arc;
|
||||
|
||||
// import verification key
|
||||
|
||||
|
||||
|
||||
self.alpha_g1.into_uncompressed().as_ref();
|
||||
|
||||
//let vk_file = File::open(PathBuf::from("./verification.key")).unwrap();
|
||||
//let vk : VerifyingKey<Bn256> = VerifyingKey::read(vk_file).unwrap();
|
||||
|
||||
@ -69,8 +78,49 @@ fn main() {
|
||||
//let prepared_vk = prepare_verifying_key(&vk);
|
||||
|
||||
// import proof
|
||||
//let proof_file = File::open(PathBuf::from("./proof.key")).unwrap();
|
||||
//let proof : Proof<Bn256> = Proof::read(proof_file).unwrap();
|
||||
let proof_file = File::open(PathBuf::from("./proof.bin")).unwrap();
|
||||
let proof : Proof<Bn256> = Proof::read(proof_file).unwrap();
|
||||
|
||||
// export proof
|
||||
let mut proof_file = File::create(PathBuf::from("./proof2.bin")).unwrap();
|
||||
proof_file.write_all(proof.a.into_uncompressed().as_ref());
|
||||
//proof_file.write_all(proof.b.into_compressed().as_ref());
|
||||
//0x125c6452b97d9b83600e903313aa93284a8b8d8318050ed6af65c10df7ebb5ec
|
||||
//let [u8] =
|
||||
//proof_file.write_all(proof.c.into_compressed().as_ref());
|
||||
|
||||
let mut proof_file = File::open(PathBuf::from("./proof2.bin")).unwrap();
|
||||
//let proof : Proof<Bn256> = Proof::read(proof_file).unwrap();
|
||||
|
||||
|
||||
let mut g1_repr = <bellman::pairing::bn256::G1Affine as CurveAffine>::Uncompressed::empty();
|
||||
//let mut g2_repr = <bellman::pairing::bn256::G2Affine as CurveAffine>::Uncompressed::empty();
|
||||
|
||||
proof_file.read_exact(g1_repr.as_mut());
|
||||
//let a = g1_repr.into_affine();
|
||||
let a = g1_repr
|
||||
.into_affine()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||
.and_then(|e| if e.is_zero() {
|
||||
Err(io::Error::new(io::ErrorKind::InvalidData, "point at infinity"))
|
||||
} else {
|
||||
Ok(e)
|
||||
}).unwrap();
|
||||
println!("!!! proof a g1: {}", a);
|
||||
|
||||
|
||||
// write proof.a in hex form and binary form
|
||||
let a : G1Affine = proof.a;
|
||||
println!("proof a g1: {}", a);
|
||||
println!("proof a g1 compressed: {:?}", a.into_compressed().as_ref());
|
||||
|
||||
let b : G2Affine = proof.b;
|
||||
println!("proof b g2: {}", b);
|
||||
println!("proof b g2 compressed: {:?}", b.into_compressed().as_ref());
|
||||
|
||||
let c : G1Affine = proof.c;
|
||||
println!("proof c g1: {}", c);
|
||||
println!("proof c g1 uncompressed: {:?}", c.into_compressed().as_ref());
|
||||
|
||||
// import public inputs
|
||||
//let public_inputs = vec![];
|
||||
|
Loading…
x
Reference in New Issue
Block a user