1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

fix cpp format, change proof system folder structure

This commit is contained in:
dark64 2020-05-13 15:46:53 +02:00
parent 793c0b143f
commit 17c51ba500
12 changed files with 46 additions and 67 deletions

View file

@ -18,6 +18,9 @@ use std::string::String;
use zokrates_abi::Encode;
use zokrates_core::compile::{compile, CompilationArtifacts, CompileError};
use zokrates_core::ir::{self, ProgEnum};
use zokrates_core::proof_system::bellman::groth16::G16;
use zokrates_core::proof_system::libsnark::gm17::GM17;
use zokrates_core::proof_system::libsnark::pghr13::PGHR13;
use zokrates_core::proof_system::*;
use zokrates_core::typed_absy::abi::Abi;
use zokrates_core::typed_absy::{types::Signature, Type};
@ -681,8 +684,6 @@ fn cli() -> Result<(), String> {
}
}
("compute-witness", Some(sub_matches)) => {
println!("Computing witness...");
// read compiled program
let path = Path::new(sub_matches.value_of("input").unwrap());
let file = File::open(&path)

View file

@ -96,7 +96,8 @@ std::string serializeVerificationKey(r1cs_se_ppzksnark_verification_key<libff::a
ss << "\"h_gamma\":" << outputPointG2AffineAsHexJson(vk->H_gamma) << ",";
ss << "\"query\":[";
for (size_t i = 0; i < queryLength; ++i) {
if (i != 0) ss << ",";
if (i != 0)
ss << ",";
ss << outputPointG1AffineAsHexJson(vk->query[i]);
}
ss << "],";

View file

@ -7,14 +7,12 @@ use regex::Regex;
use zokrates_field::Field;
use crate::ir;
use crate::proof_system::bn128::utils::bellman::Computation;
use crate::proof_system::bn128::utils::bellman::{parse_fr, parse_g1, parse_g2};
use crate::proof_system::bn128::utils::solidity::{
use crate::proof_system::bellman::Computation;
use crate::proof_system::bellman::{parse_fr, parse_g1, parse_g2};
use crate::proof_system::solidity::{
SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use crate::proof_system::{ProofSystem, SetupKeypair};
use proof_system::bn128::{G1Affine, G2Affine};
use proof_system::{Proof, SolidityAbi};
use proof_system::{G1Affine, G2Affine, Proof, ProofSystem, SetupKeypair, SolidityAbi};
const G16_WARNING: &str = "WARNING: You are using the G16 scheme which is subject to malleability. See zokrates.github.io/reference/proving_schemes.html#g16-malleability for implications.";

View file

@ -1,3 +1,5 @@
pub mod groth16;
extern crate rand;
use crate::ir::{CanonicalLinComb, Prog, Statement, Witness};
@ -209,7 +211,7 @@ mod parse {
use lazy_static::lazy_static;
use super::*;
use proof_system::bn128::{G1Affine, G2Affine};
use proof_system::{G1Affine, G2Affine};
use regex::Regex;
lazy_static! {

View file

@ -1,31 +0,0 @@
mod g16;
#[cfg(feature = "libsnark")]
mod gm17;
#[cfg(feature = "libsnark")]
mod pghr13;
mod utils;
pub use self::g16::G16;
#[cfg(feature = "libsnark")]
pub use self::gm17::GM17;
#[cfg(feature = "libsnark")]
pub use self::pghr13::PGHR13;
#[derive(Serialize, Deserialize)]
pub struct G1Affine(String, String);
#[derive(Serialize, Deserialize)]
pub struct G2Affine(G1Affine, G1Affine);
impl ToString for G1Affine {
fn to_string(&self) -> String {
format!("{}, {}", self.0, self.1)
}
}
impl ToString for G2Affine {
fn to_string(&self) -> String {
format!("[{}], [{}]", self.0.to_string(), self.1.to_string())
}
}

View file

@ -1,6 +0,0 @@
pub mod bellman;
#[cfg(feature = "libsnark")]
pub mod ffi;
#[cfg(feature = "libsnark")]
pub mod libsnark;
pub mod solidity;

View file

@ -1,13 +1,10 @@
use ir;
use proof_system::bn128::utils::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::bn128::utils::libsnark::{
prepare_generate_proof, prepare_public_inputs, prepare_setup,
};
use proof_system::bn128::utils::solidity::{
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::libsnark::{prepare_generate_proof, prepare_public_inputs, prepare_setup};
use proof_system::solidity::{
SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use proof_system::bn128::{G1Affine, G2Affine};
use proof_system::{Proof, ProofSystem, SetupKeypair, SolidityAbi};
use proof_system::{G1Affine, G2Affine, Proof, ProofSystem, SetupKeypair, SolidityAbi};
use regex::Regex;
use zokrates_field::Bn128Field;

View file

@ -1,3 +1,7 @@
mod ffi;
pub mod gm17;
pub mod pghr13;
use flat_absy::FlatVariable;
use ir::{self, Statement};
use std::cmp::max;

View file

@ -1,13 +1,10 @@
use ir;
use proof_system::bn128::utils::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::bn128::utils::libsnark::{
prepare_generate_proof, prepare_public_inputs, prepare_setup,
};
use proof_system::bn128::utils::solidity::{
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::libsnark::{prepare_generate_proof, prepare_public_inputs, prepare_setup};
use proof_system::solidity::{
SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use proof_system::bn128::{G1Affine, G2Affine};
use proof_system::{Proof, ProofSystem, SetupKeypair, SolidityAbi};
use proof_system::{G1Affine, G2Affine, Proof, ProofSystem, SetupKeypair, SolidityAbi};
use regex::Regex;
use zokrates_field::Bn128Field;

View file

@ -1,10 +1,8 @@
mod bn128;
pub mod bellman;
#[cfg(feature = "libsnark")]
pub mod libsnark;
pub use self::bn128::G16;
#[cfg(feature = "libsnark")]
pub use self::bn128::GM17;
#[cfg(feature = "libsnark")]
pub use self::bn128::PGHR13;
mod solidity;
use crate::ir;
use serde::de::DeserializeOwned;
@ -57,6 +55,24 @@ impl<T: Serialize + DeserializeOwned> Proof<T> {
}
}
#[derive(Serialize, Deserialize)]
pub struct G1Affine(String, String);
#[derive(Serialize, Deserialize)]
pub struct G2Affine(G1Affine, G1Affine);
impl ToString for G1Affine {
fn to_string(&self) -> String {
format!("{}, {}", self.0, self.1)
}
}
impl ToString for G2Affine {
fn to_string(&self) -> String {
format!("[{}], [{}]", self.0.to_string(), self.1.to_string())
}
}
pub trait ProofSystem<T: Field>
where
Self::VerificationKey: Serialize + DeserializeOwned,