1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

featurize zokrates_core

This commit is contained in:
schaeff 2020-11-30 23:10:36 +00:00
parent 4975f748fd
commit 5f76a0316b
63 changed files with 253 additions and 193 deletions

5
Cargo.lock generated
View file

@ -1578,6 +1578,9 @@ name = "serde"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
@ -2042,6 +2045,7 @@ version = "0.6.2"
dependencies = [
"assert_cli",
"bincode",
"cfg-if 0.1.10",
"clap",
"dirs",
"fs_extra",
@ -2090,7 +2094,6 @@ dependencies = [
"reduce",
"regex",
"serde",
"serde_derive",
"serde_json",
"typed-arena",
"wasm-bindgen-test",

View file

@ -12,6 +12,7 @@ bellman = ["zokrates_core/bellman"]
ark = ["zokrates_core/ark"]
[dependencies]
cfg-if = "0.1"
clap = "2.26.2"
bincode = "0.8.0"
regex = "0.2"

View file

@ -21,18 +21,24 @@ use std::string::String;
use zokrates_abi::Encode;
use zokrates_core::compile::{check, compile, CompilationArtifacts, CompileError};
use zokrates_core::ir::{self, ProgEnum};
use zokrates_core::proof_system::{
ark::Ark, bellman::Bellman, gm17::GM17, groth16::G16, SolidityCompatibleField,
gm17::GM17, groth16::G16, pghr13::PGHR13, SolidityCompatibleField,
};
use zokrates_core::proof_system::{Backend, Scheme, SolidityAbi, SolidityCompatibleScheme};
use zokrates_core::proof_system::{SolidityAbi, SolidityCompatibleScheme};
use zokrates_core::typed_absy::abi::Abi;
use zokrates_core::typed_absy::{types::Signature, Type};
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
use zokrates_fs_resolver::FileSystemResolver;
#[cfg(feature = "ark")]
use zokrates_core::proof_system::ark::Ark;
#[cfg(feature = "bellman")]
use zokrates_core::proof_system::bellman::Bellman;
#[cfg(feature = "libsnark")]
use {
zokrates_core::proof_system::libsnark::Libsnark, zokrates_core::proof_system::pghr13::PGHR13,
};
use zokrates_core::proof_system::libsnark::Libsnark;
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
use zokrates_core::proof_system::{Backend, Scheme};
fn main() {
cli().unwrap_or_else(|e| {
@ -41,6 +47,7 @@ fn main() {
})
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
fn cli_generate_proof<T: Field, S: Scheme<T>, B: Backend<T, S>>(
program: ir::Prog<T>,
sub_matches: &ArgMatches,
@ -115,6 +122,7 @@ fn cli_export_verifier<T: SolidityCompatibleField, S: SolidityCompatibleScheme<T
Ok(())
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
fn cli_setup<T: Field, S: Scheme<T>, B: Backend<T, S>>(
program: ir::Prog<T>,
sub_matches: &ArgMatches,
@ -397,6 +405,7 @@ fn cli_check<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
Ok(())
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
fn cli_verify<T: Field, S: Scheme<T>, B: Backend<T, S>>(
sub_matches: &ArgMatches,
) -> Result<(), String> {
@ -821,6 +830,7 @@ fn cli() -> Result<(), String> {
ProgEnum::Bw6_761Program(p) => cli_compute(p, sub_matches)?,
}
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
("setup", Some(sub_matches)) => {
// read compiled program
let path = Path::new(sub_matches.value_of("input").unwrap());
@ -842,11 +852,13 @@ fn cli() -> Result<(), String> {
))?;
match parameters {
#[cfg(feature = "bellman")]
Parameters(BackendParameter::Bellman, _, SchemeParameter::G16) => match prog {
ProgEnum::Bn128Program(p) => cli_setup::<_, G16, Bellman>(p, sub_matches),
ProgEnum::Bls12_381Program(p) => cli_setup::<_, G16, Bellman>(p, sub_matches),
_ => unreachable!(),
},
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
ProgEnum::Bls12_377Program(p) => cli_setup::<_, GM17, Ark>(p, sub_matches),
ProgEnum::Bw6_761Program(p) => cli_setup::<_, GM17, Ark>(p, sub_matches),
@ -887,13 +899,13 @@ fn cli() -> Result<(), String> {
(CurveParameter::Bn128, SchemeParameter::GM17) => {
cli_export_verifier::<Bn128Field, GM17>(sub_matches)
}
#[cfg(feature = "libsnark")]
(CurveParameter::Bn128, SchemeParameter::PGHR13) => {
cli_export_verifier::<Bn128Field, PGHR13>(sub_matches)
}
_ => Err(format!("Could not export verifier with given parameters (curve: {}, scheme: {}): not supported", curve, scheme))
}?
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
("generate-proof", Some(sub_matches)) => {
let program_path = Path::new(sub_matches.value_of("input").unwrap());
let program_file = File::open(&program_path)
@ -914,6 +926,7 @@ fn cli() -> Result<(), String> {
))?;
match parameters {
#[cfg(feature = "bellman")]
Parameters(BackendParameter::Bellman, _, SchemeParameter::G16) => match prog {
ProgEnum::Bn128Program(p) => {
cli_generate_proof::<_, G16, Bellman>(p, sub_matches)
@ -923,6 +936,7 @@ fn cli() -> Result<(), String> {
}
_ => unreachable!(),
},
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, _, SchemeParameter::GM17) => match prog {
ProgEnum::Bls12_377Program(p) => {
cli_generate_proof::<_, GM17, Ark>(p, sub_matches)
@ -994,6 +1008,7 @@ fn cli() -> Result<(), String> {
_ => unreachable!(),
}
}
#[cfg(any(feature = "bellman", feature = "ark", feature = "libsnark"))]
("verify", Some(sub_matches)) => {
let parameters = Parameters::try_from((
sub_matches.value_of("backend").unwrap(),
@ -1002,26 +1017,31 @@ fn cli() -> Result<(), String> {
))?;
match parameters {
#[cfg(feature = "bellman")]
Parameters(
BackendParameter::Bellman,
CurveParameter::Bn128,
SchemeParameter::G16,
) => cli_verify::<Bn128Field, G16, Bellman>(sub_matches),
#[cfg(feature = "bellman")]
Parameters(
BackendParameter::Bellman,
CurveParameter::Bls12_381,
SchemeParameter::G16,
) => cli_verify::<Bls12_381Field, G16, Bellman>(sub_matches),
#[cfg(feature = "ark")]
Parameters(
BackendParameter::Ark,
CurveParameter::Bls12_377,
SchemeParameter::GM17,
) => cli_verify::<Bls12_377Field, GM17, Ark>(sub_matches),
#[cfg(feature = "ark")]
Parameters(
BackendParameter::Ark,
CurveParameter::Bw6_761,
SchemeParameter::GM17,
) => cli_verify::<Bw6_761Field, GM17, Ark>(sub_matches),
#[cfg(feature = "ark")]
Parameters(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => {
cli_verify::<Bn128Field, GM17, Ark>(sub_matches)
}

View file

@ -1,12 +1,36 @@
pub const BELLMAN: &str = "bellman";
#[cfg(feature = "libsnark")]
pub const LIBSNARK: &str = "libsnark";
pub const ARK: &str = "ark";
#[cfg(feature = "libsnark")]
pub const BACKENDS: &[&str] = &[BELLMAN, LIBSNARK, ARK];
#[cfg(not(feature = "libsnark"))]
pub const BACKENDS: &[&str] = &[BELLMAN, ARK];
pub const BACKENDS: &[&str] = if cfg!(feature = "libsnark") {
if cfg!(feature = "ark") {
if cfg!(feature = "bellman") {
&[BELLMAN, LIBSNARK, ARK]
} else {
&[LIBSNARK, ARK]
}
} else {
if cfg!(feature = "bellman") {
&[BELLMAN, LIBSNARK]
} else {
&[LIBSNARK]
}
}
} else {
if cfg!(feature = "ark") {
if cfg!(feature = "bellman") {
&[BELLMAN, ARK]
} else {
&[ARK]
}
} else {
if cfg!(feature = "bellman") {
&[BELLMAN]
} else {
&[]
}
}
};
pub const BN128: &str = "bn128";
pub const BLS12_381: &str = "bls12_381";
@ -15,11 +39,7 @@ pub const BW6_761: &str = "bw6_761";
pub const CURVES: &[&str] = &[BN128, BLS12_381, BLS12_377, BW6_761];
pub const G16: &str = "g16";
#[cfg(feature = "libsnark")]
pub const PGHR13: &str = "pghr13";
pub const GM17: &str = "gm17";
#[cfg(feature = "libsnark")]
pub const SCHEMES: &[&str] = &[G16, PGHR13, GM17];
#[cfg(not(feature = "libsnark"))]
pub const SCHEMES: &[&str] = &[G16, GM17];

View file

@ -11,7 +11,9 @@ pub enum CurveParameter {
}
pub enum BackendParameter {
#[cfg(feature = "bellman")]
Bellman,
#[cfg(feature = "ark")]
Ark,
#[cfg(feature = "libsnark")]
Libsnark,
@ -20,7 +22,6 @@ pub enum BackendParameter {
pub enum SchemeParameter {
G16,
GM17,
#[cfg(feature = "libsnark")]
PGHR13,
}
@ -43,7 +44,9 @@ impl TryFrom<&str> for BackendParameter {
fn try_from(s: &str) -> Result<Self, Self::Error> {
match s {
#[cfg(feature = "bellman")]
BELLMAN => Ok(BackendParameter::Bellman),
#[cfg(feature = "ark")]
ARK => Ok(BackendParameter::Ark),
#[cfg(feature = "libsnark")]
LIBSNARK => Ok(BackendParameter::Libsnark),
@ -59,7 +62,6 @@ impl TryFrom<&str> for SchemeParameter {
match s {
G16 => Ok(SchemeParameter::G16),
GM17 => Ok(SchemeParameter::GM17),
#[cfg(feature = "libsnark")]
PGHR13 => Ok(SchemeParameter::PGHR13),
_ => Err(format!("Unknown proving scheme {}", s)),
}
@ -81,10 +83,15 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
let proving_scheme = SchemeParameter::try_from(s.2)?;
match (&backend, &curve, &proving_scheme) {
#[cfg(feature = "bellman")]
(BackendParameter::Bellman, CurveParameter::Bn128, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "bellman")]
(BackendParameter::Bellman, CurveParameter::Bls12_381, SchemeParameter::G16) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bls12_377, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bw6_761, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "ark")]
(BackendParameter::Ark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
#[cfg(feature = "libsnark")]
(BackendParameter::Libsnark, CurveParameter::Bn128, SchemeParameter::GM17) => Ok(()),
@ -94,6 +101,6 @@ impl TryFrom<(&str, &str, &str)> for Parameters {
"Unsupported combination of parameters (backend: {}, curve: {}, proving scheme: {})",
s.0, s.1, s.2
)),
}.map(|_| Parameters(backend, curve, proving_scheme))
}.map(|_: ()| Parameters(backend, curve, proving_scheme))
}
}

View file

@ -10,10 +10,10 @@ build = "build.rs"
[features]
default = []
libsnark = ["cc", "cmake", "git2"]
bellman = ["bellman_ce"]
bellman = ["bellman_ce", "pairing_ce", "ff_ce", "zokrates_field/bellman"]
wasm = ["bellman_ce/nolog", "bellman_ce/wasm"]
multicore = ["bellman_ce/multicore"]
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-serialize", "ark-relations"]
ark = ["ark-ff", "ark-ec", "ark-bn254", "ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-serialize", "ark-relations", "zokrates_field/ark"]
[dependencies]
cfg-if = "0.1"
@ -23,8 +23,7 @@ lazy_static = "1.4"
typed-arena = "1.4.1"
reduce = "0.1.1"
# serialization and deserialization
serde = "1.0"
serde_derive = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
bincode = "0.8.0"
hex = "0.4.2"

View file

@ -1,5 +1,5 @@
use absy;
use imports;
use crate::absy;
use crate::imports;
use num::ToPrimitive;
use num_bigint::BigUint;
@ -23,7 +23,7 @@ impl<'ast> From<pest::File<'ast>> for absy::Module<'ast> {
impl<'ast> From<pest::ImportDirective<'ast>> for absy::ImportNode<'ast> {
fn from(import: pest::ImportDirective<'ast>) -> absy::ImportNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
match import {
pest::ImportDirective::Main(import) => {
@ -48,7 +48,7 @@ impl<'ast> From<pest::ImportDirective<'ast>> for absy::ImportNode<'ast> {
impl<'ast> From<pest::StructDefinition<'ast>> for absy::SymbolDeclarationNode<'ast> {
fn from(definition: pest::StructDefinition<'ast>) -> absy::SymbolDeclarationNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let span = definition.span;
@ -73,7 +73,7 @@ impl<'ast> From<pest::StructDefinition<'ast>> for absy::SymbolDeclarationNode<'a
impl<'ast> From<pest::StructField<'ast>> for absy::StructDefinitionFieldNode<'ast> {
fn from(field: pest::StructField<'ast>) -> absy::StructDefinitionFieldNode {
use absy::NodeValue;
use crate::absy::NodeValue;
let span = field.span;
@ -87,7 +87,7 @@ impl<'ast> From<pest::StructField<'ast>> for absy::StructDefinitionFieldNode<'as
impl<'ast> From<pest::Function<'ast>> for absy::SymbolDeclarationNode<'ast> {
fn from(function: pest::Function<'ast>) -> absy::SymbolDeclarationNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let span = function.span;
@ -136,7 +136,7 @@ impl<'ast> From<pest::Function<'ast>> for absy::SymbolDeclarationNode<'ast> {
impl<'ast> From<pest::Parameter<'ast>> for absy::ParameterNode<'ast> {
fn from(param: pest::Parameter<'ast>) -> absy::ParameterNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let private = param
.visibility
@ -166,7 +166,7 @@ fn statements_from_statement(statement: pest::Statement) -> Vec<absy::StatementN
}
fn statements_from_definition(definition: pest::DefinitionStatement) -> Vec<absy::StatementNode> {
use absy::NodeValue;
use crate::absy::NodeValue;
let lhs = definition.lhs;
@ -240,7 +240,7 @@ fn statements_from_definition(definition: pest::DefinitionStatement) -> Vec<absy
impl<'ast> From<pest::ReturnStatement<'ast>> for absy::StatementNode<'ast> {
fn from(statement: pest::ReturnStatement<'ast>) -> absy::StatementNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Statement::Return(
absy::ExpressionList {
@ -258,7 +258,7 @@ impl<'ast> From<pest::ReturnStatement<'ast>> for absy::StatementNode<'ast> {
impl<'ast> From<pest::AssertionStatement<'ast>> for absy::StatementNode<'ast> {
fn from(statement: pest::AssertionStatement<'ast>) -> absy::StatementNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Statement::Assertion(absy::ExpressionNode::from(statement.expression))
.span(statement.span)
@ -267,7 +267,7 @@ impl<'ast> From<pest::AssertionStatement<'ast>> for absy::StatementNode<'ast> {
impl<'ast> From<pest::IterationStatement<'ast>> for absy::StatementNode<'ast> {
fn from(statement: pest::IterationStatement<'ast>) -> absy::StatementNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let from = absy::ExpressionNode::from(statement.from);
let to = absy::ExpressionNode::from(statement.to);
let index = statement.index.span.as_str();
@ -302,7 +302,7 @@ impl<'ast> From<pest::Expression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::BinaryExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(expression: pest::BinaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
match expression.op {
pest::BinaryOperator::Add => absy::Expression::Add(
box absy::ExpressionNode::from(*expression.left),
@ -391,7 +391,7 @@ impl<'ast> From<pest::BinaryExpression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::TernaryExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(expression: pest::TernaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Expression::IfElse(
box absy::ExpressionNode::from(*expression.first),
box absy::ExpressionNode::from(*expression.second),
@ -403,7 +403,7 @@ impl<'ast> From<pest::TernaryExpression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::Spread<'ast>> for absy::SpreadNode<'ast> {
fn from(spread: pest::Spread<'ast>) -> absy::SpreadNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Spread {
expression: absy::ExpressionNode::from(spread.expression),
}
@ -413,7 +413,7 @@ impl<'ast> From<pest::Spread<'ast>> for absy::SpreadNode<'ast> {
impl<'ast> From<pest::Range<'ast>> for absy::RangeNode<'ast> {
fn from(range: pest::Range<'ast>) -> absy::RangeNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let from = range.from.map(|e| absy::ExpressionNode::from(e.0));
@ -453,7 +453,7 @@ impl<'ast> From<pest::SpreadOrExpression<'ast>> for absy::SpreadOrExpression<'as
impl<'ast> From<pest::InlineArrayExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(array: pest::InlineArrayExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Expression::InlineArray(
array
.expressions
@ -467,7 +467,7 @@ impl<'ast> From<pest::InlineArrayExpression<'ast>> for absy::ExpressionNode<'ast
impl<'ast> From<pest::InlineStructExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(s: pest::InlineStructExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Expression::InlineStruct(
s.ty.span.as_str().to_string(),
s.members
@ -486,7 +486,7 @@ impl<'ast> From<pest::InlineStructExpression<'ast>> for absy::ExpressionNode<'as
impl<'ast> From<pest::ArrayInitializerExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(initializer: pest::ArrayInitializerExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let value = absy::ExpressionNode::from(*initializer.value);
let count: absy::ExpressionNode<'ast> = absy::ExpressionNode::from(initializer.count);
@ -501,7 +501,7 @@ impl<'ast> From<pest::ArrayInitializerExpression<'ast>> for absy::ExpressionNode
impl<'ast> From<pest::UnaryExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(unary: pest::UnaryExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
match unary.op {
pest::UnaryOperator::Not(_) => {
@ -514,7 +514,7 @@ impl<'ast> From<pest::UnaryExpression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::PostfixExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(expression: pest::PostfixExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let id_str = expression.id.span.as_str();
let id = absy::ExpressionNode::from(expression.id);
@ -548,7 +548,7 @@ impl<'ast> From<pest::PostfixExpression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::ConstantExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(expression: pest::ConstantExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
match expression {
pest::ConstantExpression::BooleanLiteral(c) => {
absy::Expression::BooleanConstant(c.value.parse().unwrap()).span(c.span)
@ -575,14 +575,14 @@ impl<'ast> From<pest::ConstantExpression<'ast>> for absy::ExpressionNode<'ast> {
impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::ExpressionNode<'ast> {
fn from(expression: pest::IdentifierExpression<'ast>) -> absy::ExpressionNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Expression::Identifier(expression.span.as_str()).span(expression.span)
}
}
impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::AssigneeNode<'ast> {
fn from(expression: pest::IdentifierExpression<'ast>) -> absy::AssigneeNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
absy::Assignee::Identifier(expression.span.as_str()).span(expression.span)
}
@ -590,7 +590,7 @@ impl<'ast> From<pest::IdentifierExpression<'ast>> for absy::AssigneeNode<'ast> {
impl<'ast> From<pest::Assignee<'ast>> for absy::AssigneeNode<'ast> {
fn from(assignee: pest::Assignee<'ast>) -> absy::AssigneeNode<'ast> {
use absy::NodeValue;
use crate::absy::NodeValue;
let a = absy::AssigneeNode::from(assignee.id);
let span = assignee.span;
@ -611,8 +611,8 @@ impl<'ast> From<pest::Assignee<'ast>> for absy::AssigneeNode<'ast> {
impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode {
fn from(t: pest::Type<'ast>) -> absy::UnresolvedTypeNode {
use absy::types::UnresolvedType;
use absy::NodeValue;
use crate::absy::types::UnresolvedType;
use crate::absy::NodeValue;
match t {
pest::Type::Basic(t) => match t {
@ -673,8 +673,8 @@ impl<'ast> From<pest::Type<'ast>> for absy::UnresolvedTypeNode {
#[cfg(test)]
mod tests {
use super::*;
use absy::types::{UnresolvedSignature, UnresolvedType};
use absy::NodeValue;
use crate::absy::types::{UnresolvedSignature, UnresolvedType};
use crate::absy::NodeValue;
#[test]
fn return_forty_two() {

View file

@ -15,7 +15,7 @@ pub use crate::absy::node::{Node, NodeValue};
pub use crate::absy::parameter::{Parameter, ParameterNode};
use crate::absy::types::{FunctionIdentifier, UnresolvedSignature, UnresolvedType, UserTypeId};
pub use crate::absy::variable::{Variable, VariableNode};
use embed::FlatEmbed;
use crate::embed::FlatEmbed;
use std::path::PathBuf;
use crate::imports::ImportNode;

View file

@ -2,7 +2,7 @@ use crate::parser::Position;
use std::fmt;
use zokrates_pest_ast::Span;
#[derive(Clone, Serialize, Deserialize)]
#[derive(Clone)]
pub struct Node<T> {
pub start: Position,
pub end: Position,
@ -72,9 +72,9 @@ impl<V: NodeValue> From<V> for Node<V> {
}
}
use crate::absy::types::UnresolvedType;
use crate::absy::*;
use crate::imports::*;
use absy::types::UnresolvedType;
impl<'ast> NodeValue for Expression<'ast> {}
impl<'ast> NodeValue for ExpressionList<'ast> {}

View file

@ -1,4 +1,4 @@
use absy::UnresolvedTypeNode;
use crate::absy::UnresolvedTypeNode;
use std::fmt;
pub type Identifier<'ast> = &'ast str;
@ -7,7 +7,7 @@ pub type MemberId = String;
pub type UserTypeId = String;
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug)]
#[derive(Clone, PartialEq, Debug)]
pub enum UnresolvedType {
FieldElement,
Boolean,
@ -41,9 +41,9 @@ pub use self::signature::UnresolvedSignature;
mod signature {
use std::fmt;
use absy::UnresolvedTypeNode;
use crate::absy::UnresolvedTypeNode;
#[derive(Clone, PartialEq, Serialize, Deserialize)]
#[derive(Clone, PartialEq)]
pub struct UnresolvedSignature {
pub inputs: Vec<UnresolvedTypeNode>,
pub outputs: Vec<UnresolvedTypeNode>,

View file

@ -3,21 +3,21 @@
//! @file compile.rs
//! @author Thibaut Schaeffer <thibaut@schaeff.fr>
//! @date 2018
use absy::{Module, ModuleId, Program};
use flatten::Flattener;
use imports::{self, Importer};
use ir;
use macros;
use crate::absy::{Module, ModuleId, Program};
use crate::flatten::Flattener;
use crate::imports::{self, Importer};
use crate::ir;
use crate::macros;
use crate::semantics::{self, Checker};
use crate::static_analysis::Analyse;
use crate::typed_absy::abi::Abi;
use crate::zir::ZirProgram;
use macros::process_macros;
use semantics::{self, Checker};
use static_analysis::Analyse;
use std::collections::HashMap;
use std::fmt;
use std::io;
use std::path::PathBuf;
use typed_absy::abi::Abi;
use typed_arena::Arena;
use zir::ZirProgram;
use zokrates_common::Resolver;
use zokrates_field::Field;
use zokrates_pest_ast as pest;
@ -287,8 +287,8 @@ mod test {
mod abi {
use super::*;
use typed_absy::abi::*;
use typed_absy::types::*;
use crate::typed_absy::abi::*;
use crate::typed_absy::types::*;
#[test]
fn use_struct_declaration_types() {

View file

@ -1,10 +1,10 @@
use crate::solvers::Solver;
use flat_absy::{
use crate::flat_absy::{
FlatDirective, FlatExpression, FlatExpressionList, FlatFunction, FlatParameter, FlatStatement,
FlatVariable,
};
use crate::solvers::Solver;
use crate::typed_absy::types::{FunctionKey, Signature, Type};
use std::collections::HashMap;
use typed_absy::types::{FunctionKey, Signature, Type};
use zokrates_field::Field;
/// A low level function that contains non-deterministic introduction of variables. It is carried out as is until

View file

@ -2,7 +2,7 @@ use crate::flat_absy::flat_variable::FlatVariable;
use std::collections::HashMap;
use std::fmt;
#[derive(Clone, PartialEq, Serialize, Deserialize)]
#[derive(Clone, PartialEq)]
pub struct FlatParameter {
pub id: FlatVariable,
pub private: bool,

View file

@ -1,3 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;

View file

@ -11,7 +11,7 @@ pub mod flat_variable;
pub use self::flat_parameter::FlatParameter;
pub use self::flat_variable::FlatVariable;
use solvers::Solver;
use crate::solvers::Solver;
use std::collections::HashMap;
use std::fmt;
use zokrates_field::Field;
@ -209,7 +209,7 @@ impl<T: Field> fmt::Display for FlatDirective<T> {
}
}
#[derive(Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum FlatExpression<T> {
Number(T),
Identifier(FlatVariable),

View file

@ -1,4 +1,5 @@
use crate::flat_absy::FlatVariable;
use serde::{Deserialize, Serialize};
use std::collections::btree_map::{BTreeMap, Entry};
use std::fmt;
use std::ops::{Add, Div, Mul, Sub};

View file

@ -1,7 +1,8 @@
use crate::flat_absy::flat_variable::FlatVariable;
use crate::ir::Directive;
use crate::ir::{LinComb, Prog, QuadComb, Statement, Witness};
use ir::Directive;
use solvers::Solver;
use crate::solvers::Solver;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt;
use zokrates_field::Field;

View file

@ -1,6 +1,7 @@
use crate::flat_absy::flat_parameter::FlatParameter;
use crate::flat_absy::FlatVariable;
use crate::solvers::Solver;
use serde::{Deserialize, Serialize};
use std::fmt;
use zokrates_field::Field;

View file

@ -1,5 +1,5 @@
use crate::ir::Prog;
use bincode::{deserialize_from, serialize_into, Infinite};
use ir::Prog;
use std::io::{Read, Write};
use zokrates_field::*;
@ -70,7 +70,7 @@ impl ProgEnum {
#[cfg(test)]
mod tests {
use super::*;
use ir;
use crate::ir;
use std::io::{Cursor, Seek, SeekFrom};
use zokrates_field::{Bls12_381Field, Bn128Field};

View file

@ -1,8 +1,5 @@
#![feature(box_patterns, box_syntax)]
#[macro_use]
extern crate serde_derive;
cfg_if::cfg_if! {
if #[cfg(feature = "ark")] {
extern crate bellman_ce as bellman;

View file

@ -12,7 +12,7 @@
use crate::flat_absy::flat_variable::FlatVariable;
use crate::ir::folder::*;
use crate::ir::*;
use solvers::Solver;
use crate::solvers::Solver;
use std::collections::hash_map::{Entry, HashMap};
use zokrates_field::Field;

View file

@ -48,7 +48,7 @@ impl<T: Field> Folder<T> for DuplicateOptimizer {
#[cfg(test)]
mod tests {
use super::*;
use flat_absy::FlatVariable;
use crate::flat_absy::FlatVariable;
use zokrates_field::Bn128Field;
#[test]

View file

@ -1,6 +1,6 @@
use std::fmt;
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Copy)]
pub struct Position {
pub line: usize,
pub col: usize,

View file

@ -6,13 +6,13 @@ use ark_gm17::{
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use zokrates_field::{ArkFieldExtensions, Bw6_761Field, Field};
use crate::ir::{Prog, Witness};
use crate::proof_system::ark::Ark;
use crate::proof_system::ark::Computation;
use crate::proof_system::ark::{parse_fr, parse_g1, parse_g2, parse_g2_fq};
use ir::{Prog, Witness};
use proof_system::ark::Ark;
use proof_system::gm17::{NotBw6_761Field, ProofPoints, VerificationKey, GM17};
use proof_system::Scheme;
use proof_system::{Backend, Proof, SetupKeypair};
use crate::proof_system::gm17::{NotBw6_761Field, ProofPoints, VerificationKey, GM17};
use crate::proof_system::Scheme;
use crate::proof_system::{Backend, Proof, SetupKeypair};
impl<T: Field + ArkFieldExtensions + NotBw6_761Field> Backend<T, GM17> for Ark {
fn setup(program: Prog<T>) -> SetupKeypair<<GM17 as Scheme<T>>::VerificationKey> {
@ -200,9 +200,9 @@ impl Backend<Bw6_761Field, GM17> for Ark {
}
pub mod serialization {
use crate::proof_system::{G1Affine, G2Affine, G2AffineFq};
use ark_ec::PairingEngine;
use ark_ff::FromBytes;
use proof_system::{G1Affine, G2Affine, G2AffineFq};
use zokrates_field::ArkFieldExtensions;
#[inline]

View file

@ -214,8 +214,8 @@ impl<T: Field + ArkFieldExtensions>
mod parse {
use super::*;
use crate::proof_system::{Fr, G1Affine, G2Affine, G2AffineFq};
use ark_ff::ToBytes;
use proof_system::{Fr, G1Affine, G2Affine, G2AffineFq};
pub fn parse_g1<T: Field + ArkFieldExtensions>(
e: &<T::ArkEngine as PairingEngine>::G1Affine,

View file

@ -4,16 +4,16 @@ use bellman::groth16::{
};
use pairing::{CurveAffine, Engine};
use proof_system::{Backend, Proof, SetupKeypair};
use crate::proof_system::{Backend, Proof, SetupKeypair};
use zokrates_field::BellmanFieldExtensions;
use zokrates_field::Field;
use crate::ir::{Prog, Witness};
use crate::proof_system::bellman::Bellman;
use crate::proof_system::bellman::Computation;
use crate::proof_system::bellman::{parse_fr, parse_g1, parse_g2};
use ir::{Prog, Witness};
use proof_system::bellman::Bellman;
use proof_system::groth16::{ProofPoints, VerificationKey, G16};
use proof_system::Scheme;
use crate::proof_system::groth16::{ProofPoints, VerificationKey, G16};
use crate::proof_system::Scheme;
const G16_WARNING: &str = "WARNING: You are using the G16 scheme which is subject to malleability. See zokrates.github.io/toolbox/proving_schemes.html#g16-malleability for implications.";
@ -109,7 +109,7 @@ impl<T: Field + BellmanFieldExtensions> Backend<T, G16> for Bellman {
mod serialization {
use pairing::{from_hex, CurveAffine, Engine};
use proof_system::{G1Affine, G2Affine};
use crate::proof_system::{G1Affine, G2Affine};
use zokrates_field::BellmanFieldExtensions;
pub fn to_g1<T: BellmanFieldExtensions>(

View file

@ -205,7 +205,7 @@ mod parse {
use lazy_static::lazy_static;
use super::*;
use proof_system::{Fr, G1Affine, G2Affine};
use crate::proof_system::{Fr, G1Affine, G2Affine};
use regex::Regex;
lazy_static! {
@ -260,8 +260,8 @@ mod parse {
#[cfg(test)]
mod tests {
use super::*;
use crate::ir::Interpreter;
use crate::ir::{Function, LinComb};
use ir::Interpreter;
use zokrates_field::Bn128Field;
mod prove {

View file

@ -1,11 +1,11 @@
use ir::{Prog, Witness};
use proof_system::gm17::{ProofPoints, VerificationKey, GM17};
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::libsnark::{
use crate::ir::{Prog, Witness};
use crate::proof_system::gm17::{ProofPoints, VerificationKey, GM17};
use crate::proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use crate::proof_system::libsnark::{
prepare_generate_proof, prepare_public_inputs, prepare_setup, serialization::*, Libsnark,
};
use proof_system::Scheme;
use proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
use crate::proof_system::Scheme;
use crate::proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
use std::io::{BufReader, BufWriter, Write};
use zokrates_field::{Bn128Field, Field};

View file

@ -2,8 +2,8 @@ mod ffi;
pub mod gm17;
pub mod pghr13;
use flat_absy::FlatVariable;
use ir::{self, Statement};
use crate::flat_absy::FlatVariable;
use crate::ir::{self, Statement};
use std::cmp::max;
use std::collections::HashMap;
use zokrates_field::Field;
@ -305,7 +305,7 @@ pub fn r1cs_program<T: Field>(
}
pub mod serialization {
use proof_system::{G1Affine, G2Affine};
use crate::proof_system::{G1Affine, G2Affine};
use std::io::Read;
use std::io::Write;

View file

@ -1,13 +1,13 @@
use proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use proof_system::libsnark::{
use crate::proof_system::libsnark::ffi::{Buffer, ProofResult, SetupResult};
use crate::proof_system::libsnark::{
prepare_generate_proof, prepare_public_inputs, prepare_setup, Libsnark,
};
use proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
use crate::proof_system::{Backend, G1Affine, G2Affine, Proof, SetupKeypair};
use ir::{Prog, Witness};
use proof_system::libsnark::serialization::{read_g1, read_g2, write_g1, write_g2};
use proof_system::pghr13::{ProofPoints, VerificationKey, PGHR13};
use proof_system::Scheme;
use crate::ir::{Prog, Witness};
use crate::proof_system::libsnark::serialization::{read_g1, read_g2, write_g1, write_g2};
use crate::proof_system::pghr13::{ProofPoints, VerificationKey, PGHR13};
use crate::proof_system::Scheme;
use std::io::{BufReader, BufWriter, Write};
use zokrates_field::Bn128Field;
use zokrates_field::Field;

View file

@ -13,7 +13,7 @@ pub use self::solidity::*;
use crate::ir;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use zokrates_field::Field;
#[derive(Serialize)]
@ -34,6 +34,7 @@ pub struct Proof<T> {
pub inputs: Vec<String>,
}
#[allow(dead_code)]
impl<T: Serialize + DeserializeOwned> Proof<T> {
fn new(proof: T, inputs: Vec<String>) -> Self {
Proof { proof, inputs }

View file

@ -1,11 +1,12 @@
use proof_system::scheme::Scheme;
use proof_system::solidity::{
use crate::proof_system::scheme::Scheme;
use crate::proof_system::solidity::{
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use proof_system::{
use crate::proof_system::{
G1Affine, G2Affine, G2AffineFq, SolidityCompatibleField, SolidityCompatibleScheme,
};
use regex::Regex;
use serde::{Deserialize, Serialize};
use zokrates_field::{Bls12_377Field, Bls12_381Field, Bn128Field, Bw6_761Field, Field};
pub trait NotBw6_761Field {}

View file

@ -1,9 +1,10 @@
use proof_system::scheme::Scheme;
use proof_system::solidity::{
use crate::proof_system::scheme::Scheme;
use crate::proof_system::solidity::{
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
use crate::proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
use regex::Regex;
use serde::{Deserialize, Serialize};
use zokrates_field::Field;
pub struct G16;

View file

@ -1,9 +1,10 @@
use proof_system::scheme::Scheme;
use proof_system::solidity::{
use crate::proof_system::scheme::Scheme;
use crate::proof_system::solidity::{
SolidityAbi, SOLIDITY_G2_ADDITION_LIB, SOLIDITY_PAIRING_LIB, SOLIDITY_PAIRING_LIB_V2,
};
use proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
use crate::proof_system::{G1Affine, G2Affine, SolidityCompatibleField, SolidityCompatibleScheme};
use regex::Regex;
use serde::{Deserialize, Serialize};
use zokrates_field::Field;
pub struct PGHR13;

View file

@ -1,4 +1,4 @@
use proof_system::Scheme;
use crate::proof_system::Scheme;
use zokrates_field::{Bn128Field, Field};
pub trait SolidityCompatibleField: Field {}

View file

@ -18,8 +18,8 @@ use crate::parser::Position;
use crate::absy::types::{UnresolvedSignature, UnresolvedType, UserTypeId};
use crate::typed_absy::types::{FunctionKey, Signature, StructLocation, Type};
use crate::typed_absy::types::{ArrayType, StructMember};
use std::hash::{Hash, Hasher};
use typed_absy::types::{ArrayType, StructMember};
#[derive(PartialEq, Debug)]
pub struct ErrorInner {
@ -2378,9 +2378,9 @@ impl<'ast> Checker<'ast> {
#[cfg(test)]
mod tests {
use super::*;
use absy;
use crate::absy;
use crate::typed_absy;
use num_bigint::BigUint;
use typed_absy;
use zokrates_field::Bn128Field;
const MODULE_ID: &str = "";

View file

@ -1,3 +1,4 @@
use serde::{Deserialize, Serialize};
use std::fmt;
use zokrates_field::Field;

View file

@ -1,7 +1,7 @@
use crate::typed_absy;
use crate::typed_absy::types::{StructType, UBitwidth};
use crate::zir;
use std::marker::PhantomData;
use typed_absy;
use typed_absy::types::{StructType, UBitwidth};
use zir;
use zokrates_field::Field;
pub struct Flattener<T: Field> {
@ -302,7 +302,7 @@ pub fn fold_array_expression_inner<'ast, T: Field>(
assert_eq!(consequence.len(), alternative.len());
use zir::IfElse;
use crate::zir::IfElse;
consequence
.into_iter()
@ -390,7 +390,7 @@ pub fn fold_struct_expression_inner<'ast, T: Field>(
assert_eq!(consequence.len(), alternative.len());
use zir::IfElse;
use crate::zir::IfElse;
consequence
.into_iter()

View file

@ -16,9 +16,9 @@
//! where any call in `main` must be to `_SHA_256_ROUND` or `_UNPACK`
use crate::typed_absy::types::{FunctionKey, FunctionKeyHash, Type, UBitwidth};
use crate::typed_absy::{folder::*, *};
use std::collections::HashMap;
use typed_absy::types::{FunctionKey, FunctionKeyHash, Type, UBitwidth};
use typed_absy::{folder::*, *};
use zokrates_field::Field;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
@ -605,8 +605,8 @@ impl<'ast, T: Field> Folder<'ast, T> for Inliner<'ast, T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::typed_absy::types::{FunctionKey, Signature, Type};
use std::path::PathBuf;
use typed_absy::types::{FunctionKey, Signature, Type};
use zokrates_field::Bn128Field;
#[test]

View file

@ -28,7 +28,7 @@ use self::variable_access_remover::VariableAccessRemover;
use crate::flat_absy::FlatProg;
use crate::ir::Prog;
use crate::typed_absy::TypedProgram;
use zir::ZirProgram;
use crate::zir::ZirProgram;
use zokrates_field::Field;
pub trait Analyse {

View file

@ -19,9 +19,9 @@
//! In the case that a loop bound cannot be reduced to a constant, we detect it by noticing that the unroll does
//! not make progress anymore.
use static_analysis::propagation::Propagator;
use static_analysis::unroll::{Output, Unroller};
use typed_absy::TypedProgram;
use crate::static_analysis::propagation::Propagator;
use crate::static_analysis::unroll::{Output, Unroller};
use crate::typed_absy::TypedProgram;
use zokrates_field::Field;
pub struct PropagatedUnroller;
@ -61,8 +61,8 @@ impl PropagatedUnroller {
#[cfg(test)]
mod tests {
use super::*;
use typed_absy::types::{FunctionKey, Signature};
use typed_absy::*;
use crate::typed_absy::types::{FunctionKey, Signature};
use crate::typed_absy::*;
use zokrates_field::Bn128Field;
#[test]

View file

@ -11,10 +11,10 @@
//! @date 2018
use crate::typed_absy::folder::*;
use crate::typed_absy::types::Type;
use crate::typed_absy::*;
use std::collections::HashMap;
use std::convert::TryFrom;
use typed_absy::types::Type;
use zokrates_field::Field;
pub struct Propagator<'ast, T: Field> {

View file

@ -1,6 +1,6 @@
use typed_absy::folder::fold_statement;
use typed_absy::identifier::CoreIdentifier;
use typed_absy::*;
use crate::typed_absy::folder::fold_statement;
use crate::typed_absy::identifier::CoreIdentifier;
use crate::typed_absy::*;
use zokrates_field::Field;
pub struct ReturnBinder;

View file

@ -1,6 +1,6 @@
use crate::zir::folder::*;
use crate::zir::*;
use std::collections::HashMap;
use zir::folder::*;
use zokrates_field::Field;
#[derive(Default)]

View file

@ -1,7 +1,7 @@
use crate::flat_absy::FlatVariable;
use crate::ir::folder::Folder;
use crate::ir::Directive;
use crate::ir::Prog;
use flat_absy::FlatVariable;
use ir::folder::Folder;
use ir::Directive;
use std::collections::HashSet;
use zokrates_field::Field;
@ -54,9 +54,9 @@ impl<T: Field> Folder<T> for UnconstrainedVariableDetector {
#[cfg(test)]
mod tests {
use super::*;
use flat_absy::FlatVariable;
use ir::{Function, LinComb, Prog, QuadComb, Statement};
use solvers::Solver;
use crate::flat_absy::FlatVariable;
use crate::ir::{Function, LinComb, Prog, QuadComb, Statement};
use crate::solvers::Solver;
use zokrates_field::Bn128Field;
#[test]

View file

@ -5,11 +5,11 @@
//! @date 2018
use crate::typed_absy::folder::*;
use crate::typed_absy::identifier::CoreIdentifier;
use crate::typed_absy::types::{MemberId, Type};
use crate::typed_absy::*;
use std::collections::HashMap;
use std::collections::HashSet;
use typed_absy::identifier::CoreIdentifier;
use zokrates_field::Field;
pub enum Output<'ast, T: Field> {

View file

@ -10,7 +10,7 @@
//! if(index == 0, a[0], if(index == 1, a[1], ...))
//! ```
use typed_absy::{folder::*, *};
use crate::typed_absy::{folder::*, *};
use zokrates_field::Field;
pub struct VariableAccessRemover<'ast, T: Field> {

View file

@ -1,5 +1,5 @@
use typed_absy::types::Signature;
use typed_absy::Type;
use crate::typed_absy::{Signature, Type};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
pub struct AbiInput {
@ -29,12 +29,12 @@ impl Abi {
#[cfg(test)]
mod tests {
use super::*;
use std::collections::HashMap;
use typed_absy::types::{ArrayType, FunctionKey, StructMember, StructType};
use typed_absy::{
use crate::typed_absy::types::{ArrayType, FunctionKey, StructMember, StructType};
use crate::typed_absy::{
Parameter, Type, TypedFunction, TypedFunctionSymbol, TypedModule, TypedProgram, UBitwidth,
Variable,
};
use std::collections::HashMap;
use zokrates_field::Bn128Field;
#[test]

View file

@ -1,6 +1,6 @@
use crate::typed_absy::types::FunctionKeyHash;
use crate::typed_absy::TypedModuleId;
use std::fmt;
use typed_absy::types::FunctionKeyHash;
use typed_absy::TypedModuleId;
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
pub enum CoreIdentifier<'ast> {

View file

@ -18,18 +18,18 @@ pub use self::identifier::CoreIdentifier;
pub use self::parameter::Parameter;
pub use self::types::{Signature, StructType, Type, UBitwidth};
pub use self::variable::Variable;
pub use crate::typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
use std::path::PathBuf;
pub use typed_absy::uint::{bitwidth, UExpression, UExpressionInner, UMetadata};
use crate::embed::FlatEmbed;
use crate::typed_absy::types::{FunctionKey, MemberId};
use embed::FlatEmbed;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fmt;
use zokrates_field::Field;
pub use self::folder::Folder;
use typed_absy::abi::{Abi, AbiInput};
use crate::typed_absy::abi::{Abi, AbiInput};
pub use self::identifier::Identifier;

View file

@ -1,3 +1,4 @@
use serde::{de::Error, ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::path::{Path, PathBuf};

View file

@ -1,5 +1,5 @@
use typed_absy::types::{FunctionKey, UBitwidth};
use typed_absy::*;
use crate::typed_absy::types::{FunctionKey, UBitwidth};
use crate::typed_absy::*;
use zokrates_field::Field;
type Bitwidth = usize;

View file

@ -1,7 +1,7 @@
use crate::typed_absy::types::Type;
use crate::typed_absy::types::{StructType, UBitwidth};
use crate::typed_absy::Identifier;
use std::fmt;
use typed_absy::types::{StructType, UBitwidth};
#[derive(Clone, PartialEq, Hash, Eq)]
pub struct Variable<'ast> {

View file

@ -1,5 +1,5 @@
use typed_absy;
use zir;
use crate::typed_absy;
use crate::zir;
impl<'ast> From<typed_absy::types::FunctionKey<'ast>> for zir::types::FunctionKey<'ast> {
fn from(k: typed_absy::types::FunctionKey<'ast>) -> zir::types::FunctionKey<'ast> {

View file

@ -1,7 +1,7 @@
use crate::zir::types::MemberId;
use std::fmt;
use zir::types::MemberId;
use typed_absy::Identifier as CoreIdentifier;
use crate::typed_absy::Identifier as CoreIdentifier;
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
pub enum Identifier<'ast> {

View file

@ -9,14 +9,14 @@ mod variable;
pub use self::parameter::Parameter;
pub use self::types::Type;
pub use self::variable::Variable;
pub use crate::zir::uint::{ShouldReduce, UExpression, UExpressionInner, UMetadata};
use std::path::PathBuf;
pub use zir::uint::{ShouldReduce, UExpression, UExpressionInner, UMetadata};
use embed::FlatEmbed;
use crate::embed::FlatEmbed;
use crate::zir::types::{FunctionKey, Signature};
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fmt;
use zir::types::{FunctionKey, Signature};
use zokrates_field::Field;
pub use self::folder::Folder;

View file

@ -1,5 +1,5 @@
use crate::zir::Variable;
use std::fmt;
use zir::Variable;
#[derive(Clone, PartialEq)]
pub struct Parameter<'ast> {

View file

@ -1,3 +1,4 @@
use serde::{Deserialize, Serialize};
use std::fmt;
pub type Identifier<'ast> = &'ast str;

View file

@ -1,6 +1,6 @@
use zir::identifier::Identifier;
use zir::types::UBitwidth;
use zir::{BooleanExpression, FieldElementExpression};
use crate::zir::identifier::Identifier;
use crate::zir::types::UBitwidth;
use crate::zir::{BooleanExpression, FieldElementExpression};
use zokrates_field::Field;
impl<'ast, T: Field> UExpression<'ast, T> {

View file

@ -1,6 +1,6 @@
use crate::zir::types::{Type, UBitwidth};
use crate::zir::Identifier;
use std::fmt;
use zir::types::{Type, UBitwidth};
use zir::Identifier;
#[derive(Clone, PartialEq, Hash, Eq)]
pub struct Variable<'ast> {

View file

@ -4,7 +4,6 @@ prime_field!(
);
#[cfg(feature = "bellman")]
bellman_extensions!(
bellman_ce::pairing::bls12_381::Bls12,
bellman_ce::pairing::bls12_381::Fq2
);
use bellman_ce::pairing::bls12_381::{Bls12, Fq2};
#[cfg(feature = "ark")]
bellman_extensions!(Bls12, Fq2);

View file

@ -4,13 +4,14 @@ prime_field!(
);
#[cfg(feature = "bellman")]
bellman_extensions!(
bellman_ce::pairing::bn256::Bn256,
bellman_ce::pairing::bn256::Fq2
);
use bellman_ce::pairing::bn256::{Bn256, Fq2};
#[cfg(feature = "bellman")]
bellman_extensions!(Bn256, Fq2);
#[cfg(feature = "ark")]
ark_extensions!(ark_bn254::Bn254);
use ark_bn254::Bn254;
#[cfg(feature = "ark")]
ark_extensions!(Bn254);
#[cfg(test)]
mod tests {

View file

@ -4,4 +4,6 @@ prime_field!(
);
#[cfg(feature = "ark")]
ark_extensions!(ark_bw6_761::BW6_761);
use ark_bw6_761::BW6_761;
#[cfg(feature = "ark")]
ark_extensions!(BW6_761);