diff --git a/.circleci/config.yml b/.circleci/config.yml index e8ccd352f..0bfef41ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ executors: image: ubuntu-2004:202101-01 macos: macos: - xcode: 12.4.0 + xcode: 13.4.1 jobs: build: @@ -279,7 +279,7 @@ workflows: <<: *tag-only pre-steps: - install_rust - build-with: SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) cargo + build-with: SDKROOT=$(xcrun -sdk macosx12.3 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx12.3 --show-sdk-platform-version) cargo add-target: true matrix: alias: cross-build-apple-silicon diff --git a/.github/workflows/js-format-check.yml b/.github/workflows/js-format-check.yml new file mode 100644 index 000000000..f09fe5974 --- /dev/null +++ b/.github/workflows/js-format-check.yml @@ -0,0 +1,11 @@ +name: Check JS/JSON/TS format +on: [pull_request] +jobs: + js-format-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check format with prettier + uses: creyD/prettier_action@v4.2 + with: + prettier_options: --check ./**/*.{js,ts,json} diff --git a/CHANGELOG.md b/CHANGELOG.md index acd7b697b..42f323d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. ## [Unreleased] https://github.com/Zokrates/ZoKrates/compare/latest...develop +## [0.8.2] - 2022-09-05 + +### Release +- https://github.com/Zokrates/ZoKrates/releases/tag/0.8.2 + +### Changes +- Make return statement optional if no returns are expected (#1222, @dark64) +- Add a casting utility module to stdlib (#1215, @dark64) +- Introduce dead code elimination (#1206, @schaeff) +- Add magic square in javascript example to the book (#1198, @dark64) +- Fix circom r1cs export to avoid generating unverified proofs (#1220, @schaeff) +- Allow shadowing (#1193, @schaeff) + ## [0.8.1] - 2022-08-22 ### Release diff --git a/Cargo.lock b/Cargo.lock index dee108061..7e67221af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3026,7 +3026,7 @@ dependencies = [ [[package]] name = "zokrates_ast" -version = "0.1.1" +version = "0.1.2" dependencies = [ "ark-bls12-377", "cfg-if 0.1.10", @@ -3059,7 +3059,7 @@ dependencies = [ [[package]] name = "zokrates_circom" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bellman_ce", "byteorder", @@ -3072,7 +3072,7 @@ dependencies = [ [[package]] name = "zokrates_cli" -version = "0.8.1" +version = "0.8.2" dependencies = [ "assert_cli", "blake2 0.8.1", @@ -3087,6 +3087,7 @@ dependencies = [ "hex 0.3.2", "lazy_static", "log", + "pretty_assertions 1.2.1", "primitive-types", "rand 0.4.6", "rand 0.8.5", @@ -3117,7 +3118,7 @@ version = "0.1.1" [[package]] name = "zokrates_core" -version = "0.7.1" +version = "0.7.2" dependencies = [ "cfg-if 0.1.10", "csv", @@ -3141,7 +3142,7 @@ dependencies = [ [[package]] name = "zokrates_core_test" -version = "0.2.7" +version = "0.2.8" dependencies = [ "zokrates_test", "zokrates_test_derive", @@ -3241,7 +3242,7 @@ dependencies = [ [[package]] name = "zokrates_parser" -version = "0.3.1" +version = "0.3.2" dependencies = [ "glob 0.2.11", "pest", @@ -3292,7 +3293,7 @@ dependencies = [ [[package]] name = "zokrates_stdlib" -version = "0.3.1" +version = "0.3.2" dependencies = [ "fs_extra", "zokrates_test", diff --git a/README.md b/README.md index 1d07750a5..f86385577 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,12 @@ You can enable zokrates git hooks locally by running: ```sh git config core.hooksPath .githooks ``` + +### `{js,json,ts}` formatting + +We enforce strict formatting of `.{js,json,ts}` files in CI. This check is not included in the git hooks. If you modify such a file, you can ensure its formatting is correct by running: + +``` +npm i -g prettier +prettier --write "./**/*.{js,ts,json}" --ignore-path .gitignore +``` diff --git a/zokrates_ast/Cargo.toml b/zokrates_ast/Cargo.toml index cc022d0ac..46b068ef7 100644 --- a/zokrates_ast/Cargo.toml +++ b/zokrates_ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_ast" -version = "0.1.1" +version = "0.1.2" edition = "2021" [features] diff --git a/zokrates_ast/src/common/error.rs b/zokrates_ast/src/common/error.rs index f1d8b2d14..45ef04223 100644 --- a/zokrates_ast/src/common/error.rs +++ b/zokrates_ast/src/common/error.rs @@ -16,13 +16,11 @@ pub enum RuntimeError { BranchIsolation, ConstantLtBitness, ConstantLtSum, - LtBitness, - LtSum, - LtFinalBitness, LtFinalSum, LtSymetric, Or, Xor, + IncompleteDynamicRange, Inverse, Euclidean, ShaXor, @@ -37,6 +35,10 @@ impl From for RuntimeError { match error { crate::zir::RuntimeError::SourceAssertion(s) => RuntimeError::SourceAssertion(s), crate::zir::RuntimeError::SelectRangeCheck => RuntimeError::SelectRangeCheck, + crate::zir::RuntimeError::DivisionByZero => RuntimeError::Inverse, + crate::zir::RuntimeError::IncompleteDynamicRange => { + RuntimeError::IncompleteDynamicRange + } } } } @@ -47,7 +49,11 @@ impl RuntimeError { !matches!( self, - SourceAssertion(_) | Inverse | LtSum | SelectRangeCheck | ArgumentBitness + SourceAssertion(_) + | Inverse + | SelectRangeCheck + | ArgumentBitness + | IncompleteDynamicRange ) } } @@ -70,13 +76,13 @@ impl fmt::Display for RuntimeError { BranchIsolation => "Branch isolation failed", ConstantLtBitness => "Bitness check failed in constant Lt check", ConstantLtSum => "Sum check failed in constant Lt check", - LtBitness => "Bitness check failed in Lt check", - LtSum => "Sum check failed in Lt check", - LtFinalBitness => "Bitness check failed in final Lt check", LtFinalSum => "Sum check failed in final Lt check", LtSymetric => "Symetrical check failed in Lt check", Or => "Or check failed", Xor => "Xor check failed", + IncompleteDynamicRange => { + "Failed to compare field elements because dynamic comparison is incomplete" + } Inverse => "Division by zero", Euclidean => "Euclidean check failed", ShaXor => "Internal Sha check failed", diff --git a/zokrates_ast/src/ir/mod.rs b/zokrates_ast/src/ir/mod.rs index f2dab8e7c..bd068b891 100644 --- a/zokrates_ast/src/ir/mod.rs +++ b/zokrates_ast/src/ir/mod.rs @@ -188,15 +188,6 @@ impl fmt::Display for Prog { for s in &self.statements { writeln!(f, "\t{}", s)?; } - writeln!( - f, - "\treturn {}", - (0..self.return_count) - .map(Variable::public) - .map(|e| format!("{}", e)) - .collect::>() - .join(", ") - )?; writeln!(f, "\treturn {}", returns)?; writeln!(f, "}}") diff --git a/zokrates_ast/src/typed/folder.rs b/zokrates_ast/src/typed/folder.rs index e957768ad..e1e6d971e 100644 --- a/zokrates_ast/src/typed/folder.rs +++ b/zokrates_ast/src/typed/folder.rs @@ -264,6 +264,10 @@ pub trait Folder<'ast, T: Field>: Sized { fold_statement(self, s) } + fn fold_definition_rhs(&mut self, rhs: DefinitionRhs<'ast, T>) -> DefinitionRhs<'ast, T> { + fold_definition_rhs(self, rhs) + } + fn fold_embed_call(&mut self, e: EmbedCall<'ast, T>) -> EmbedCall<'ast, T> { fold_embed_call(self, e) } @@ -491,6 +495,16 @@ pub fn fold_constant_symbol_declaration<'ast, T: Field, F: Folder<'ast, T>>( } } +pub fn fold_definition_rhs<'ast, T: Field, F: Folder<'ast, T>>( + f: &mut F, + rhs: DefinitionRhs<'ast, T>, +) -> DefinitionRhs<'ast, T> { + match rhs { + DefinitionRhs::EmbedCall(c) => DefinitionRhs::EmbedCall(f.fold_embed_call(c)), + DefinitionRhs::Expression(e) => DefinitionRhs::Expression(f.fold_expression(e)), + } +} + pub fn fold_statement<'ast, T: Field, F: Folder<'ast, T>>( f: &mut F, s: TypedStatement<'ast, T>, @@ -498,7 +512,7 @@ pub fn fold_statement<'ast, T: Field, F: Folder<'ast, T>>( let res = match s { TypedStatement::Return(e) => TypedStatement::Return(f.fold_expression(e)), TypedStatement::Definition(a, e) => { - TypedStatement::Definition(f.fold_assignee(a), f.fold_expression(e)) + TypedStatement::Definition(f.fold_assignee(a), f.fold_definition_rhs(e)) } TypedStatement::Assertion(e, error) => { TypedStatement::Assertion(f.fold_boolean_expression(e), error) @@ -515,12 +529,6 @@ pub fn fold_statement<'ast, T: Field, F: Folder<'ast, T>>( TypedStatement::Log(s, e) => { TypedStatement::Log(s, e.into_iter().map(|e| f.fold_expression(e)).collect()) } - TypedStatement::EmbedCallDefinition(assignee, embed_call) => { - TypedStatement::EmbedCallDefinition( - f.fold_assignee(assignee), - f.fold_embed_call(embed_call), - ) - } s => s, }; vec![res] diff --git a/zokrates_ast/src/typed/identifier.rs b/zokrates_ast/src/typed/identifier.rs index 2eb64390d..abcd2f400 100644 --- a/zokrates_ast/src/typed/identifier.rs +++ b/zokrates_ast/src/typed/identifier.rs @@ -1,10 +1,11 @@ use crate::typed::CanonicalConstantIdentifier; -use std::convert::TryInto; use std::fmt; +pub type SourceIdentifier<'ast> = &'ast str; + #[derive(Debug, PartialEq, Clone, Hash, Eq, PartialOrd, Ord)] pub enum CoreIdentifier<'ast> { - Source(&'ast str), + Source(ShadowedIdentifier<'ast>), Call(usize), Constant(CanonicalConstantIdentifier<'ast>), Condition(usize), @@ -21,12 +22,6 @@ impl<'ast> fmt::Display for CoreIdentifier<'ast> { } } -impl<'ast> From<&'ast str> for CoreIdentifier<'ast> { - fn from(s: &str) -> CoreIdentifier { - CoreIdentifier::Source(s) - } -} - impl<'ast> From> for CoreIdentifier<'ast> { fn from(s: CanonicalConstantIdentifier<'ast>) -> CoreIdentifier<'ast> { CoreIdentifier::Constant(s) @@ -42,13 +37,24 @@ pub struct Identifier<'ast> { pub version: usize, } -impl<'ast> TryInto<&'ast str> for Identifier<'ast> { - type Error = (); +#[derive(Debug, PartialEq, Clone, Hash, Eq, PartialOrd, Ord)] +pub struct ShadowedIdentifier<'ast> { + pub id: SourceIdentifier<'ast>, + pub shadow: usize, +} + +impl<'ast> ShadowedIdentifier<'ast> { + pub fn shadow(id: SourceIdentifier<'ast>, shadow: usize) -> Self { + Self { id, shadow } + } +} - fn try_into(self) -> Result<&'ast str, Self::Error> { - match self.id { - CoreIdentifier::Source(i) => Ok(i), - _ => Err(()), +impl<'ast> fmt::Display for ShadowedIdentifier<'ast> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.shadow == 0 { + write!(f, "{}", self.id) + } else { + write!(f, "{}_{}", self.id, self.shadow) } } } @@ -69,21 +75,34 @@ impl<'ast> From> for Identifier<'ast> { } } -impl<'ast> From<&'ast str> for Identifier<'ast> { - fn from(id: &'ast str) -> Identifier<'ast> { - Identifier::from(CoreIdentifier::Source(id)) - } -} - impl<'ast> From> for Identifier<'ast> { fn from(id: CoreIdentifier<'ast>) -> Identifier<'ast> { Identifier { id, version: 0 } } } +impl<'ast> From> for CoreIdentifier<'ast> { + fn from(id: ShadowedIdentifier<'ast>) -> CoreIdentifier<'ast> { + CoreIdentifier::Source(id) + } +} + impl<'ast> Identifier<'ast> { pub fn version(mut self, version: usize) -> Self { self.version = version; self } } + +// these two From implementations are only used in tests but somehow cfg(test) doesn't work +impl<'ast> From<&'ast str> for CoreIdentifier<'ast> { + fn from(s: &str) -> CoreIdentifier { + CoreIdentifier::Source(ShadowedIdentifier::shadow(s, 0)) + } +} + +impl<'ast> From<&'ast str> for Identifier<'ast> { + fn from(id: &'ast str) -> Identifier<'ast> { + Identifier::from(CoreIdentifier::from(id)) + } +} diff --git a/zokrates_ast/src/typed/mod.rs b/zokrates_ast/src/typed/mod.rs index 9c3f5e129..a43f59bdb 100644 --- a/zokrates_ast/src/typed/mod.rs +++ b/zokrates_ast/src/typed/mod.rs @@ -16,7 +16,7 @@ pub mod types; mod uint; pub mod variable; -pub use self::identifier::CoreIdentifier; +pub use self::identifier::{CoreIdentifier, ShadowedIdentifier, SourceIdentifier}; pub use self::parameter::{DeclarationParameter, GParameter}; pub use self::types::{ CanonicalConstantIdentifier, ConcreteFunctionKey, ConcreteSignature, ConcreteTupleType, @@ -588,6 +588,7 @@ impl fmt::Display for AssertionMetadata { pub enum RuntimeError { SourceAssertion(AssertionMetadata), SelectRangeCheck, + DivisionByZero, } impl fmt::Display for RuntimeError { @@ -595,6 +596,7 @@ impl fmt::Display for RuntimeError { match self { RuntimeError::SourceAssertion(metadata) => write!(f, "{}", metadata), RuntimeError::SelectRangeCheck => write!(f, "Range check on array access"), + RuntimeError::DivisionByZero => write!(f, "Division by zero"), } } } @@ -646,12 +648,39 @@ impl<'ast, T: fmt::Display> fmt::Display for EmbedCall<'ast, T> { } } +#[derive(Clone, PartialEq, Debug, Hash, Eq, PartialOrd, Ord)] +pub enum DefinitionRhs<'ast, T> { + Expression(TypedExpression<'ast, T>), + EmbedCall(EmbedCall<'ast, T>), +} + +impl<'ast, T> From> for DefinitionRhs<'ast, T> { + fn from(e: TypedExpression<'ast, T>) -> Self { + Self::Expression(e) + } +} + +impl<'ast, T> From> for DefinitionRhs<'ast, T> { + fn from(c: EmbedCall<'ast, T>) -> Self { + Self::EmbedCall(c) + } +} + +impl<'ast, T: fmt::Display> fmt::Display for DefinitionRhs<'ast, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + DefinitionRhs::EmbedCall(c) => write!(f, "{}", c), + DefinitionRhs::Expression(e) => write!(f, "{}", e), + } + } +} + /// A statement in a `TypedFunction` #[allow(clippy::large_enum_variant)] #[derive(Clone, PartialEq, Debug, Hash, Eq, PartialOrd, Ord)] pub enum TypedStatement<'ast, T> { Return(TypedExpression<'ast, T>), - Definition(TypedAssignee<'ast, T>, TypedExpression<'ast, T>), + Definition(TypedAssignee<'ast, T>, DefinitionRhs<'ast, T>), Assertion(BooleanExpression<'ast, T>, RuntimeError), For( Variable<'ast, T>, @@ -660,7 +689,6 @@ pub enum TypedStatement<'ast, T> { Vec>, ), Log(FormatString, Vec>), - EmbedCallDefinition(TypedAssignee<'ast, T>, EmbedCall<'ast, T>), // Aux PushCallLog( DeclarationFunctionKey<'ast, T>, @@ -669,6 +697,16 @@ pub enum TypedStatement<'ast, T> { PopCallLog, } +impl<'ast, T> TypedStatement<'ast, T> { + pub fn definition(a: TypedAssignee<'ast, T>, e: TypedExpression<'ast, T>) -> Self { + Self::Definition(a, e.into()) + } + + pub fn embed_call_definition(a: TypedAssignee<'ast, T>, c: EmbedCall<'ast, T>) -> Self { + Self::Definition(a, c.into()) + } +} + impl<'ast, T: fmt::Display> TypedStatement<'ast, T> { fn fmt_indented(&self, f: &mut fmt::Formatter, depth: usize) -> fmt::Result { match self { @@ -710,9 +748,6 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedStatement<'ast, T> { } write!(f, "\t}}") } - TypedStatement::EmbedCallDefinition(ref lhs, ref rhs) => { - write!(f, "{} = {};", lhs, rhs) - } TypedStatement::Log(ref l, ref expressions) => write!( f, "log({}, {})", @@ -752,6 +787,12 @@ pub enum TypedExpression<'ast, T> { Int(IntExpression<'ast, T>), } +impl<'ast, T> TypedExpression<'ast, T> { + pub fn empty_tuple() -> TypedExpression<'ast, T> { + TypedExpression::Tuple(TupleExpressionInner::Value(vec![]).annotate(TupleType::new(vec![]))) + } +} + impl<'ast, T> From> for TypedExpression<'ast, T> { fn from(e: BooleanExpression<'ast, T>) -> TypedExpression { TypedExpression::Boolean(e) @@ -909,7 +950,7 @@ impl EqExpression { impl fmt::Display for EqExpression { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{} == {}", self.left, self.right) + write!(f, "({} == {})", self.left, self.right) } } @@ -1659,22 +1700,22 @@ impl<'ast, T: fmt::Display> fmt::Display for BooleanExpression<'ast, T> { match *self { BooleanExpression::Block(ref block) => write!(f, "{}", block,), BooleanExpression::Identifier(ref var) => write!(f, "{}", var), - BooleanExpression::FieldLt(ref lhs, ref rhs) => write!(f, "{} < {}", lhs, rhs), - BooleanExpression::FieldLe(ref lhs, ref rhs) => write!(f, "{} <= {}", lhs, rhs), - BooleanExpression::FieldGe(ref lhs, ref rhs) => write!(f, "{} >= {}", lhs, rhs), - BooleanExpression::FieldGt(ref lhs, ref rhs) => write!(f, "{} > {}", lhs, rhs), - BooleanExpression::UintLt(ref lhs, ref rhs) => write!(f, "{} < {}", lhs, rhs), - BooleanExpression::UintLe(ref lhs, ref rhs) => write!(f, "{} <= {}", lhs, rhs), - BooleanExpression::UintGe(ref lhs, ref rhs) => write!(f, "{} >= {}", lhs, rhs), - BooleanExpression::UintGt(ref lhs, ref rhs) => write!(f, "{} > {}", lhs, rhs), + BooleanExpression::FieldLt(ref lhs, ref rhs) => write!(f, "({} < {})", lhs, rhs), + BooleanExpression::FieldLe(ref lhs, ref rhs) => write!(f, "({} <= {})", lhs, rhs), + BooleanExpression::FieldGe(ref lhs, ref rhs) => write!(f, "({} >= {})", lhs, rhs), + BooleanExpression::FieldGt(ref lhs, ref rhs) => write!(f, "({} > {})", lhs, rhs), + BooleanExpression::UintLt(ref lhs, ref rhs) => write!(f, "({} < {})", lhs, rhs), + BooleanExpression::UintLe(ref lhs, ref rhs) => write!(f, "({} <= {})", lhs, rhs), + BooleanExpression::UintGe(ref lhs, ref rhs) => write!(f, "({} >= {})", lhs, rhs), + BooleanExpression::UintGt(ref lhs, ref rhs) => write!(f, "({} > {})", lhs, rhs), BooleanExpression::FieldEq(ref e) => write!(f, "{}", e), BooleanExpression::BoolEq(ref e) => write!(f, "{}", e), BooleanExpression::ArrayEq(ref e) => write!(f, "{}", e), BooleanExpression::StructEq(ref e) => write!(f, "{}", e), BooleanExpression::TupleEq(ref e) => write!(f, "{}", e), BooleanExpression::UintEq(ref e) => write!(f, "{}", e), - BooleanExpression::Or(ref lhs, ref rhs) => write!(f, "{} || {}", lhs, rhs), - BooleanExpression::And(ref lhs, ref rhs) => write!(f, "{} && {}", lhs, rhs), + BooleanExpression::Or(ref lhs, ref rhs) => write!(f, "({} || {})", lhs, rhs), + BooleanExpression::And(ref lhs, ref rhs) => write!(f, "({} && {})", lhs, rhs), BooleanExpression::Not(ref exp) => write!(f, "!{}", exp), BooleanExpression::Value(b) => write!(f, "{}", b), BooleanExpression::FunctionCall(ref function_call) => write!(f, "{}", function_call), diff --git a/zokrates_ast/src/typed/result_folder.rs b/zokrates_ast/src/typed/result_folder.rs index 4e9220543..fe6cd1577 100644 --- a/zokrates_ast/src/typed/result_folder.rs +++ b/zokrates_ast/src/typed/result_folder.rs @@ -385,6 +385,13 @@ pub trait ResultFolder<'ast, T: Field>: Sized { fold_statement(self, s) } + fn fold_definition_rhs( + &mut self, + rhs: DefinitionRhs<'ast, T>, + ) -> Result, Self::Error> { + fold_definition_rhs(self, rhs) + } + fn fold_embed_call( &mut self, e: EmbedCall<'ast, T>, @@ -508,7 +515,7 @@ pub fn fold_statement<'ast, T: Field, F: ResultFolder<'ast, T>>( let res = match s { TypedStatement::Return(e) => TypedStatement::Return(f.fold_expression(e)?), TypedStatement::Definition(a, e) => { - TypedStatement::Definition(f.fold_assignee(a)?, f.fold_expression(e)?) + TypedStatement::Definition(f.fold_assignee(a)?, f.fold_definition_rhs(e)?) } TypedStatement::Assertion(e, error) => { TypedStatement::Assertion(f.fold_boolean_expression(e)?, error) @@ -531,17 +538,21 @@ pub fn fold_statement<'ast, T: Field, F: ResultFolder<'ast, T>>( .map(|e| f.fold_expression(e)) .collect::, _>>()?, ), - TypedStatement::EmbedCallDefinition(assignee, embed_call) => { - TypedStatement::EmbedCallDefinition( - f.fold_assignee(assignee)?, - f.fold_embed_call(embed_call)?, - ) - } s => s, }; Ok(vec![res]) } +pub fn fold_definition_rhs<'ast, T: Field, F: ResultFolder<'ast, T>>( + f: &mut F, + rhs: DefinitionRhs<'ast, T>, +) -> Result, F::Error> { + Ok(match rhs { + DefinitionRhs::EmbedCall(c) => DefinitionRhs::EmbedCall(f.fold_embed_call(c)?), + DefinitionRhs::Expression(e) => DefinitionRhs::Expression(f.fold_expression(e)?), + }) +} + pub fn fold_embed_call<'ast, T: Field, F: ResultFolder<'ast, T>>( f: &mut F, e: EmbedCall<'ast, T>, diff --git a/zokrates_ast/src/typed/types.rs b/zokrates_ast/src/typed/types.rs index 18cd658c8..6d29da5cb 100644 --- a/zokrates_ast/src/typed/types.rs +++ b/zokrates_ast/src/typed/types.rs @@ -48,6 +48,13 @@ pub struct GenericIdentifier<'ast> { index: usize, } +impl<'ast> From> for CoreIdentifier<'ast> { + fn from(g: GenericIdentifier<'ast>) -> CoreIdentifier<'ast> { + // generic identifiers are always declared in the function scope, which is shadow 0 + CoreIdentifier::Source(ShadowedIdentifier::shadow(g.name(), 0)) + } +} + impl<'ast> GenericIdentifier<'ast> { pub fn without_name() -> Self { Self { @@ -228,8 +235,9 @@ impl<'ast, T> From for UExpression<'ast, T> { impl<'ast, T> From> for UExpression<'ast, T> { fn from(c: DeclarationConstant<'ast, T>) -> Self { match c { - DeclarationConstant::Generic(i) => { - UExpressionInner::Identifier(i.name().into()).annotate(UBitwidth::B32) + DeclarationConstant::Generic(g) => { + UExpressionInner::Identifier(CoreIdentifier::from(g).into()) + .annotate(UBitwidth::B32) } DeclarationConstant::Concrete(v) => { UExpressionInner::Value(v as u128).annotate(UBitwidth::B32) @@ -887,6 +895,10 @@ impl GType { pub fn uint>(b: W) -> Self { GType::Uint(b.into()) } + + pub fn is_empty_tuple(&self) -> bool { + matches!(self, GType::Tuple(ty) if ty.elements.is_empty()) + } } impl<'ast, T: fmt::Display + PartialEq + fmt::Debug> Type<'ast, T> { @@ -1215,6 +1227,8 @@ pub use self::signature::{ try_from_g_signature, ConcreteSignature, DeclarationSignature, GSignature, Signature, }; +use super::ShadowedIdentifier; + pub mod signature { use super::*; use std::fmt; diff --git a/zokrates_ast/src/typed/uint.rs b/zokrates_ast/src/typed/uint.rs index 51579e6b2..d993bdf1a 100644 --- a/zokrates_ast/src/typed/uint.rs +++ b/zokrates_ast/src/typed/uint.rs @@ -127,12 +127,6 @@ impl<'ast, T: Field> From for UExpressionInner<'ast, T> { } } -impl<'ast, T: Field> From<&'ast str> for UExpressionInner<'ast, T> { - fn from(e: &'ast str) -> Self { - UExpressionInner::Identifier(e.into()) - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct UMetadata { pub bitwidth: Option, diff --git a/zokrates_ast/src/zir/identifier.rs b/zokrates_ast/src/zir/identifier.rs index f010f2f8e..aae839d30 100644 --- a/zokrates_ast/src/zir/identifier.rs +++ b/zokrates_ast/src/zir/identifier.rs @@ -35,6 +35,7 @@ impl<'ast> fmt::Display for Identifier<'ast> { } } +// this is only used in tests but somehow cfg(test) does not work impl<'ast> From<&'ast str> for Identifier<'ast> { fn from(id: &'ast str) -> Identifier<'ast> { Identifier::Source(SourceIdentifier::Basic(id.into())) diff --git a/zokrates_ast/src/zir/mod.rs b/zokrates_ast/src/zir/mod.rs index 7420682ea..d2cbf6330 100644 --- a/zokrates_ast/src/zir/mod.rs +++ b/zokrates_ast/src/zir/mod.rs @@ -92,6 +92,8 @@ pub type ZirAssignee<'ast> = Variable<'ast>; pub enum RuntimeError { SourceAssertion(String), SelectRangeCheck, + DivisionByZero, + IncompleteDynamicRange, } impl fmt::Display for RuntimeError { @@ -99,6 +101,8 @@ impl fmt::Display for RuntimeError { match self { RuntimeError::SourceAssertion(message) => write!(f, "{}", message), RuntimeError::SelectRangeCheck => write!(f, "Range check on array access"), + RuntimeError::DivisionByZero => write!(f, "Division by zero"), + RuntimeError::IncompleteDynamicRange => write!(f, "Dynamic comparison is incomplete"), } } } @@ -716,7 +720,6 @@ impl<'ast, T> Conditional<'ast, T> for UExpression<'ast, T> { .annotate(bitwidth) } } - pub trait Select<'ast, T>: Sized { fn select(array: Vec, index: UExpression<'ast, T>) -> Self; } @@ -745,7 +748,6 @@ impl<'ast, T> Select<'ast, T> for UExpression<'ast, T> { UExpressionInner::Select(SelectExpression::new(array, index)).annotate(bitwidth) } } - pub trait IntoType { fn into_type(self) -> Type; } diff --git a/zokrates_ast/src/zir/uint.rs b/zokrates_ast/src/zir/uint.rs index d8252ee08..5d09b4285 100644 --- a/zokrates_ast/src/zir/uint.rs +++ b/zokrates_ast/src/zir/uint.rs @@ -85,12 +85,6 @@ impl<'ast, T: Field> From for UExpressionInner<'ast, T> { } } -impl<'ast, T: Field> From<&'ast str> for UExpressionInner<'ast, T> { - fn from(e: &'ast str) -> Self { - UExpressionInner::Identifier(e.into()) - } -} - impl<'ast, T> From for UExpression<'ast, T> { fn from(u: u32) -> Self { UExpressionInner::Value(u as u128).annotate(UBitwidth::B32) diff --git a/zokrates_book/src/SUMMARY.md b/zokrates_book/src/SUMMARY.md index cadcca3c3..298f90438 100644 --- a/zokrates_book/src/SUMMARY.md +++ b/zokrates_book/src/SUMMARY.md @@ -30,5 +30,6 @@ - [Examples](examples/index.md) - [A SNARK Powered RNG](examples/rng_tutorial.md) - [Proving knowledge of a hash preimage](examples/sha256example.md) + - [A ZK Magic Square in the browser](examples/magic_square.md) - [Testing](testing.md) diff --git a/zokrates_book/src/examples/magic_square.md b/zokrates_book/src/examples/magic_square.md new file mode 100644 index 000000000..1994e4c3f --- /dev/null +++ b/zokrates_book/src/examples/magic_square.md @@ -0,0 +1,7 @@ +# A ZK Magic Square in the browser + + \ No newline at end of file diff --git a/zokrates_book/src/gettingstarted.md b/zokrates_book/src/gettingstarted.md index b747d02f2..93caf96c2 100644 --- a/zokrates_book/src/gettingstarted.md +++ b/zokrates_book/src/gettingstarted.md @@ -2,9 +2,12 @@ ## Installation -### Remix online IDE +### Online IDEs + +To get a feel of the language, try the [ZoKrates playgound](https://play.zokrat.es). + +To experiment with creating SNARKs and verifying them in the EVM, check out the ZoKrates plugin in the [Remix online IDE](https://remix.ethereum.org). -To write your first SNARK program, check out the ZoKrates plugin in the [Remix online IDE](https://remix.ethereum.org)! ### One-line installation @@ -14,16 +17,6 @@ We provide one-line installation for Linux, MacOS and FreeBSD: curl -LSfs get.zokrat.es | sh ``` -### Docker - -ZoKrates is available on Dockerhub. - -```bash -docker run -ti zokrates/zokrates /bin/bash -``` - -From there on, you can use the `zokrates` CLI. - ### From source You can build ZoKrates from [source](https://github.com/ZoKrates/ZoKrates/) with the following commands: @@ -31,10 +24,21 @@ You can build ZoKrates from [source](https://github.com/ZoKrates/ZoKrates/) with ```bash git clone https://github.com/ZoKrates/ZoKrates cd ZoKrates +export ZOKRATES_STDLIB=$PWD/zokrates_stdlib/stdlib cargo +nightly build -p zokrates_cli --release cd target/release ``` +### Docker + +ZoKrates is available on Dockerhub. + +```bash +docker run -ti zokrates/zokrates /bin/bash +``` + +From there on, you can use the `zokrates` CLI. + ## Hello ZoKrates! First, create the text-file `root.zok` and implement your program. In this example, we will prove knowledge of the square root `a` of a number `b`: diff --git a/zokrates_book/src/language/functions.md b/zokrates_book/src/language/functions.md index 3a4872b88..a89b12689 100644 --- a/zokrates_book/src/language/functions.md +++ b/zokrates_book/src/language/functions.md @@ -1,13 +1,15 @@ ## Functions +Functions are declared using the `def` keyword. A function's signature has to be explicitly provided. +Its arguments are type annotated, just like variables, and, if the function returns a value, +the return type must be specified after an arrow `->`. + A function has to be declared at the top level before it is called. ```zokrates {{#include ../../../zokrates_cli/examples/book/function_declaration.zok}} ``` -A function's signature has to be explicitly provided. - A function can be generic over any number of values of type `u32`. ```zokrates @@ -18,4 +20,10 @@ The generic parameters can be provided explicitly, especially when they cannot b ```zokrates {{#include ../../../zokrates_cli/examples/book/explicit_generic_parameters.zok}} +``` + +If the return type of a function is the empty tuple `()`, the return type as well as the return statement can be omitted. + +```zokrates +{{#include ../../../zokrates_cli/examples/book/no_return.zok}} ``` \ No newline at end of file diff --git a/zokrates_book/src/language/variables.md b/zokrates_book/src/language/variables.md index 7b5eb6e76..dcbb91085 100644 --- a/zokrates_book/src/language/variables.md +++ b/zokrates_book/src/language/variables.md @@ -19,9 +19,9 @@ Variables are immutable by default. In order to declare a mutable variable, the ### Shadowing -Shadowing is not allowed. +Shadowing is allowed. ```zokrates -{{#include ../../../zokrates_cli/examples/book/no_shadowing.zok}} +{{#include ../../../zokrates_cli/examples/book/shadowing.zok}} ``` ### Scope diff --git a/zokrates_book/src/testing.md b/zokrates_book/src/testing.md index 752ef9f55..df9d16483 100644 --- a/zokrates_book/src/testing.md +++ b/zokrates_book/src/testing.md @@ -20,15 +20,6 @@ cargo test --release Integration tests are excluded from `cargo test` by default. They are defined in the `zokrates_cli` crate in `integration.rs` and use the test cases specified in `zokrates_cli/tests/code`. -Before running integration tests, make sure: -1. You have [solc](https://github.com/ethereum/solc-js) installed and in your `$PATH`. - - Solc can conveniently be installed through `npm` by running - ``` - npm install -g solc - ``` -2. You have an Ethereum node running on localhost with a JSON-RPC interface on the default port 8545 (`http://localhost:8545`). - Integration tests can then be run with the following command: ``` diff --git a/zokrates_book/src/toolbox/proving_schemes.md b/zokrates_book/src/toolbox/proving_schemes.md index 1c7330fa3..96be0fd7b 100644 --- a/zokrates_book/src/toolbox/proving_schemes.md +++ b/zokrates_book/src/toolbox/proving_schemes.md @@ -49,7 +49,7 @@ ZoKrates supports multiple backends. The options are the following: | Bellman | `--backend bellman` | G16 | ALTBN_128, BLS12_381 | | Ark | `--backend ark` | G16, GM17, MARLIN | ALTBN_128, BLS12_381, BLS12_377, BW6_761 | -Default: `bellman` +Default: `ark` When not using the default, the CLI flag has to be provided for the following commands: - `universal-setup` diff --git a/zokrates_circom/Cargo.toml b/zokrates_circom/Cargo.toml index 845aac443..d4ce79429 100644 --- a/zokrates_circom/Cargo.toml +++ b/zokrates_circom/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_circom" -version = "0.1.0" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zokrates_circom/src/r1cs.rs b/zokrates_circom/src/r1cs.rs index 0a96f8f10..8bdab0ac0 100644 --- a/zokrates_circom/src/r1cs.rs +++ b/zokrates_circom/src/r1cs.rs @@ -1,5 +1,5 @@ use byteorder::{LittleEndian, WriteBytesExt}; -use std::collections::HashMap; +use std::collections::{BTreeSet, HashMap}; use std::io::Result; use std::{io::Write, ops::Add}; use zokrates_ast::flat::Variable; @@ -65,6 +65,9 @@ pub fn r1cs_program(prog: Prog) -> (Vec, usize, Vec Some((quad, lin)), @@ -72,16 +75,21 @@ pub fn r1cs_program(prog: Prog) -> (Vec, usize, Vec None, }) { for (k, _) in &quad.left.0 { - provide_variable_idx(&mut variables, k); + ordered_variables_set.insert(k); } for (k, _) in &quad.right.0 { - provide_variable_idx(&mut variables, k); + ordered_variables_set.insert(k); } for (k, _) in &lin.0 { - provide_variable_idx(&mut variables, k); + ordered_variables_set.insert(k); } } + // create indices for the variables *in increasing order* + for variable in ordered_variables_set { + provide_variable_idx(&mut variables, variable); + } + let mut constraints = vec![]; // second pass to convert program to raw sparse vectors diff --git a/zokrates_cli/Cargo.toml b/zokrates_cli/Cargo.toml index c34f651e5..81e9a7472 100644 --- a/zokrates_cli/Cargo.toml +++ b/zokrates_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_cli" -version = "0.8.1" +version = "0.8.2" authors = ["Jacob Eberhardt ", "Dennis Kuhnert ", "Thibaut Schaeffer "] repository = "https://github.com/Zokrates/ZoKrates.git" edition = "2018" @@ -50,6 +50,7 @@ zokrates_solidity_test = { version = "0.1", path = "../zokrates_solidity_test", ethabi = "17.0.0" primitive-types = { version = "0.11", features = ["rlp"] } fs_extra = "1.1.0" +pretty_assertions = "1.2.1" [build-dependencies] fs_extra = "1.1.0" diff --git a/zokrates_cli/examples/book/no_return.zok b/zokrates_cli/examples/book/no_return.zok new file mode 100644 index 000000000..a4d866998 --- /dev/null +++ b/zokrates_cli/examples/book/no_return.zok @@ -0,0 +1 @@ +def main() {} \ No newline at end of file diff --git a/zokrates_cli/examples/book/no_shadowing.zok b/zokrates_cli/examples/book/no_shadowing.zok deleted file mode 100644 index 2aa41eac6..000000000 --- a/zokrates_cli/examples/book/no_shadowing.zok +++ /dev/null @@ -1,8 +0,0 @@ -def main() -> field { - field a = 2; - // field a = 3; <- not allowed - for u32 i in 0..5 { - // field a = 7; <- not allowed - } - return a; -} diff --git a/zokrates_cli/examples/book/shadowing.zok b/zokrates_cli/examples/book/shadowing.zok new file mode 100644 index 000000000..3c5c19823 --- /dev/null +++ b/zokrates_cli/examples/book/shadowing.zok @@ -0,0 +1,9 @@ +def main() -> field { + field a = 2; + field a = 3; // shadowing + for u32 i in 0..5 { + bool a = true; // shadowing + } + // `a` is the variable declared before the loop + return a; +} diff --git a/zokrates_cli/examples/compile_errors/no_return.zok b/zokrates_cli/examples/compile_errors/no_return.zok index 058212d5b..9480cf79d 100644 --- a/zokrates_cli/examples/compile_errors/no_return.zok +++ b/zokrates_cli/examples/compile_errors/no_return.zok @@ -1,5 +1 @@ -def foo() {} - -def main() { - return; -} +def main() -> field {} \ No newline at end of file diff --git a/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1.zok b/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1.zok index cc64d027e..52d730249 100644 --- a/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1.zok +++ b/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1.zok @@ -4,9 +4,10 @@ from "field" import FIELD_SIZE_IN_BITS; // It should not work for the maxvalue = 2^(pbits - 2) - 1 augmented by one // /!\ should be called with a = 0 -def main(field a) -> bool { +def main(field a) { u32 pbits = FIELD_SIZE_IN_BITS; // we added a = 0 to prevent the condition to be evaluated at compile time field maxvalue = a + (2**(pbits - 2) - 1); - return a < maxvalue + 1; + bool c = a < maxvalue + 1; + return; } diff --git a/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1_sym.zok b/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1_sym.zok index fe3fb4317..80df807dd 100644 --- a/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1_sym.zok +++ b/zokrates_cli/examples/runtime_errors/lt_overflow_max_plus_1_sym.zok @@ -4,9 +4,10 @@ from "field" import FIELD_SIZE_IN_BITS; // It should not work for the maxvalue = 2^(pbits - 2) - 1 augmented by one // /!\ should be called with a = 0 -def main(field a) -> bool { +def main(field a) { u32 pbits = FIELD_SIZE_IN_BITS; // we added a = 0 to prevent the condition to be evaluated at compile time field maxvalue = a + (2**(pbits - 2) - 1); - return maxvalue + 1 < a; + bool c = maxvalue + 1 < a; + return; } diff --git a/zokrates_cli/examples/compile_errors/shadowing.zok b/zokrates_cli/examples/shadowing.zok similarity index 100% rename from zokrates_cli/examples/compile_errors/shadowing.zok rename to zokrates_cli/examples/shadowing.zok diff --git a/zokrates_cli/tests/code/arithmetics.arguments.json b/zokrates_cli/tests/code/arithmetics.arguments.json index 70faac20f..1d6e5499e 100644 --- a/zokrates_cli/tests/code/arithmetics.arguments.json +++ b/zokrates_cli/tests/code/arithmetics.arguments.json @@ -1,4 +1 @@ -[ - "1", - "2" -] \ No newline at end of file +["1", "2"] diff --git a/zokrates_cli/tests/code/conditional_false.arguments.json b/zokrates_cli/tests/code/conditional_false.arguments.json index 45abfef65..d220209a8 100644 --- a/zokrates_cli/tests/code/conditional_false.arguments.json +++ b/zokrates_cli/tests/code/conditional_false.arguments.json @@ -1,3 +1 @@ -[ - "0" -] \ No newline at end of file +["0"] diff --git a/zokrates_cli/tests/code/conditional_true.arguments.json b/zokrates_cli/tests/code/conditional_true.arguments.json index 51ba4f971..90042dc91 100644 --- a/zokrates_cli/tests/code/conditional_true.arguments.json +++ b/zokrates_cli/tests/code/conditional_true.arguments.json @@ -1,3 +1 @@ -[ - "1" -] \ No newline at end of file +["1"] diff --git a/zokrates_cli/tests/code/multidim_update.arguments.json b/zokrates_cli/tests/code/multidim_update.arguments.json index 607a017d9..8d491ef30 100644 --- a/zokrates_cli/tests/code/multidim_update.arguments.json +++ b/zokrates_cli/tests/code/multidim_update.arguments.json @@ -1,12 +1,6 @@ [ - [ - [ - "0", - "0" - ], - [ - "0", - "0" - ] - ] -] \ No newline at end of file + [ + ["0", "0"], + ["0", "0"] + ] +] diff --git a/zokrates_cli/tests/code/n_choose_k.arguments.json b/zokrates_cli/tests/code/n_choose_k.arguments.json index 2ef9360d7..2a0167209 100644 --- a/zokrates_cli/tests/code/n_choose_k.arguments.json +++ b/zokrates_cli/tests/code/n_choose_k.arguments.json @@ -1,4 +1 @@ -[ - "5", - "1" -] \ No newline at end of file +["5", "1"] diff --git a/zokrates_cli/tests/code/no_return.arguments.json b/zokrates_cli/tests/code/no_return.arguments.json index 6d113a658..a9911e091 100644 --- a/zokrates_cli/tests/code/no_return.arguments.json +++ b/zokrates_cli/tests/code/no_return.arguments.json @@ -1,4 +1 @@ -[ - "1", - "1" -] \ No newline at end of file +["1", "1"] diff --git a/zokrates_cli/tests/code/return_array.arguments.json b/zokrates_cli/tests/code/return_array.arguments.json index 70ac3a6c2..cf2ac55f4 100644 --- a/zokrates_cli/tests/code/return_array.arguments.json +++ b/zokrates_cli/tests/code/return_array.arguments.json @@ -1,14 +1 @@ -[ - [ - "1", - "1", - "1" - ], - "2", - [ - "3", - "3", - "3", - "3" - ] -] \ No newline at end of file +[["1", "1", "1"], "2", ["3", "3", "3", "3"]] diff --git a/zokrates_cli/tests/code/simple_add.arguments.json b/zokrates_cli/tests/code/simple_add.arguments.json index 70faac20f..1d6e5499e 100644 --- a/zokrates_cli/tests/code/simple_add.arguments.json +++ b/zokrates_cli/tests/code/simple_add.arguments.json @@ -1,4 +1 @@ -[ - "1", - "2" -] \ No newline at end of file +["1", "2"] diff --git a/zokrates_cli/tests/code/simple_mul.arguments.json b/zokrates_cli/tests/code/simple_mul.arguments.json index f9ca65e0a..26e032c03 100644 --- a/zokrates_cli/tests/code/simple_mul.arguments.json +++ b/zokrates_cli/tests/code/simple_mul.arguments.json @@ -1,5 +1 @@ -[ - "2", - "3", - "4" -] \ No newline at end of file +["2", "3", "4"] diff --git a/zokrates_cli/tests/code/taxation.arguments.json b/zokrates_cli/tests/code/taxation.arguments.json index 030cb431f..50595013c 100644 --- a/zokrates_cli/tests/code/taxation.arguments.json +++ b/zokrates_cli/tests/code/taxation.arguments.json @@ -1,4 +1 @@ -[ - "15", - "12" -] \ No newline at end of file +["15", "12"] diff --git a/zokrates_cli/tests/code/taxation.smt2 b/zokrates_cli/tests/code/taxation.smt2 index e861790ce..7935ade77 100644 --- a/zokrates_cli/tests/code/taxation.smt2 +++ b/zokrates_cli/tests/code/taxation.smt2 @@ -523,7 +523,7 @@ (= (mod (* (+ (* |~one| 14651237294507013008273219182214280847718990358813499091232105186081237893121) (* |_0| 1) (* |_1| 21888242871839275222246405745257275088548364400416034343698204186575808495616)) (* |_258| 1)) |~prime|) (mod (* |_257| 1) |~prime|)) (= (mod (* (+ (* |~one| 1) (* |_257| 21888242871839275222246405745257275088548364400416034343698204186575808495616)) (+ (* |~one| 14651237294507013008273219182214280847718990358813499091232105186081237893121) (* |_0| 1) (* |_1| 21888242871839275222246405745257275088548364400416034343698204186575808495616))) |~prime|) (mod 0 |~prime|)) -(= (mod (* (* |~one| 1) 0) |~prime|) (mod (+ (* |~one| 1) (* |_257| 21888242871839275222246405745257275088548364400416034343698204186575808495616)) |~prime|)) +(= (mod (* (* |~one| 1) (* |~one| 1)) |~prime|) (mod (* |_257| 1) |~prime|)) (= (mod (* (* |_2| 1) (+ (* |_0| 21888242871839275222246405745257275088548364400416034343698204186575808495616) (* |_1| 1))) |~prime|) (mod (* |_264| 1) |~prime|)) (= (mod (* (* |~one| 1) (* |_264| 1)) |~prime|) (mod (* |~out_0| 1) |~prime|)) )) \ No newline at end of file diff --git a/zokrates_cli/tests/integration.rs b/zokrates_cli/tests/integration.rs index 7563a10bf..6ee737663 100644 --- a/zokrates_cli/tests/integration.rs +++ b/zokrates_cli/tests/integration.rs @@ -10,6 +10,7 @@ extern crate zokrates_solidity_test; mod integration { use fs_extra::copy_items; use fs_extra::dir::CopyOptions; + use pretty_assertions::assert_eq; use primitive_types::U256; use serde_json::from_reader; use std::fs; @@ -452,6 +453,8 @@ mod integration { program_path: &Path, expected_smtlib2_path: &Path, ) { + println!("test smtlib2 for {}", program_path.display()); + let tmp_dir = TempDir::new(program_name).unwrap(); let tmp_base = tmp_dir.path(); let test_case_path = tmp_base.join(program_name); diff --git a/zokrates_core/Cargo.toml b/zokrates_core/Cargo.toml index 183b10c54..c1f316f2f 100644 --- a/zokrates_core/Cargo.toml +++ b/zokrates_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_core" -version = "0.7.1" +version = "0.7.2" edition = "2018" authors = ["Jacob Eberhardt ", "Dennis Kuhnert "] repository = "https://github.com/Zokrates/ZoKrates" diff --git a/zokrates_core/src/flatten/mod.rs b/zokrates_core/src/flatten/mod.rs index 14bf1dc34..cd2e455c6 100644 --- a/zokrates_core/src/flatten/mod.rs +++ b/zokrates_core/src/flatten/mod.rs @@ -280,9 +280,29 @@ impl<'ast, T: Field> Flattener<'ast, T> { a: &[FlatExpression], b: &[bool], ) -> Vec> { - let len = b.len(); assert_eq!(a.len(), b.len()); + let is_power_of_two_minus_one = b.iter().all(|b| *b); + + // if `b` is all ones, then the check is always verified because that's the maximum possible value + if is_power_of_two_minus_one { + let statements: Vec<_> = a + .iter() + .map(|e| { + let e_id = self.define(e.clone(), statements_flattened); + FlatStatement::Condition( + e_id.into(), + FlatExpression::Mult(box e_id.into(), box e_id.into()), + RuntimeError::Bitness, + ) + }) + .collect(); + statements_flattened.extend(statements); + return vec![]; + } + + let len = b.len(); + let mut is_not_smaller_run = vec![]; let mut size_unknown = vec![]; @@ -778,66 +798,17 @@ impl<'ast, T: Field> Flattener<'ast, T> { let sub_width = bit_width + 1; - // define variables for the bits - let shifted_sub_bits_be: Vec = - (0..sub_width).map(|_| self.use_sym()).collect(); - - // add a directive to get the bits - statements_flattened.push_back(FlatStatement::Directive(FlatDirective::new( - shifted_sub_bits_be.clone(), - Solver::bits(sub_width), - vec![shifted_sub.clone()], - ))); - - // bitness checks - for bit in shifted_sub_bits_be.iter() { - statements_flattened.push_back(FlatStatement::Condition( - FlatExpression::Identifier(*bit), - FlatExpression::Mult( - box FlatExpression::Identifier(*bit), - box FlatExpression::Identifier(*bit), - ), - RuntimeError::LtFinalBitness, - )); - } - - // sum(sym_b{i} * 2**i) - let mut expr = FlatExpression::Number(T::from(0)); - - for (i, bit) in shifted_sub_bits_be.iter().take(sub_width).enumerate() { - expr = FlatExpression::Add( - box expr, - box FlatExpression::Mult( - box FlatExpression::Identifier(*bit), - box FlatExpression::Number(T::from(2).pow(sub_width - i - 1)), - ), - ); - } - - statements_flattened.push_back(FlatStatement::Condition( - shifted_sub, - expr, - RuntimeError::LtFinalSum, - )); - - // to make this check symetric, we ban the value `a - b == -2**N`, as the value `a - b == 2**N` is already banned - let fail = self.eq_check( + let shifted_sub_bits_be = self.get_bits_unchecked( + &FlatUExpression::with_field(shifted_sub), + sub_width, + sub_width, statements_flattened, - FlatExpression::Sub( - box FlatExpression::Identifier(rhs_id), - box FlatExpression::Identifier(lhs_id), - ), - FlatExpression::Number(T::from(2).pow(bit_width)), + RuntimeError::IncompleteDynamicRange, ); - statements_flattened.push_back(FlatStatement::Condition( - fail, - FlatExpression::Number(T::from(0)), - RuntimeError::LtSymetric, - )); FlatExpression::Sub( box FlatExpression::Number(T::one()), - box FlatExpression::Identifier(shifted_sub_bits_be[0]), + box shifted_sub_bits_be[0].clone(), ) } } @@ -1351,24 +1322,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { FlatExpression::Identifier(id) }; - // first check that the d is not 0 by giving its inverse - let invd = self.use_sym(); - - // # invd = 1/d - statements_flattened.push_back(FlatStatement::Directive(FlatDirective::new( - vec![invd], - Solver::Div, - vec![FlatExpression::Number(T::one()), d.clone()], - ))); - - // assert(invd * d == 1) - statements_flattened.push_back(FlatStatement::Condition( - FlatExpression::Number(T::one()), - FlatExpression::Mult(box invd.into(), box d.clone()), - RuntimeError::Inverse, - )); - - // now introduce the quotient and remainder + // introduce the quotient and remainder let q = self.use_sym(); let r = self.use_sym(); @@ -2163,22 +2117,10 @@ impl<'ast, T: Field> Flattener<'ast, T> { id.into() }; - let invb = self.use_sym(); - let inverse = self.use_sym(); - - // # invb = 1/b - statements_flattened.push_back(FlatStatement::Directive(FlatDirective::new( - vec![invb], - Solver::Div, - vec![FlatExpression::Number(T::one()), new_right.clone()], - ))); + // `right` is assumed to already be non-zero so this is an unchecked division + // TODO: we could save one constraint here by reusing the inverse of `right` computed earlier - // assert(invb * b == 1) - statements_flattened.push_back(FlatStatement::Condition( - FlatExpression::Number(T::one()), - FlatExpression::Mult(box invb.into(), box new_right.clone()), - RuntimeError::Inverse, - )); + let inverse = self.use_sym(); // # c = a/b statements_flattened.push_back(FlatStatement::Directive(FlatDirective::new( @@ -2458,6 +2400,40 @@ impl<'ast, T: Field> Flattener<'ast, T> { } } } + BooleanExpression::UintLe(box lhs, box rhs) => { + let lhs = self + .flatten_uint_expression(statements_flattened, lhs) + .get_field_unchecked(); + let rhs = self + .flatten_uint_expression(statements_flattened, rhs) + .get_field_unchecked(); + + match (lhs, rhs) { + (e, FlatExpression::Number(c)) => self.enforce_constant_le_check( + statements_flattened, + e, + c, + error.into(), + ), + // c <= e <=> p - 1 - e <= p - 1 - c + (FlatExpression::Number(c), e) => self.enforce_constant_le_check( + statements_flattened, + FlatExpression::Sub(box T::max_value().into(), box e), + T::max_value() - c, + error.into(), + ), + (lhs, rhs) => { + let bit_width = T::get_required_bits(); + let safe_width = bit_width - 2; // dynamic comparison is not complete + let e = self.le_check(statements_flattened, lhs, rhs, safe_width); + statements_flattened.push_back(FlatStatement::Condition( + e, + FlatExpression::Number(T::one()), + error.into(), + )); + } + } + } BooleanExpression::UintEq(box lhs, box rhs) => { let lhs = self .flatten_uint_expression(statements_flattened, lhs) @@ -2484,6 +2460,80 @@ impl<'ast, T: Field> Flattener<'ast, T> { error.into(), ) } + // `!(x == 0)` can be asserted by giving the inverse of `x` + BooleanExpression::Not(box BooleanExpression::UintEq( + box UExpression { + inner: UExpressionInner::Value(0), + .. + }, + box x, + )) + | BooleanExpression::Not(box BooleanExpression::UintEq( + box x, + box UExpression { + inner: UExpressionInner::Value(0), + .. + }, + )) => { + let x = self + .flatten_uint_expression(statements_flattened, x) + .get_field_unchecked(); + + // introduce intermediate variable + let x_id = self.define(x, statements_flattened); + + // check that `x` is not 0 by giving its inverse + let invx = self.use_sym(); + + // # invx = 1/x + statements_flattened.push_back(FlatStatement::Directive( + FlatDirective::new( + vec![invx], + Solver::Div, + vec![FlatExpression::Number(T::one()), x_id.into()], + ), + )); + + // assert(invx * x == 1) + statements_flattened.push_back(FlatStatement::Condition( + FlatExpression::Number(T::one()), + FlatExpression::Mult(box invx.into(), box x_id.into()), + RuntimeError::Inverse, + )); + } + // `!(x == 0)` can be asserted by giving the inverse of `x` + BooleanExpression::Not(box BooleanExpression::FieldEq( + box FieldElementExpression::Number(zero), + box x, + )) + | BooleanExpression::Not(box BooleanExpression::FieldEq( + box x, + box FieldElementExpression::Number(zero), + )) if zero == T::from(0) => { + let x = self.flatten_field_expression(statements_flattened, x); + + // introduce intermediate variable + let x_id = self.define(x, statements_flattened); + + // check that `x` is not 0 by giving its inverse + let invx = self.use_sym(); + + // # invx = 1/x + statements_flattened.push_back(FlatStatement::Directive( + FlatDirective::new( + vec![invx], + Solver::Div, + vec![FlatExpression::Number(T::one()), x_id.into()], + ), + )); + + // assert(invx * x == 1) + statements_flattened.push_back(FlatStatement::Condition( + FlatExpression::Number(T::one()), + FlatExpression::Mult(box invx.into(), box x_id.into()), + RuntimeError::Inverse, + )); + } e => { // naive approach: flatten the boolean to a single field element and constrain it to 1 let e = self.flatten_boolean_expression(statements_flattened, e); @@ -3580,18 +3630,14 @@ mod tests { // define new wires for members of Div let five = Variable::new(1); let b0 = Variable::new(2); - // Define inverse of denominator to prevent div by 0 - let invb0 = Variable::new(3); // Define inverse - let sym_0 = Variable::new(4); + let sym_0 = Variable::new(3); // Define result, which is first member to next Div - let sym_1 = Variable::new(5); + let sym_1 = Variable::new(4); // Define second member - let b1 = Variable::new(6); - // Define inverse of denominator to prevent div by 0 - let invb1 = Variable::new(7); + let b1 = Variable::new(5); // Define inverse - let sym_2 = Variable::new(8); + let sym_2 = Variable::new(6); assert_eq!( statements_flattened, @@ -3600,17 +3646,6 @@ mod tests { // inputs to first div (5/b) FlatStatement::Definition(five, FlatExpression::Number(Bn128Field::from(5))), FlatStatement::Definition(b0, b.into()), - // check div by 0 - FlatStatement::Directive(FlatDirective::new( - vec![invb0], - Solver::Div, - vec![FlatExpression::Number(Bn128Field::from(1)), b0.into()] - )), - FlatStatement::Condition( - FlatExpression::Number(Bn128Field::from(1)), - FlatExpression::Mult(box invb0.into(), box b0.into()), - RuntimeError::Inverse, - ), // execute div FlatStatement::Directive(FlatDirective::new( vec![sym_0], @@ -3625,17 +3660,6 @@ mod tests { // inputs to second div (res/b) FlatStatement::Definition(sym_1, sym_0.into()), FlatStatement::Definition(b1, b.into()), - // check div by 0 - FlatStatement::Directive(FlatDirective::new( - vec![invb1], - Solver::Div, - vec![FlatExpression::Number(Bn128Field::from(1)), b1.into()] - )), - FlatStatement::Condition( - FlatExpression::Number(Bn128Field::from(1)), - FlatExpression::Mult(box invb1.into(), box b1.into()), - RuntimeError::Inverse - ), // execute div FlatStatement::Directive(FlatDirective::new( vec![sym_2], diff --git a/zokrates_core/src/semantics.rs b/zokrates_core/src/semantics.rs index 750ffaf06..8e27f27fd 100644 --- a/zokrates_core/src/semantics.rs +++ b/zokrates_core/src/semantics.rs @@ -10,6 +10,7 @@ use std::fmt; use std::path::PathBuf; use zokrates_ast::common::FormatString; use zokrates_ast::typed::types::{GGenericsAssignment, GTupleType, GenericsAssignment}; +use zokrates_ast::typed::SourceIdentifier; use zokrates_ast::typed::*; use zokrates_ast::typed::{DeclarationParameter, DeclarationVariable, Variable}; use zokrates_ast::untyped::Identifier; @@ -18,7 +19,7 @@ use zokrates_field::Field; use zokrates_ast::untyped::types::{UnresolvedSignature, UnresolvedType, UserTypeId}; -use std::hash::{Hash, Hasher}; +use std::hash::Hash; use zokrates_ast::typed::types::{ check_type, specialize_declaration_type, ArrayType, DeclarationArrayType, DeclarationConstant, DeclarationFunctionKey, DeclarationSignature, DeclarationStructMember, DeclarationStructType, @@ -262,72 +263,67 @@ impl<'ast, T: Field> FunctionQuery<'ast, T> { } } -/// A scoped variable, so that we can delete all variables of a given scope when exiting it -#[derive(Clone, Debug)] -pub struct ScopedIdentifier<'ast> { - id: CoreIdentifier<'ast>, - level: usize, +#[derive(Debug, Clone)] +pub struct IdentifierInfo<'ast, T, U> { + id: U, + ty: Type<'ast, T>, + is_mutable: bool, } -impl<'ast> ScopedIdentifier<'ast> { - fn is_constant(&self) -> bool { - let res = self.level == 0; - - // currently this is encoded twice: in the level and in the identifier itself. - // we add a sanity check to make sure the two agree - assert_eq!(res, matches!(self.id, CoreIdentifier::Constant(..))); - - res - } +#[derive(Default, Debug)] +struct Scope<'ast, T> { + level: usize, + map: HashMap< + SourceIdentifier<'ast>, + BTreeMap>>, + >, } -/// Identifiers coming from constants or variables are equivalent -impl<'ast> PartialEq for ScopedIdentifier<'ast> { - fn eq(&self, other: &Self) -> bool { - let i0 = match &self.id { - CoreIdentifier::Source(id) => id, - CoreIdentifier::Constant(c) => c.id, - _ => unreachable!(), - }; +impl<'ast, T: Field> Scope<'ast, T> { + // insert into the scope and return whether we are shadowing an existing variable + fn insert( + &mut self, + id: SourceIdentifier<'ast>, + info: IdentifierInfo<'ast, T, CoreIdentifier<'ast>>, + ) -> bool { + let existed = self + .map + .get(&id) + .map(|versions| !versions.is_empty()) + .unwrap_or(false); + self.map.entry(id).or_default().insert(self.level, info); + + existed + } - let i1 = match &other.id { - CoreIdentifier::Source(id) => id, - CoreIdentifier::Constant(c) => c.id, - _ => unreachable!(), - }; + /// get the current version of this variable + fn get( + &self, + id: &SourceIdentifier<'ast>, + ) -> Option>> { + self.map + .get(id) + .and_then(|versions| versions.values().next_back().cloned()) + } - i0 == i1 + fn enter(&mut self) { + self.level += 1; } -} -/// Identifiers coming from constants or variables hash to the same result -impl<'ast> Hash for ScopedIdentifier<'ast> { - fn hash(&self, state: &mut H) { - match &self.id { - CoreIdentifier::Source(id) => id.hash(state), - CoreIdentifier::Constant(c) => c.id.hash(state), - _ => unreachable!(), + fn exit(&mut self) { + for versions in self.map.values_mut() { + versions.remove(&self.level); } + self.level -= 1; } } -impl<'ast> Eq for ScopedIdentifier<'ast> {} - -#[derive(Debug)] -pub struct IdentifierInfo<'ast, T> { - ty: Type<'ast, T>, - is_mutable: bool, -} - -type Scope<'ast, T> = HashMap, IdentifierInfo<'ast, T>>; - /// Checker checks the semantics of a program, keeping track of functions and variables in scope #[derive(Default)] pub struct Checker<'ast, T> { return_type: Option>, scope: Scope<'ast, T>, functions: HashSet>, - level: usize, } impl<'ast, T: Field> Checker<'ast, T> { @@ -692,13 +688,18 @@ impl<'ast, T: Field> Checker<'ast, T> { ) .into(), ); - self.insert_into_scope(Variable::immutable( - CoreIdentifier::Constant(CanonicalConstantIdentifier::new( + let id = declaration.id; + + let info = IdentifierInfo { + id: CoreIdentifier::Constant(CanonicalConstantIdentifier::new( declaration.id, module_id.into(), )), - c.get_type(), - )); + ty: c.get_type(), + is_mutable: false, + }; + assert_eq!(self.scope.level, 0); + assert!(!self.scope.insert(id, info)); assert!(state .constants .entry(module_id.to_path_buf()) @@ -883,10 +884,18 @@ impl<'ast, T: Field> Checker<'ast, T> { id.clone(), TypedConstantSymbol::There(imported_id) ).into()); - self.insert_into_scope(Variable::immutable(CoreIdentifier::Constant(CanonicalConstantIdentifier::new( - declaration.id, - module_id.into(), - )), zokrates_ast::typed::types::try_from_g_type(ty.clone()).unwrap())); + + let id = declaration.id; + let info = IdentifierInfo { + id: CoreIdentifier::Constant(CanonicalConstantIdentifier::new( + declaration.id, + module_id.into(), + )), + ty: zokrates_ast::typed::types::try_from_g_type(ty.clone()).unwrap(), + is_mutable: false, + }; + assert_eq!(self.scope.level, 0); + assert!(!self.scope.insert(id, info)); state .constants @@ -1071,11 +1080,19 @@ impl<'ast, T: Field> Checker<'ast, T> { }]), }?; - self.insert_into_scope(var.clone()); - Ok(var) } + fn id_in_this_scope(&self, id: SourceIdentifier<'ast>) -> CoreIdentifier<'ast> { + // in the semantic checker, 0 is top level, 1 is function level. For shadowing, we start with 0 at function level + // hence the offset of 1 + assert!( + self.scope.level > 0, + "CoreIdentifier cannot be declared in the global scope" + ); + CoreIdentifier::from(ShadowedIdentifier::shadow(id, self.scope.level - 1)) + } + fn check_function( &mut self, funct_node: FunctionNode<'ast>, @@ -1111,17 +1128,14 @@ impl<'ast, T: Field> Checker<'ast, T> { }; // for declaration signatures, generics cannot be ignored - - let v = Variable::immutable(generic.name(), Type::Uint(UBitwidth::B32)); - generics.0.insert( generic.clone(), - UExpressionInner::Identifier(generic.name().into()) + UExpressionInner::Identifier(self.id_in_this_scope(generic.name()).into()) .annotate(UBitwidth::B32), ); - // we don't have to check for conflicts here, because this was done when checking the signature - self.insert_into_scope(v.clone()); + //we don't have to check for conflicts here, because this was done when checking the signature + self.insert_into_scope(generic.name(), Type::Uint(UBitwidth::B32), false); } for (arg, decl_ty) in funct.arguments.into_iter().zip(s.inputs.iter()) { @@ -1130,7 +1144,7 @@ impl<'ast, T: Field> Checker<'ast, T> { let arg = arg.value; let decl_v = DeclarationVariable::new( - arg.id.value.id, + self.id_in_this_scope(arg.id.value.id), decl_ty.clone(), arg.id.value.is_mutable, ); @@ -1139,16 +1153,20 @@ impl<'ast, T: Field> Checker<'ast, T> { let ty = specialize_declaration_type(decl_v.clone()._type, &generics).unwrap(); - match self.insert_into_scope(zokrates_ast::typed::variable::Variable { - id: decl_v.clone().id, - _type: ty, + assert_eq!(self.scope.level, 1); + + let id = arg.id.value.id; + let info = IdentifierInfo { + id: decl_v.id.id.clone(), + ty, is_mutable, - }) { - true => {} - false => { + }; + match self.scope.insert(id, info) { + false => {} + true => { errors.push(ErrorInner { pos: Some(pos), - message: format!("Duplicate name in function definition: `{}` was previously declared as an argument or a generic constant", arg.id.value.id) + message: format!("Duplicate name in function definition: `{}` was previously declared as an argument, a generic parameter or a constant", arg.id.value.id) }); } }; @@ -1186,10 +1204,16 @@ impl<'ast, T: Field> Checker<'ast, T> { } if !found_return { - errors.push(ErrorInner { - pos: Some(pos), - message: "Expected a return statement".to_string(), - }); + match (&*s.output).is_empty_tuple() { + true => statements_checked + .push(TypedStatement::Return(TypedExpression::empty_tuple())), + false => { + errors.push(ErrorInner { + pos: Some(pos), + message: "Expected a return statement".to_string(), + }); + } + } } signature = Some(s); @@ -1622,10 +1646,16 @@ impl<'ast, T: Field> Checker<'ast, T> { module_id: &ModuleId, types: &TypeMap<'ast, T>, ) -> Result, Vec> { + let ty = self + .check_type(v.value._type, module_id, types) + .map_err(|e| vec![e])?; + + // insert into the scope and ignore whether shadowing happened + self.insert_into_scope(v.value.id, ty.clone(), v.value.is_mutable); + Ok(Variable::new( - v.value.id, - self.check_type(v.value._type, module_id, types) - .map_err(|e| vec![e])?, + self.id_in_this_scope(v.value.id), + ty, v.value.is_mutable, )) } @@ -1717,72 +1747,26 @@ impl<'ast, T: Field> Checker<'ast, T> { } // the assignee is already checked to be defined and mutable - fn check_assignment_inner( + fn check_rhs( &mut self, - assignee: TypedAssignee<'ast, T>, + return_type: Type<'ast, T>, expr: ExpressionNode<'ast>, - statement_pos: (Position, Position), module_id: &ModuleId, types: &TypeMap<'ast, T>, - ) -> Result, Vec> { - let assignee_type = assignee.get_type(); - + ) -> Result, ErrorInner> { match expr.value { - Expression::FunctionCall(box fun_id_expression, generics, arguments) => { - let e = self - .check_function_call_expression( - fun_id_expression, - generics, - arguments, - Some(assignee_type), - module_id, - types, - ) - .map_err(|e| vec![e])?; - Ok(TypedStatement::Definition(assignee, e)) - } - _ => { - // check the expression to be assigned - let checked_expr = self - .check_expression(expr, module_id, types) - .map_err(|e| vec![e])?; - - // make sure the assignee has the same type as the rhs - match assignee_type { - Type::FieldElement => FieldElementExpression::try_from_typed(checked_expr) - .map(TypedExpression::from), - Type::Boolean => { - BooleanExpression::try_from_typed(checked_expr).map(TypedExpression::from) - } - Type::Uint(bitwidth) => UExpression::try_from_typed(checked_expr, &bitwidth) - .map(TypedExpression::from), - Type::Array(ref array_ty) => { - ArrayExpression::try_from_typed(checked_expr, array_ty) - .map(TypedExpression::from) - } - Type::Struct(ref struct_ty) => { - StructExpression::try_from_typed(checked_expr, struct_ty) - .map(TypedExpression::from) - } - Type::Tuple(ref tuple_ty) => { - TupleExpression::try_from_typed(checked_expr, tuple_ty) - .map(TypedExpression::from) - } - Type::Int => Err(checked_expr), // Integers cannot be assigned - } - .map_err(|e| ErrorInner { - pos: Some(statement_pos), - message: format!( - "Expression `{}` of type `{}` cannot be assigned to `{}` of type `{}`", - e, - e.get_type(), - assignee.clone(), - assignee_type - ), - }) - .map(|rhs| TypedStatement::Definition(assignee, rhs)) - .map_err(|e| vec![e]) - } + // for function calls, check the rhs with the expected type + Expression::FunctionCall(box fun_id_expression, generics, arguments) => self + .check_function_call_expression( + fun_id_expression, + generics, + arguments, + Some(return_type), + module_id, + types, + ), + // otherwise, just check the rhs normally + _ => self.check_expression(expr, module_id, types), } } @@ -1865,11 +1849,7 @@ impl<'ast, T: Field> Checker<'ast, T> { } .map_err(|e| vec![e]) }) - .unwrap_or_else(|| { - Ok(TupleExpressionInner::Value(vec![]) - .annotate(TupleType::new(vec![])) - .into()) - })?; + .unwrap_or_else(|| Ok(TypedExpression::empty_tuple()))?; let res = match TypedExpression::align_to_type(e_checked.clone(), &return_type) .map_err(|e| { @@ -1910,27 +1890,106 @@ impl<'ast, T: Field> Checker<'ast, T> { Ok(res) } Statement::Definition(var, expr) => { - let var = self.check_variable(var, module_id, types)?; - match self.insert_into_scope(var.clone()) { - true => Ok(()), - false => Err(ErrorInner { - pos: Some(pos), - message: format!("Duplicate declaration for variable named {}", var.id), - }), - } - .map_err(|e| vec![e])?; + // get the lhs type + let var_ty = self + .check_type(var.value._type, module_id, types) + .map_err(|e| vec![e])?; + + // check the rhs based on the lhs type + let checked_expr = self + .check_rhs(var_ty.clone(), expr, module_id, types) + .map_err(|e| vec![e])?; - let assignee = TypedAssignee::Identifier(var); + // insert the lhs into the scope and ignore whether shadowing happened + self.insert_into_scope(var.value.id, var_ty.clone(), var.value.is_mutable); - self.check_assignment_inner(assignee, expr, pos, module_id, types) + let var = Variable::new( + self.id_in_this_scope(var.value.id), + var_ty.clone(), + var.value.is_mutable, + ); + + match var_ty { + Type::FieldElement => FieldElementExpression::try_from_typed(checked_expr) + .map(TypedExpression::from), + Type::Boolean => { + BooleanExpression::try_from_typed(checked_expr).map(TypedExpression::from) + } + Type::Uint(bitwidth) => UExpression::try_from_typed(checked_expr, &bitwidth) + .map(TypedExpression::from), + Type::Array(ref array_ty) => { + ArrayExpression::try_from_typed(checked_expr, array_ty) + .map(TypedExpression::from) + } + Type::Struct(ref struct_ty) => { + StructExpression::try_from_typed(checked_expr, struct_ty) + .map(TypedExpression::from) + } + Type::Tuple(ref tuple_ty) => { + TupleExpression::try_from_typed(checked_expr, tuple_ty) + .map(TypedExpression::from) + } + Type::Int => Err(checked_expr), // Integers cannot be assigned + } + .map_err(|e| ErrorInner { + pos: Some(pos), + message: format!( + "Expression `{}` of type `{}` cannot be assigned to `{}` of type `{}`", + e, + e.get_type(), + var.clone(), + var_ty + ), + }) + .map(|e| TypedStatement::Definition(var.into(), e.into())) + .map_err(|e| vec![e]) } Statement::Assignment(assignee, expr) => { // check that the assignee is declared, well formed and mutable - let var = self + let assignee = self .check_assignee(assignee, module_id, types) .map_err(|e| vec![e])?; - self.check_assignment_inner(var, expr, pos, module_id, types) + let assignee_ty = assignee.get_type(); + + let checked_expr = self + .check_rhs(assignee_ty.clone(), expr, module_id, types) + .map_err(|e| vec![e])?; + + match assignee_ty { + Type::FieldElement => FieldElementExpression::try_from_typed(checked_expr) + .map(TypedExpression::from), + Type::Boolean => { + BooleanExpression::try_from_typed(checked_expr).map(TypedExpression::from) + } + Type::Uint(bitwidth) => UExpression::try_from_typed(checked_expr, &bitwidth) + .map(TypedExpression::from), + Type::Array(ref array_ty) => { + ArrayExpression::try_from_typed(checked_expr, array_ty) + .map(TypedExpression::from) + } + Type::Struct(ref struct_ty) => { + StructExpression::try_from_typed(checked_expr, struct_ty) + .map(TypedExpression::from) + } + Type::Tuple(ref tuple_ty) => { + TupleExpression::try_from_typed(checked_expr, tuple_ty) + .map(TypedExpression::from) + } + Type::Int => Err(checked_expr), // Integers cannot be assigned + } + .map_err(|e| ErrorInner { + pos: Some(pos), + message: format!( + "Expression `{}` of type `{}` cannot be assigned to `{}` of type `{}`", + e, + e.get_type(), + assignee.clone(), + assignee_ty + ), + }) + .map(|e| TypedStatement::Definition(assignee, e.into())) + .map_err(|e| vec![e]) } Statement::Assertion(e, message) => { let e = self @@ -1978,18 +2037,14 @@ impl<'ast, T: Field> Checker<'ast, T> { let pos = assignee.pos(); // check that the assignee is declared match assignee.value { - Assignee::Identifier(variable_name) => match self.get_key_value_scope(variable_name) { - Some((id, info)) => match (id.is_constant(), info.is_mutable) { - (true, _) => Err(ErrorInner { - pos: Some(assignee.pos()), - message: format!("Assignment to constant variable `{}`", variable_name), - }), - (_, false) => Err(ErrorInner { + Assignee::Identifier(variable_name) => match self.scope.get(&variable_name) { + Some(info) => match info.is_mutable { + false => Err(ErrorInner { pos: Some(assignee.pos()), message: format!("Assignment to an immutable variable `{}`", variable_name), }), _ => Ok(TypedAssignee::Identifier(Variable::new( - variable_name, + info.id, info.ty.clone(), info.is_mutable, ))), @@ -2291,33 +2346,35 @@ impl<'ast, T: Field> Checker<'ast, T> { Expression::BooleanConstant(b) => Ok(BooleanExpression::Value(b).into()), Expression::Identifier(name) => { // check that `id` is defined in the scope - match self - .get_key_value_scope(name) - .map(|(x, y)| (x.clone(), y.ty.clone())) - { - Some((id, ty)) => match ty { - Type::Boolean => Ok(BooleanExpression::Identifier(id.id.into()).into()), - Type::Uint(bitwidth) => Ok(UExpressionInner::Identifier(id.id.into()) - .annotate(bitwidth) - .into()), - Type::FieldElement => { - Ok(FieldElementExpression::Identifier(id.id.into()).into()) - } - Type::Array(array_type) => { - Ok(ArrayExpressionInner::Identifier(id.id.into()) - .annotate(*array_type.ty, *array_type.size) - .into()) - } - Type::Struct(members) => { - Ok(StructExpressionInner::Identifier(id.id.into()) - .annotate(members) - .into()) + match self.scope.get(&name) { + Some(info) => { + let id = info.id; + match info.ty.clone() { + Type::Boolean => Ok(BooleanExpression::Identifier(id.into()).into()), + Type::Uint(bitwidth) => Ok(UExpressionInner::Identifier(id.into()) + .annotate(bitwidth) + .into()), + Type::FieldElement => { + Ok(FieldElementExpression::Identifier(id.into()).into()) + } + Type::Array(array_type) => { + Ok(ArrayExpressionInner::Identifier(id.into()) + .annotate(*array_type.ty, *array_type.size) + .into()) + } + Type::Struct(members) => { + Ok(StructExpressionInner::Identifier(id.into()) + .annotate(members) + .into()) + } + Type::Tuple(tuple_ty) => { + Ok(TupleExpressionInner::Identifier(id.into()) + .annotate(tuple_ty) + .into()) + } + Type::Int => unreachable!(), } - Type::Tuple(tuple_ty) => Ok(TupleExpressionInner::Identifier(id.id.into()) - .annotate(tuple_ty) - .into()), - Type::Int => unreachable!(), - }, + } None => Err(ErrorInner { pos: Some(pos), message: format!("Identifier \"{}\" is undefined", name), @@ -3551,29 +3608,18 @@ impl<'ast, T: Field> Checker<'ast, T> { } } - fn get_key_value_scope<'a>( - &'a self, - identifier: &'ast str, - ) -> Option<(&'a ScopedIdentifier<'ast>, &'a IdentifierInfo<'ast, T>)> { - self.scope.get_key_value(&ScopedIdentifier { - id: CoreIdentifier::Source(identifier), - level: 0, - }) - } - - fn insert_into_scope(&mut self, v: Variable<'ast, T>) -> bool { - self.scope - .insert( - ScopedIdentifier { - id: v.id.id, - level: self.level, - }, - IdentifierInfo { - ty: v._type, - is_mutable: v.is_mutable, - }, - ) - .is_none() + fn insert_into_scope( + &mut self, + id: SourceIdentifier<'ast>, + ty: Type<'ast, T>, + is_mutable: bool, + ) -> bool { + let info = IdentifierInfo { + id: self.id_in_this_scope(id), + ty, + is_mutable, + }; + self.scope.insert(id, info) } fn find_functions( @@ -3584,14 +3630,11 @@ impl<'ast, T: Field> Checker<'ast, T> { } fn enter_scope(&mut self) { - self.level += 1; + self.scope.enter(); } fn exit_scope(&mut self) { - let current_level = self.level; - self.scope - .retain(|scoped_variable, _| scoped_variable.level < current_level); - self.level -= 1; + self.scope.exit(); } } @@ -4312,15 +4355,13 @@ mod tests { } } - pub fn new_with_args<'ast, T: Field>( + fn new_with_args<'ast, T: Field>( scope: Scope<'ast, T>, - level: usize, functions: HashSet>, ) -> Checker<'ast, T> { Checker { scope, functions, - level, return_type: None, } } @@ -4432,21 +4473,20 @@ mod tests { let mut scope = Scope::default(); scope.insert( - ScopedIdentifier { - id: CoreIdentifier::Source("b"), - level: 1, - }, + "b", IdentifierInfo { + id: "b".into(), ty: Type::FieldElement, is_mutable: false, }, ); - let mut checker: Checker = new_with_args(scope, 1, HashSet::new()); + let mut checker: Checker = new_with_args(scope, HashSet::new()); + checker.enter_scope(); assert_eq!( checker.check_statement(statement, &*MODULE_ID, &TypeMap::new()), - Ok(TypedStatement::Definition( - TypedAssignee::Identifier(typed::Variable::field_element("a")), + Ok(TypedStatement::definition( + typed::Variable::field_element("a").into(), FieldElementExpression::Identifier("b".into()).into() )) ); @@ -4674,25 +4714,30 @@ mod tests { Statement::Return(None).mock(), ]; - let for_statements_checked = vec![TypedStatement::Definition( - TypedAssignee::Identifier(typed::Variable::uint("a", UBitwidth::B32)), - UExpressionInner::Identifier("i".into()) - .annotate(UBitwidth::B32) - .into(), + let for_statements_checked = vec![TypedStatement::definition( + typed::Variable::uint( + CoreIdentifier::Source(ShadowedIdentifier::shadow("a", 1)), + UBitwidth::B32, + ) + .into(), + UExpressionInner::Identifier( + CoreIdentifier::Source(ShadowedIdentifier::shadow("i", 1)).into(), + ) + .annotate(UBitwidth::B32) + .into(), )]; let foo_statements_checked = vec![ TypedStatement::For( - typed::Variable::uint("i", UBitwidth::B32), + typed::Variable::uint( + CoreIdentifier::Source(ShadowedIdentifier::shadow("i", 1)), + UBitwidth::B32, + ), 0u32.into(), 10u32.into(), for_statements_checked, ), - TypedStatement::Return( - TupleExpressionInner::Value(vec![]) - .annotate(TupleType::new(vec![])) - .into(), - ), + TypedStatement::Return(TypedExpression::empty_tuple()), ]; let foo = Function { @@ -4758,7 +4803,7 @@ mod tests { let modules = Modules::new(); let state = State::new(modules); - let mut checker: Checker = new_with_args(HashMap::new(), 0, functions); + let mut checker: Checker = new_with_args(Scope::default(), functions); assert_eq!( checker.check_function(bar, &*MODULE_ID, &state), Err(vec![ErrorInner { @@ -4797,7 +4842,7 @@ mod tests { let modules = Modules::new(); let state = State::new(modules); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert_eq!( checker.check_function(bar, &*MODULE_ID, &state), Err(vec![ErrorInner { @@ -4870,7 +4915,7 @@ mod tests { let mut state = State::::new(vec![((*MODULE_ID).clone(), module)].into_iter().collect()); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert_eq!( checker.check_module(&*MODULE_ID, &mut state), Err(vec![Error { @@ -4966,7 +5011,7 @@ mod tests { let mut state = State::::new(vec![((*MODULE_ID).clone(), module)].into_iter().collect()); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert!(checker.check_module(&*MODULE_ID, &mut state).is_ok()); } @@ -5006,7 +5051,7 @@ mod tests { let modules = Modules::new(); let state = State::new(modules); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert_eq!( checker.check_function(bar, &*MODULE_ID, &state), Err(vec![ErrorInner { @@ -5039,7 +5084,7 @@ mod tests { let modules = Modules::new(); let state = State::new(modules); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert_eq!( checker.check_function(bar, &*MODULE_ID, &state), Err(vec![ErrorInner { @@ -5076,13 +5121,13 @@ mod tests { let modules = Modules::new(); let state = State::new(modules); - let mut checker: Checker = new_with_args(HashMap::new(), 0, HashSet::new()); + let mut checker: Checker = new_with_args(Scope::default(), HashSet::new()); assert_eq!( checker .check_function(f, &*MODULE_ID, &state) .unwrap_err()[0] .message, - "Duplicate name in function definition: `a` was previously declared as an argument or a generic constant" + "Duplicate name in function definition: `a` was previously declared as an argument, a generic parameter or a constant" ); } @@ -5163,25 +5208,20 @@ mod tests { ); } - #[test] - fn shadowing_with_same_type() { - // field a = 2; - // field a = 2; - // - // should fail + mod shadowing { - let mut checker: Checker = Checker::default(); - let _: Result, Vec> = checker.check_statement( - Statement::Definition( - untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(), - untyped::Expression::IntConstant(2usize.into()).mock(), - ) - .mock(), - &*MODULE_ID, - &TypeMap::new(), - ); - let s2_checked: Result, Vec> = checker - .check_statement( + use super::*; + + #[test] + fn same_type() { + // field a = 2; + // field a = 2; + // + // should succeed + + let mut checker: Checker = Checker::default(); + checker.enter_scope(); + let _: Result, Vec> = checker.check_statement( Statement::Definition( untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(), untyped::Expression::IntConstant(2usize.into()).mock(), @@ -5190,49 +5230,169 @@ mod tests { &*MODULE_ID, &TypeMap::new(), ); - assert_eq!( - s2_checked, - Err(vec![ErrorInner { - pos: Some((Position::mock(), Position::mock())), - message: "Duplicate declaration for variable named a".into() - }]) - ); - } + let s2_checked: Result, Vec> = checker + .check_statement( + Statement::Definition( + untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()) + .mock(), + untyped::Expression::IntConstant(2usize.into()).mock(), + ) + .mock(), + &*MODULE_ID, + &TypeMap::new(), + ); + assert!(s2_checked.is_ok()); + } - #[test] - fn shadowing_with_different_type() { - // field a = 2; - // bool a = true; - // - // should fail + #[test] + fn different_type() { + // field a = 2; + // bool a = true; + // + // should succeed - let mut checker: Checker = Checker::default(); - let _: Result, Vec> = checker.check_statement( - Statement::Definition( - untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(), - untyped::Expression::IntConstant(2usize.into()).mock(), - ) - .mock(), - &*MODULE_ID, - &TypeMap::new(), - ); - let s2_checked: Result, Vec> = checker - .check_statement( + let mut checker: Checker = Checker::default(); + checker.enter_scope(); + let _: Result, Vec> = checker.check_statement( Statement::Definition( - untyped::Variable::immutable("a", UnresolvedType::Boolean.mock()).mock(), - untyped::Expression::BooleanConstant(true).mock(), + untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()).mock(), + untyped::Expression::IntConstant(2usize.into()).mock(), ) .mock(), &*MODULE_ID, &TypeMap::new(), ); - assert_eq!( - s2_checked, - Err(vec![ErrorInner { - pos: Some((Position::mock(), Position::mock())), - message: "Duplicate declaration for variable named a".into() - }]) - ); + let s2_checked: Result, Vec> = checker + .check_statement( + Statement::Definition( + untyped::Variable::immutable("a", UnresolvedType::Boolean.mock()).mock(), + untyped::Expression::BooleanConstant(true).mock(), + ) + .mock(), + &*MODULE_ID, + &TypeMap::new(), + ); + assert!(s2_checked.is_ok()); + assert_eq!( + checker.scope.get(&"a").unwrap().ty, + DeclarationType::Boolean + ); + } + + #[test] + fn scopes() { + // field mut a = 2; + // for uint i in 0..0 { + // a = 3 + // field a = 4 + // } + // a = 5 + // + // should be turned into + // + // field mut a_0 = 2; + // for uint i_1 in 0..0 { + // a_0 = 3 + // field a_1 = 4 + // } + // a_0 = 5 + + let mut checker: Checker = Checker::default(); + + let statements = vec![ + Statement::Definition( + untyped::Variable::mutable("a", UnresolvedType::FieldElement.mock()).mock(), + untyped::Expression::IntConstant(2usize.into()).mock(), + ) + .mock(), + Statement::For( + untyped::Variable::immutable("i", UnresolvedType::Uint(32).mock()).mock(), + untyped::Expression::U32Constant(0).mock(), + untyped::Expression::U32Constant(0).mock(), + vec![ + Statement::Assignment( + untyped::Assignee::Identifier("a").mock(), + untyped::Expression::IntConstant(3usize.into()).mock(), + ) + .mock(), + Statement::Definition( + untyped::Variable::immutable("a", UnresolvedType::FieldElement.mock()) + .mock(), + untyped::Expression::IntConstant(4usize.into()).mock(), + ) + .mock(), + ], + ) + .mock(), + Statement::Assignment( + untyped::Assignee::Identifier("a").mock(), + untyped::Expression::IntConstant(5usize.into()).mock(), + ) + .mock(), + ]; + + let expected = vec![ + TypedStatement::definition( + typed::Variable::new( + CoreIdentifier::from(ShadowedIdentifier::shadow("a", 0)), + Type::FieldElement, + true, + ) + .into(), + FieldElementExpression::Number(2.into()).into(), + ), + TypedStatement::For( + typed::Variable::new( + CoreIdentifier::from(ShadowedIdentifier::shadow("i", 1)), + Type::Uint(UBitwidth::B32), + false, + ), + 0u32.into(), + 0u32.into(), + vec![ + TypedStatement::definition( + typed::Variable::new( + CoreIdentifier::from(ShadowedIdentifier::shadow("a", 0)), + Type::FieldElement, + true, + ) + .into(), + FieldElementExpression::Number(3.into()).into(), + ), + TypedStatement::definition( + typed::Variable::new( + CoreIdentifier::from(ShadowedIdentifier::shadow("a", 1)), + Type::FieldElement, + false, + ) + .into(), + FieldElementExpression::Number(4.into()).into(), + ), + ], + ), + TypedStatement::definition( + typed::Variable::new( + CoreIdentifier::from(ShadowedIdentifier::shadow("a", 0)), + Type::FieldElement, + true, + ) + .into(), + FieldElementExpression::Number(5.into()).into(), + ), + ]; + + checker.enter_scope(); + let checked: Vec<_> = statements + .into_iter() + .map(|s| { + checker + .check_statement(s, &*MODULE_ID, &TypeMap::default()) + .unwrap() + }) + .collect(); + + assert_eq!(checked, expected); + } } mod structs { diff --git a/zokrates_core/src/static_analysis/condition_redefiner.rs b/zokrates_core/src/static_analysis/condition_redefiner.rs index 0820345f9..b34ed1a57 100644 --- a/zokrates_core/src/static_analysis/condition_redefiner.rs +++ b/zokrates_core/src/static_analysis/condition_redefiner.rs @@ -1,7 +1,7 @@ use zokrates_ast::typed::{ folder::*, BlockExpression, BooleanExpression, Conditional, ConditionalExpression, - ConditionalOrExpression, CoreIdentifier, Expr, Identifier, Type, TypedProgram, TypedStatement, - Variable, + ConditionalOrExpression, CoreIdentifier, Expr, Identifier, Type, TypedExpression, TypedProgram, + TypedStatement, Variable, }; use zokrates_field::Field; @@ -65,9 +65,9 @@ impl<'ast, T: Field> Folder<'ast, T> for ConditionRedefiner<'ast, T> { | condition @ BooleanExpression::Identifier(_) => condition, condition => { let condition_id = Identifier::from(CoreIdentifier::Condition(self.index)); - self.buffer.push(TypedStatement::Definition( + self.buffer.push(TypedStatement::definition( Variable::immutable(condition_id.clone(), Type::Boolean).into(), - condition.into(), + TypedExpression::from(condition), )); self.index += 1; BooleanExpression::Identifier(condition_id) @@ -99,7 +99,7 @@ mod tests { // field foo = if true { 1 } else { 2 }; // should be left unchanged - let s = TypedStatement::Definition( + let s = TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( BooleanExpression::Value(true), @@ -120,7 +120,7 @@ mod tests { // field foo = if c { 1 } else { 2 }; // should be left unchanged - let s = TypedStatement::Definition( + let s = TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( BooleanExpression::Identifier("c".into()), @@ -148,7 +148,7 @@ mod tests { box BooleanExpression::Identifier("d".into()), ); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( condition.clone(), @@ -163,12 +163,12 @@ mod tests { let expected = vec![ // define condition - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(0), Type::Boolean).into(), condition.into(), ), // rewrite statement - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( BooleanExpression::Identifier(CoreIdentifier::Condition(0).into()), @@ -212,7 +212,7 @@ mod tests { box BooleanExpression::Identifier("f".into()), ); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( condition_0.clone(), @@ -232,16 +232,16 @@ mod tests { let expected = vec![ // define conditions - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(0), Type::Boolean).into(), condition_0.into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(1), Type::Boolean).into(), condition_1.into(), ), // rewrite statement - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( BooleanExpression::Identifier(CoreIdentifier::Condition(0).into()), @@ -303,12 +303,12 @@ mod tests { let condition_id_1 = BooleanExpression::Identifier(CoreIdentifier::Condition(1).into()); let condition_id_2 = BooleanExpression::Identifier(CoreIdentifier::Condition(2).into()); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( condition_0.clone(), FieldElementExpression::block( - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Number(Bn128Field::from(1)).into(), )], @@ -320,7 +320,7 @@ mod tests { ), ), FieldElementExpression::block( - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("b").into(), FieldElementExpression::Number(Bn128Field::from(2)).into(), )], @@ -340,22 +340,22 @@ mod tests { let expected = vec![ // define conditions - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(0), Type::Boolean).into(), condition_0.into(), ), // rewrite statement - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("foo").into(), FieldElementExpression::conditional( condition_id_0.clone(), FieldElementExpression::block( vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Number(Bn128Field::from(1)).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(1), Type::Boolean) .into(), condition_1.into(), @@ -370,11 +370,11 @@ mod tests { ), FieldElementExpression::block( vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("b").into(), FieldElementExpression::Number(Bn128Field::from(2)).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::immutable(CoreIdentifier::Condition(2), Type::Boolean) .into(), condition_2.into(), diff --git a/zokrates_core/src/static_analysis/constant_argument_checker.rs b/zokrates_core/src/static_analysis/constant_argument_checker.rs index 6a1bf7d1b..c7ee629a3 100644 --- a/zokrates_core/src/static_analysis/constant_argument_checker.rs +++ b/zokrates_core/src/static_analysis/constant_argument_checker.rs @@ -1,11 +1,11 @@ use std::fmt; use zokrates_ast::common::FlatEmbed; -use zokrates_ast::typed::TypedProgram; use zokrates_ast::typed::{ result_folder::ResultFolder, result_folder::{fold_statement, fold_uint_expression_inner}, Constant, EmbedCall, TypedStatement, UBitwidth, UExpressionInner, }; +use zokrates_ast::typed::{DefinitionRhs, TypedProgram}; use zokrates_field::Field; pub struct ConstantArgumentChecker; @@ -33,37 +33,41 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ConstantArgumentChecker { s: TypedStatement<'ast, T>, ) -> Result>, Self::Error> { match s { - TypedStatement::EmbedCallDefinition(assignee, embed_call) => match embed_call { - EmbedCall { - embed: FlatEmbed::BitArrayLe, - .. - } => { - let arguments = embed_call - .arguments - .into_iter() - .map(|a| self.fold_expression(a)) - .collect::, _>>()?; + TypedStatement::Definition(assignee, DefinitionRhs::EmbedCall(embed_call)) => { + match embed_call { + EmbedCall { + embed: FlatEmbed::BitArrayLe, + .. + } => { + let arguments = embed_call + .arguments + .into_iter() + .map(|a| self.fold_expression(a)) + .collect::, _>>()?; - if arguments[1].is_constant() { - Ok(vec![TypedStatement::EmbedCallDefinition( - assignee, - EmbedCall { - embed: FlatEmbed::BitArrayLe, - generics: embed_call.generics, - arguments, - }, - )]) - } else { - Err(Error(format!( - "Cannot compare to a variable value, found `{}`", - arguments[1] - ))) + if arguments[1].is_constant() { + Ok(vec![TypedStatement::Definition( + assignee, + EmbedCall { + embed: FlatEmbed::BitArrayLe, + generics: embed_call.generics, + arguments, + } + .into(), + )]) + } else { + Err(Error(format!( + "Cannot compare to a variable value, found `{}`", + arguments[1] + ))) + } } + embed_call => Ok(vec![TypedStatement::Definition( + assignee, + embed_call.into(), + )]), } - embed_call => Ok(vec![TypedStatement::EmbedCallDefinition( - assignee, embed_call, - )]), - }, + } s => fold_statement(self, s), } } diff --git a/zokrates_core/src/static_analysis/dead_code.rs b/zokrates_core/src/static_analysis/dead_code.rs new file mode 100644 index 000000000..4b67b08b2 --- /dev/null +++ b/zokrates_core/src/static_analysis/dead_code.rs @@ -0,0 +1,68 @@ +use std::collections::HashSet; +use zokrates_ast::zir::{folder::*, Identifier, ZirFunction, ZirProgram, ZirStatement}; +use zokrates_field::Field; + +#[derive(Default)] +pub struct DeadCodeEliminator<'ast> { + used: HashSet>, +} + +impl<'ast> DeadCodeEliminator<'ast> { + pub fn eliminate(p: ZirProgram<'ast, T>) -> ZirProgram<'ast, T> { + Self::default().fold_program(p) + } +} + +impl<'ast, T: Field> Folder<'ast, T> for DeadCodeEliminator<'ast> { + fn fold_function(&mut self, f: ZirFunction<'ast, T>) -> ZirFunction<'ast, T> { + // iterate on the statements starting from the end, as we want to see usage before definition + let mut statements: Vec<_> = f + .statements + .into_iter() + .rev() + .flat_map(|s| self.fold_statement(s)) + .collect(); + statements.reverse(); + ZirFunction { statements, ..f } + } + + fn fold_statement(&mut self, s: ZirStatement<'ast, T>) -> Vec> { + match s { + ZirStatement::Definition(v, e) => { + // if the lhs is used later in the program + if self.used.remove(&v.id) { + // include this statement + fold_statement(self, ZirStatement::Definition(v, e)) + } else { + // otherwise remove it + vec![] + } + } + ZirStatement::IfElse(condition, consequence, alternative) => { + let condition = self.fold_boolean_expression(condition); + + let mut consequence: Vec<_> = consequence + .into_iter() + .rev() + .flat_map(|e| self.fold_statement(e)) + .collect(); + consequence.reverse(); + + let mut alternative: Vec<_> = alternative + .into_iter() + .rev() + .flat_map(|e| self.fold_statement(e)) + .collect(); + alternative.reverse(); + + vec![ZirStatement::IfElse(condition, consequence, alternative)] + } + s => fold_statement(self, s), + } + } + + fn fold_name(&mut self, n: Identifier<'ast>) -> Identifier<'ast> { + self.used.insert(n.clone()); + n + } +} diff --git a/zokrates_core/src/static_analysis/flatten_complex_types.rs b/zokrates_core/src/static_analysis/flatten_complex_types.rs index 424dfd229..c4683e4ed 100644 --- a/zokrates_core/src/static_analysis/flatten_complex_types.rs +++ b/zokrates_core/src/static_analysis/flatten_complex_types.rs @@ -402,7 +402,7 @@ fn fold_statement<'ast, T: Field>( typed::TypedStatement::Return(expression) => vec![zir::ZirStatement::Return( f.fold_expression(statements_buffer, expression), )], - typed::TypedStatement::Definition(a, e) => { + typed::TypedStatement::Definition(a, typed::DefinitionRhs::Expression(e)) => { let a = f.fold_assignee(a); let e = f.fold_expression(statements_buffer, e); assert_eq!(a.len(), e.len()); @@ -418,10 +418,14 @@ fn fold_statement<'ast, T: Field>( zir::RuntimeError::SourceAssertion(metadata.to_string()) } typed::RuntimeError::SelectRangeCheck => zir::RuntimeError::SelectRangeCheck, + typed::RuntimeError::DivisionByZero => zir::RuntimeError::DivisionByZero, }; vec![zir::ZirStatement::Assertion(e, error)] } - typed::TypedStatement::EmbedCallDefinition(assignee, embed_call) => { + typed::TypedStatement::Definition( + assignee, + typed::DefinitionRhs::EmbedCall(embed_call), + ) => { vec![zir::ZirStatement::MultipleDefinition( f.fold_assignee(assignee), zir::ZirExpressionList::EmbedCall( diff --git a/zokrates_core/src/static_analysis/mod.rs b/zokrates_core/src/static_analysis/mod.rs index a10f1b66e..e6ed76b24 100644 --- a/zokrates_core/src/static_analysis/mod.rs +++ b/zokrates_core/src/static_analysis/mod.rs @@ -8,10 +8,12 @@ mod branch_isolator; mod condition_redefiner; mod constant_argument_checker; mod constant_resolver; +mod dead_code; mod flat_propagation; mod flatten_complex_types; mod log_ignorer; mod out_of_bounds; +mod panic_extractor; mod propagation; mod reducer; mod struct_concretizer; @@ -32,6 +34,8 @@ use self::uint_optimizer::UintOptimizer; use self::variable_write_remover::VariableWriteRemover; use crate::compile::CompileConfig; use crate::static_analysis::constant_resolver::ConstantResolver; +use crate::static_analysis::dead_code::DeadCodeEliminator; +use crate::static_analysis::panic_extractor::PanicExtractor; use crate::static_analysis::zir_propagation::ZirPropagator; use std::fmt; use zokrates_ast::typed::{abi::Abi, TypedProgram}; @@ -172,6 +176,14 @@ pub fn analyse<'ast, T: Field>( let zir = ZirPropagator::propagate(zir).map_err(Error::from)?; log::trace!("\n{}", zir); + log::debug!("Static analyser: Extract panics"); + let zir = PanicExtractor::extract(zir); + log::trace!("\n{}", zir); + + log::debug!("Static analyser: Remove dead code"); + let zir = DeadCodeEliminator::eliminate(zir); + log::trace!("\n{}", zir); + // optimize uint expressions log::debug!("Static analyser: Optimize uints"); let zir = UintOptimizer::optimize(zir); diff --git a/zokrates_core/src/static_analysis/panic_extractor.rs b/zokrates_core/src/static_analysis/panic_extractor.rs new file mode 100644 index 000000000..d17675a83 --- /dev/null +++ b/zokrates_core/src/static_analysis/panic_extractor.rs @@ -0,0 +1,190 @@ +use zokrates_ast::zir::{ + folder::*, BooleanExpression, Conditional, ConditionalExpression, ConditionalOrExpression, + FieldElementExpression, RuntimeError, UBitwidth, UExpressionInner, ZirProgram, ZirStatement, +}; +use zokrates_field::Field; + +// a static analyser pass to extract the failure modes into separate assert statements, so that a statement can panic iff it's an assertion + +#[derive(Default)] +pub struct PanicExtractor<'ast, T> { + panic_buffer: Vec>, +} + +impl<'ast, T: Field> PanicExtractor<'ast, T> { + pub fn extract(p: ZirProgram<'ast, T>) -> ZirProgram<'ast, T> { + Self::default().fold_program(p) + } +} + +impl<'ast, T: Field> Folder<'ast, T> for PanicExtractor<'ast, T> { + fn fold_statement(&mut self, s: ZirStatement<'ast, T>) -> Vec> { + match s { + ZirStatement::IfElse(condition, consequence, alternative) => { + let condition = self.fold_boolean_expression(condition); + let mut consequence_extractor = Self::default(); + let consequence = consequence + .into_iter() + .flat_map(|s| consequence_extractor.fold_statement(s)) + .collect(); + assert!(consequence_extractor.panic_buffer.is_empty()); + let mut alternative_extractor = Self::default(); + let alternative = alternative + .into_iter() + .flat_map(|s| alternative_extractor.fold_statement(s)) + .collect(); + assert!(alternative_extractor.panic_buffer.is_empty()); + + self.panic_buffer + .drain(..) + .chain(std::iter::once(ZirStatement::IfElse( + condition, + consequence, + alternative, + ))) + .collect() + } + s => { + let s = fold_statement(self, s); + self.panic_buffer.drain(..).chain(s).collect() + } + } + } + + fn fold_field_expression( + &mut self, + e: FieldElementExpression<'ast, T>, + ) -> FieldElementExpression<'ast, T> { + match e { + FieldElementExpression::Div(box n, box d) => { + let n = self.fold_field_expression(n); + let d = self.fold_field_expression(d); + self.panic_buffer.push(ZirStatement::Assertion( + BooleanExpression::Not(box BooleanExpression::FieldEq( + box d.clone(), + box FieldElementExpression::Number(T::zero()), + )), + RuntimeError::DivisionByZero, + )); + FieldElementExpression::Div(box n, box d) + } + e => fold_field_expression(self, e), + } + } + + fn fold_conditional_expression< + E: zokrates_ast::zir::Expr<'ast, T> + Fold<'ast, T> + Conditional<'ast, T>, + >( + &mut self, + _: &E::Ty, + e: ConditionalExpression<'ast, T, E>, + ) -> ConditionalOrExpression<'ast, T, E> { + let condition = self.fold_boolean_expression(*e.condition); + let mut consequence_extractor = Self::default(); + let consequence = e.consequence.fold(&mut consequence_extractor); + let mut alternative_extractor = Self::default(); + let alternative = e.alternative.fold(&mut alternative_extractor); + + let consequence_panics: Vec<_> = consequence_extractor.panic_buffer.drain(..).collect(); + let alternative_panics: Vec<_> = alternative_extractor.panic_buffer.drain(..).collect(); + + if !(consequence_panics.is_empty() && alternative_panics.is_empty()) { + self.panic_buffer.push(ZirStatement::IfElse( + condition.clone(), + consequence_panics, + alternative_panics, + )); + } + + ConditionalOrExpression::Conditional(ConditionalExpression::new( + condition, + consequence, + alternative, + )) + } + + fn fold_uint_expression_inner( + &mut self, + b: UBitwidth, + e: UExpressionInner<'ast, T>, + ) -> UExpressionInner<'ast, T> { + match e { + UExpressionInner::Div(box n, box d) => { + let n = self.fold_uint_expression(n); + let d = self.fold_uint_expression(d); + self.panic_buffer.push(ZirStatement::Assertion( + BooleanExpression::Not(box BooleanExpression::UintEq( + box d.clone(), + box UExpressionInner::Value(0).annotate(b), + )), + RuntimeError::DivisionByZero, + )); + UExpressionInner::Div(box n, box d) + } + e => fold_uint_expression_inner(self, b, e), + } + } + + fn fold_boolean_expression( + &mut self, + e: BooleanExpression<'ast, T>, + ) -> BooleanExpression<'ast, T> { + match e { + // constant range checks are complete, so no panic needs to be extracted + e @ BooleanExpression::FieldLt(box FieldElementExpression::Number(_), _) + | e @ BooleanExpression::FieldLt(_, box FieldElementExpression::Number(_)) => { + fold_boolean_expression(self, e) + } + BooleanExpression::FieldLt(box left, box right) => { + let left = self.fold_field_expression(left); + let right = self.fold_field_expression(right); + + let bit_width = T::get_required_bits(); + + let safe_width = bit_width - 2; // dynamic comparison is not complete, it only applies to field elements whose difference is strictly smaller than 2**(bitwidth - 2) + + let offset = FieldElementExpression::Number(T::from(2).pow(safe_width)); + let max = FieldElementExpression::Number(T::from(2).pow(safe_width + 1)); + + // `|left - right|` must be of bitwidth at most `safe_bitwidth` + // this means we need to guarantee the following: `-2**(safe_width) < left - right < 2**(safe_width)` + // adding an offset of `2**(safe_width)` we turn this into: + // require `0 < 2**(safe_width) + left - right < 2**(safe_width + 1)` + + // we split this check in two: + // `2**(safe_width) + left - right < 2**(safe_width + 1)` + self.panic_buffer.push(ZirStatement::Assertion( + BooleanExpression::FieldLt( + box FieldElementExpression::Add( + box offset.clone(), + box FieldElementExpression::Sub(box left.clone(), box right.clone()), + ), + box max, + ), + RuntimeError::IncompleteDynamicRange, + )); + + // and + // `2**(safe_width) + left - right != 0` + self.panic_buffer.push(ZirStatement::Assertion( + BooleanExpression::Not(box BooleanExpression::FieldEq( + box FieldElementExpression::Sub(box right.clone(), box left.clone()), + box offset, + )), + RuntimeError::IncompleteDynamicRange, + )); + + // NOTE: + // instead of splitting the check in two, we could have used a single `Lt` here, by simply subtracting 1 from all sides: + // `let x = 2**(safe_width) + left - right` + // `0 <= x - 1 < 2**(safe_width + 1) - 1` which is a single constant `Lt` + // however, the *result* of `left < right` requires knowing the bits of `x` + // if we use `x - 1` here, we end up having to calculate the bits of both `x` and `x - 1`, which is expensive + // by splitting, we can reuse the bits of `x` needed for this completeness check when computing the result + + BooleanExpression::FieldLt(box left, box right) + } + e => fold_boolean_expression(self, e), + } + } +} diff --git a/zokrates_core/src/static_analysis/propagation.rs b/zokrates_core/src/static_analysis/propagation.rs index f7a8ac48c..311eec211 100644 --- a/zokrates_core/src/static_analysis/propagation.rs +++ b/zokrates_core/src/static_analysis/propagation.rs @@ -221,9 +221,9 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { ) -> Result>, Error> { match s { // propagation to the defined variable if rhs is a constant - TypedStatement::Definition(assignee, expr) => { - let expr = self.fold_expression(expr)?; + TypedStatement::Definition(assignee, DefinitionRhs::Expression(expr)) => { let assignee = self.fold_assignee(assignee)?; + let expr = self.fold_expression(expr)?; if let (Ok(a), Ok(e)) = ( ConcreteType::try_from(assignee.get_type()), @@ -255,10 +255,10 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { // invalidate the cache for this identifier, and define the latest // version of the constant in the program, if any Some(c) => Ok(vec![ - TypedStatement::Definition(v.clone().into(), c), - TypedStatement::Definition(assignee, expr), + TypedStatement::Definition(v.clone().into(), c.into()), + TypedStatement::Definition(assignee, expr.into()), ]), - None => Ok(vec![TypedStatement::Definition(assignee, expr)]), + None => Ok(vec![TypedStatement::Definition(assignee, expr.into())]), }, }, } @@ -271,10 +271,10 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { match self.constants.remove(&v.id) { Some(c) => Ok(vec![ - TypedStatement::Definition(v.clone().into(), c), - TypedStatement::Definition(assignee, expr), + TypedStatement::Definition(v.clone().into(), c.into()), + TypedStatement::Definition(assignee, expr.into()), ]), - None => Ok(vec![TypedStatement::Definition(assignee, expr)]), + None => Ok(vec![TypedStatement::Definition(assignee, expr.into())]), } } } @@ -285,7 +285,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { Ok(vec![TypedStatement::For(v, from, to, statements)]) } - TypedStatement::EmbedCallDefinition(assignee, embed_call) => { + TypedStatement::Definition(assignee, DefinitionRhs::EmbedCall(embed_call)) => { let assignee = self.fold_assignee(assignee)?; let embed_call = self.fold_embed_call(embed_call)?; @@ -299,37 +299,37 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { let argument = argument.into_canonical_constant(); match ArrayExpression::try_from(argument) - .unwrap() - .into_inner() - { - ArrayExpressionInner::Value(v) => - UExpressionInner::Value( - v.into_iter() - .map(|v| match v { - TypedExpressionOrSpread::Expression( - TypedExpression::Boolean( - BooleanExpression::Value(v), - ), - ) => v, - _ => unreachable!("Should be a constant boolean expression. Spreads are not expected here, as in their presence the argument isn't constant"), - }) - .enumerate() - .fold(0, |acc, (i, v)| { - if v { - acc + 2u128.pow( - (bitwidth.to_usize() - i - 1) - .try_into() - .unwrap(), - ) - } else { - acc - } - }), - ) - .annotate(bitwidth) - .into(), - _ => unreachable!("should be an array value"), - } + .unwrap() + .into_inner() + { + ArrayExpressionInner::Value(v) => + UExpressionInner::Value( + v.into_iter() + .map(|v| match v { + TypedExpressionOrSpread::Expression( + TypedExpression::Boolean( + BooleanExpression::Value(v), + ), + ) => v, + _ => unreachable!("Should be a constant boolean expression. Spreads are not expected here, as in their presence the argument isn't constant"), + }) + .enumerate() + .fold(0, |acc, (i, v)| { + if v { + acc + 2u128.pow( + (bitwidth.to_usize() - i - 1) + .try_into() + .unwrap(), + ) + } else { + acc + } + }), + ) + .annotate(bitwidth) + .into(), + _ => unreachable!("should be an array value"), + } } fn process_u_to_bits<'ast, T: Field>( @@ -471,11 +471,11 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { } Err(v) => match self.constants.remove(&v.id) { Some(c) => vec![ - TypedStatement::Definition(v.clone().into(), c), - TypedStatement::Definition(assignee, expr), + TypedStatement::Definition(v.clone().into(), c.into()), + TypedStatement::Definition(assignee, expr.into()), ], None => { - vec![TypedStatement::Definition(assignee, expr)] + vec![TypedStatement::Definition(assignee, expr.into())] } }, }, @@ -491,11 +491,12 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { match self.constants.remove(&v.id) { Some(c) => vec![ - TypedStatement::Definition(v.clone().into(), c), - TypedStatement::EmbedCallDefinition(assignee, embed_call), + TypedStatement::Definition(v.clone().into(), c.into()), + TypedStatement::Definition(assignee, embed_call.into()), ], - None => vec![TypedStatement::EmbedCallDefinition( - assignee, embed_call, + None => vec![TypedStatement::Definition( + assignee, + embed_call.into(), )], } } @@ -504,7 +505,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { false => { // if the function arguments are not constant, invalidate the cache // for the return assignees - let def = TypedStatement::EmbedCallDefinition(assignee.clone(), embed_call); + let def = TypedStatement::Definition(assignee.clone(), embed_call.into()); let v = self .try_get_constant_mut(&assignee) @@ -513,7 +514,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { Ok(match self.constants.remove(&v.id) { Some(c) => { - vec![TypedStatement::Definition(v.clone().into(), c), def] + vec![TypedStatement::Definition(v.clone().into(), c.into()), def] } None => vec![def], }) @@ -524,9 +525,10 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> { let e_str = e.to_string(); let expr = self.fold_boolean_expression(e)?; match expr { - BooleanExpression::Value(v) if !v => { + BooleanExpression::Value(false) => { Err(Error::AssertionFailed(format!("{}: ({})", ty, e_str))) } + BooleanExpression::Value(true) => Ok(vec![]), _ => Ok(vec![TypedStatement::Assertion(expr, ty)]), } } diff --git a/zokrates_core/src/static_analysis/reducer/constants_reader.rs b/zokrates_core/src/static_analysis/reducer/constants_reader.rs index 1d6ff6b41..8ea0d0afa 100644 --- a/zokrates_core/src/static_analysis/reducer/constants_reader.rs +++ b/zokrates_core/src/static_analysis/reducer/constants_reader.rs @@ -65,10 +65,9 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { assert_eq!(version, 0); match self.constants.get(&c).cloned() { Some(v) => v.try_into().unwrap(), - None => FieldElementExpression::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => FieldElementExpression::Identifier(Identifier::from( + CoreIdentifier::Constant(c), + )), } } e => fold_field_expression(self, e), @@ -87,10 +86,9 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { assert_eq!(version, 0); match self.constants.get(&c).cloned() { Some(v) => v.try_into().unwrap(), - None => BooleanExpression::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => { + BooleanExpression::Identifier(Identifier::from(CoreIdentifier::Constant(c))) + } } } e => fold_boolean_expression(self, e), @@ -108,13 +106,11 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { version, }) => { assert_eq!(version, 0); - match self.constants.get(&c).cloned() { Some(v) => UExpression::try_from(v).unwrap().into_inner(), - None => UExpressionInner::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => { + UExpressionInner::Identifier(Identifier::from(CoreIdentifier::Constant(c))) + } } } e => fold_uint_expression_inner(self, ty, e), @@ -134,10 +130,9 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { assert_eq!(version, 0); match self.constants.get(&c).cloned() { Some(v) => ArrayExpression::try_from(v).unwrap().into_inner(), - None => ArrayExpressionInner::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => ArrayExpressionInner::Identifier(Identifier::from( + CoreIdentifier::Constant(c), + )), } } e => fold_array_expression_inner(self, ty, e), @@ -157,10 +152,9 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { assert_eq!(version, 0); match self.constants.get(&c).cloned() { Some(v) => TupleExpression::try_from(v).unwrap().into_inner(), - None => TupleExpressionInner::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => TupleExpressionInner::Identifier(Identifier::from( + CoreIdentifier::Constant(c), + )), } } e => fold_tuple_expression_inner(self, ty, e), @@ -180,10 +174,9 @@ impl<'a, 'ast, T: Field> Folder<'ast, T> for ConstantsReader<'a, 'ast, T> { assert_eq!(version, 0); match self.constants.get(&c).cloned() { Some(v) => StructExpression::try_from(v).unwrap().into_inner(), - None => StructExpressionInner::Identifier(Identifier { - id: CoreIdentifier::Constant(c), - version, - }), + None => StructExpressionInner::Identifier(Identifier::from( + CoreIdentifier::Constant(c), + )), } } e => fold_struct_expression_inner(self, ty, e), diff --git a/zokrates_core/src/static_analysis/reducer/inline.rs b/zokrates_core/src/static_analysis/reducer/inline.rs index 0b8973644..b2c12962a 100644 --- a/zokrates_core/src/static_analysis/reducer/inline.rs +++ b/zokrates_core/src/static_analysis/reducer/inline.rs @@ -34,7 +34,6 @@ use zokrates_ast::common::FlatEmbed; use zokrates_ast::typed::types::{ConcreteGenericsAssignment, IntoType}; use zokrates_ast::typed::CoreIdentifier; use zokrates_ast::typed::Identifier; -use zokrates_ast::typed::TypedAssignee; use zokrates_ast::typed::{ ConcreteFunctionKey, ConcreteSignature, ConcreteVariable, DeclarationFunctionKey, Expr, Signature, Type, TypedExpression, TypedFunctionSymbol, TypedFunctionSymbolDeclaration, @@ -178,7 +177,7 @@ pub fn inline_call<'a, 'ast, T: Field, E: Expr<'ast, T>>( .zip(inferred_signature.inputs.clone()) .map(|(p, t)| ConcreteVariable::new(p.id.id, t, false)) .zip(arguments.clone()) - .map(|(v, a)| TypedStatement::Definition(TypedAssignee::Identifier(v.into()), a)) + .map(|(v, a)| TypedStatement::definition(Variable::from(v).into(), a)) .collect(); let (statements, mut returns): (Vec<_>, Vec<_>) = ssa_f @@ -196,7 +195,7 @@ pub fn inline_call<'a, 'ast, T: Field, E: Expr<'ast, T>>( let v: ConcreteVariable<'ast> = ConcreteVariable::new( Identifier::from(CoreIdentifier::Call(0)).version( *versions - .entry(CoreIdentifier::Call(0).clone()) + .entry(CoreIdentifier::Call(0)) .and_modify(|e| *e += 1) // if it was already declared, we increment .or_insert(0), ), @@ -206,8 +205,7 @@ pub fn inline_call<'a, 'ast, T: Field, E: Expr<'ast, T>>( let expression = TypedExpression::from(Variable::from(v.clone())); - let output_binding = - TypedStatement::Definition(TypedAssignee::Identifier(v.into()), return_expression); + let output_binding = TypedStatement::definition(Variable::from(v).into(), return_expression); let pop_log = TypedStatement::PopCallLog; diff --git a/zokrates_core/src/static_analysis/reducer/mod.rs b/zokrates_core/src/static_analysis/reducer/mod.rs index 218ccaf66..508e982ec 100644 --- a/zokrates_core/src/static_analysis/reducer/mod.rs +++ b/zokrates_core/src/static_analysis/reducer/mod.rs @@ -269,7 +269,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> { let identifier = Identifier::from(CoreIdentifier::Call(0)).version( *self .versions - .entry(CoreIdentifier::Call(0).clone()) + .entry(CoreIdentifier::Call(0)) .and_modify(|e| *e += 1) // if it was already declared, we increment .or_insert(0), ); @@ -278,7 +278,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> { let v = var.clone().into(); self.statement_buffer - .push(TypedStatement::EmbedCallDefinition( + .push(TypedStatement::embed_call_definition( v, EmbedCall::new(embed, generics, arguments), )); @@ -352,7 +352,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> { for index in *from..*to { let statements: Vec> = - std::iter::once(TypedStatement::Definition( + std::iter::once(TypedStatement::definition( v.clone().into(), UExpression::from(index as u32).into(), )) @@ -611,21 +611,21 @@ mod tests { let main: TypedFunction = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::function_call( DeclarationFunctionKey::with_location("main", "foo").signature( @@ -638,7 +638,7 @@ mod tests { ) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) @@ -687,7 +687,7 @@ mod tests { let expected_main = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(1)).into(), FieldElementExpression::Identifier("a".into()).into(), ), @@ -699,17 +699,17 @@ mod tests { ), GGenericsAssignment::default(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(3)).into(), FieldElementExpression::Identifier(Identifier::from("a").version(1)).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from(CoreIdentifier::Call(0)).version(0)) .into(), FieldElementExpression::Identifier(Identifier::from("a").version(3)).into(), ), TypedStatement::PopCallLog, - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(2)).into(), FieldElementExpression::Identifier( Identifier::from(CoreIdentifier::Call(0)).version(0), @@ -804,17 +804,17 @@ mod tests { let main: TypedFunction = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpressionInner::Value( vec![FieldElementExpression::Identifier("a".into()).into()].into(), @@ -822,7 +822,7 @@ mod tests { .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpression::function_call( DeclarationFunctionKey::with_location("main", "foo") @@ -835,7 +835,7 @@ mod tests { .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) @@ -889,7 +889,7 @@ mod tests { let expected_main = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpressionInner::Value( vec![FieldElementExpression::Identifier("a".into()).into()].into(), @@ -906,14 +906,14 @@ mod tests { .collect(), ), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array(Identifier::from("a").version(1), Type::FieldElement, 1u32) .into(), ArrayExpressionInner::Identifier("b".into()) .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array( Identifier::from(CoreIdentifier::Call(0)).version(0), Type::FieldElement, @@ -925,7 +925,7 @@ mod tests { .into(), ), TypedStatement::PopCallLog, - TypedStatement::Definition( + TypedStatement::definition( Variable::array(Identifier::from("b").version(1), Type::FieldElement, 1u32) .into(), ArrayExpressionInner::Identifier( @@ -1028,17 +1028,17 @@ mod tests { let main: TypedFunction = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(2u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array( "b", Type::FieldElement, @@ -1055,7 +1055,7 @@ mod tests { .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpression::function_call( DeclarationFunctionKey::with_location("main", "foo") @@ -1068,7 +1068,7 @@ mod tests { .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) @@ -1122,7 +1122,7 @@ mod tests { let expected_main = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpressionInner::Value( vec![FieldElementExpression::Identifier("a".into()).into()].into(), @@ -1139,14 +1139,14 @@ mod tests { .collect(), ), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array(Identifier::from("a").version(1), Type::FieldElement, 1u32) .into(), ArrayExpressionInner::Identifier("b".into()) .annotate(Type::FieldElement, 1u32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::array( Identifier::from(CoreIdentifier::Call(0)).version(0), Type::FieldElement, @@ -1158,7 +1158,7 @@ mod tests { .into(), ), TypedStatement::PopCallLog, - TypedStatement::Definition( + TypedStatement::definition( Variable::array(Identifier::from("b").version(1), Type::FieldElement, 1u32) .into(), ArrayExpressionInner::Identifier( @@ -1254,7 +1254,7 @@ mod tests { ) .into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::array( "ret", Type::FieldElement, @@ -1333,7 +1333,7 @@ mod tests { let main: TypedFunction = TypedFunction { arguments: vec![], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpression::function_call( DeclarationFunctionKey::with_location("main", "foo") @@ -1485,7 +1485,7 @@ mod tests { let main: TypedFunction = TypedFunction { arguments: vec![], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::array("b", Type::FieldElement, 1u32).into(), ArrayExpression::function_call( DeclarationFunctionKey::with_location("main", "foo") diff --git a/zokrates_core/src/static_analysis/reducer/shallow_ssa.rs b/zokrates_core/src/static_analysis/reducer/shallow_ssa.rs index fe7d65732..6abcc8a78 100644 --- a/zokrates_core/src/static_analysis/reducer/shallow_ssa.rs +++ b/zokrates_core/src/static_analysis/reducer/shallow_ssa.rs @@ -103,15 +103,13 @@ impl<'ast, 'a> ShallowTransformer<'ast, 'a> { f.statements = generics .0 - .iter() + .clone() + .into_iter() .map(|(g, v)| { - TypedStatement::Definition( - TypedAssignee::Identifier(Variable::new( - g.name(), - Type::Uint(UBitwidth::B32), - false, - )), - UExpression::from(*v as u32).into(), + TypedStatement::definition( + Variable::new(CoreIdentifier::from(g), Type::Uint(UBitwidth::B32), false) + .into(), + UExpression::from(v as u32).into(), ) }) .chain(f.statements) @@ -128,7 +126,7 @@ impl<'ast, 'a> ShallowTransformer<'ast, 'a> { impl<'ast, 'a, T: Field> Folder<'ast, T> for ShallowTransformer<'ast, 'a> { fn fold_statement(&mut self, s: TypedStatement<'ast, T>) -> Vec> { match s { - TypedStatement::Definition(a, e) => { + TypedStatement::Definition(a, DefinitionRhs::Expression(e)) => { let e = self.fold_expression(e); let a = match a { @@ -139,9 +137,9 @@ impl<'ast, 'a, T: Field> Folder<'ast, T> for ShallowTransformer<'ast, 'a> { a => fold_assignee(self, a), }; - vec![TypedStatement::Definition(a, e)] + vec![TypedStatement::definition(a, e)] } - TypedStatement::EmbedCallDefinition(assignee, embed_call) => { + TypedStatement::Definition(assignee, DefinitionRhs::EmbedCall(embed_call)) => { let assignee = match assignee { TypedAssignee::Identifier(v) => { let v = self.issue_next_ssa_variable(v); @@ -150,7 +148,7 @@ impl<'ast, 'a, T: Field> Folder<'ast, T> for ShallowTransformer<'ast, 'a> { a => fold_assignee(self, a), }; let embed_call = self.fold_embed_call(embed_call); - vec![TypedStatement::EmbedCallDefinition(assignee, embed_call)] + vec![TypedStatement::embed_call_definition(assignee, embed_call)] } TypedStatement::For(v, from, to, stats) => { let from = self.fold_uint_expression(from); @@ -238,13 +236,13 @@ mod tests { let mut u = ShallowTransformer::with_versions(&mut versions); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element("a")), FieldElementExpression::Number(Bn128Field::from(5)).into(), ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element( Identifier::from("a").version(0) )), @@ -252,13 +250,13 @@ mod tests { )] ); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element("a")), FieldElementExpression::Number(Bn128Field::from(6)).into(), ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element( Identifier::from("a").version(1) )), @@ -288,13 +286,13 @@ mod tests { let mut u = ShallowTransformer::with_versions(&mut versions); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element("a")), FieldElementExpression::Number(Bn128Field::from(5)).into(), ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element( Identifier::from("a").version(0) )), @@ -302,7 +300,7 @@ mod tests { )] ); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element("a")), FieldElementExpression::Add( box FieldElementExpression::Identifier("a".into()), @@ -312,7 +310,7 @@ mod tests { ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element( Identifier::from("a").version(1) )), @@ -339,13 +337,13 @@ mod tests { let mut u = ShallowTransformer::with_versions(&mut versions); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element("a")), FieldElementExpression::Number(Bn128Field::from(2)).into(), ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::field_element( Identifier::from("a").version(0) )), @@ -353,7 +351,7 @@ mod tests { )] ); - let s: TypedStatement = TypedStatement::Definition( + let s: TypedStatement = TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::function_call( DeclarationFunctionKey::with_location("main", "foo").signature( @@ -368,7 +366,7 @@ mod tests { ); assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element(Identifier::from("a").version(1)).into(), FieldElementExpression::function_call( DeclarationFunctionKey::with_location("main", "foo").signature( @@ -400,7 +398,7 @@ mod tests { let mut u = ShallowTransformer::with_versions(&mut versions); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::array("a", Type::FieldElement, 2u32)), ArrayExpressionInner::Value( vec![ @@ -415,7 +413,7 @@ mod tests { assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::array( Identifier::from("a").version(0), Type::FieldElement, @@ -433,7 +431,7 @@ mod tests { )] ); - let s: TypedStatement = TypedStatement::Definition( + let s: TypedStatement = TypedStatement::definition( TypedAssignee::Select( box TypedAssignee::Identifier(Variable::array("a", Type::FieldElement, 2u32)), box UExpression::from(1u32), @@ -459,7 +457,7 @@ mod tests { let array_of_array_ty = Type::array((Type::array((Type::FieldElement, 2u32)), 2u32)); - let s = TypedStatement::Definition( + let s = TypedStatement::definition( TypedAssignee::Identifier(Variable::new("a", array_of_array_ty.clone(), true)), ArrayExpressionInner::Value( vec![ @@ -490,7 +488,7 @@ mod tests { assert_eq!( u.fold_statement(s), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( TypedAssignee::Identifier(Variable::new( Identifier::from("a").version(0), array_of_array_ty.clone(), @@ -524,7 +522,7 @@ mod tests { )] ); - let s: TypedStatement = TypedStatement::Definition( + let s: TypedStatement = TypedStatement::definition( TypedAssignee::Select( box TypedAssignee::Identifier(Variable::new( "a", @@ -590,17 +588,17 @@ mod tests { let f: TypedFunction = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), ), @@ -609,12 +607,12 @@ mod tests { UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32), UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32) * UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), )], ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), ), @@ -623,12 +621,12 @@ mod tests { UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32), UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32) * UExpressionInner::Identifier("n".into()).annotate(UBitwidth::B32), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), )], ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), ), @@ -657,21 +655,21 @@ mod tests { let expected = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("K", UBitwidth::B32).into(), TypedExpression::Uint(1u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint(Identifier::from("n").version(1), UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(1)).into(), FieldElementExpression::Identifier("a".into()).into(), ), @@ -683,12 +681,12 @@ mod tests { .annotate(UBitwidth::B32) * UExpressionInner::Identifier(Identifier::from("n").version(1)) .annotate(UBitwidth::B32), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), )], ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(3)).into(), FieldElementExpression::Identifier(Identifier::from("a").version(2)).into(), ), @@ -700,12 +698,12 @@ mod tests { .annotate(UBitwidth::B32) * UExpressionInner::Identifier(Identifier::from("n").version(2)) .annotate(UBitwidth::B32), - vec![TypedStatement::Definition( + vec![TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), )], ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(5)).into(), FieldElementExpression::Identifier(Identifier::from("a").version(4)).into(), ), @@ -744,6 +742,178 @@ mod tests { } } + mod shadowing { + use zokrates_ast::typed::types::GGenericsAssignment; + + use super::*; + + #[test] + fn same_scope() { + // def main(field a) { + // field a = 42; + // bool a = true + // return; + // } + + // should become + + // def main(field a_0) { + // field a_1 = 42; + // bool a_2 = true; + // return; + // } + + let f: TypedFunction = TypedFunction { + arguments: vec![DeclarationVariable::field_element("a").into()], + statements: vec![ + TypedStatement::definition( + Variable::field_element("a").into(), + TypedExpression::Uint(42u32.into()), + ), + TypedStatement::definition( + Variable::boolean("a").into(), + BooleanExpression::Value(true).into(), + ), + TypedStatement::Return( + TupleExpressionInner::Value(vec![]) + .annotate(TupleType::new(vec![])) + .into(), + ), + ], + signature: DeclarationSignature::new() + .generics(vec![]) + .inputs(vec![DeclarationType::FieldElement]), + }; + + let expected: TypedFunction = TypedFunction { + arguments: vec![DeclarationVariable::field_element("a").into()], + statements: vec![ + TypedStatement::definition( + Variable::field_element(Identifier::from("a").version(1)).into(), + TypedExpression::Uint(42u32.into()), + ), + TypedStatement::definition( + Variable::boolean(Identifier::from("a").version(2)).into(), + BooleanExpression::Value(true).into(), + ), + TypedStatement::Return( + TupleExpressionInner::Value(vec![]) + .annotate(TupleType::new(vec![])) + .into(), + ), + ], + signature: DeclarationSignature::new() + .generics(vec![]) + .inputs(vec![DeclarationType::FieldElement]), + }; + + let mut versions = Versions::default(); + + let ssa = + ShallowTransformer::transform(f, &GGenericsAssignment::default(), &mut versions); + + assert_eq!(ssa, Output::Complete(expected)); + } + + #[test] + fn next_scope() { + // def main(field a) { + // for u32 i in 0..1 { + // a = a + 1 + // field a = 42 + // } + // return a + // } + + // should become + + // def main(field a_0) { + // # versions: {a: 0} + // for u32 i in 0..1 { + // a_0 = a_0 + // field a_0 = 42 + // } + // return a_1 + // } + + let f: TypedFunction = TypedFunction { + arguments: vec![DeclarationVariable::field_element("a").into()], + statements: vec![ + TypedStatement::For( + Variable::uint("i", UBitwidth::B32), + 0u32.into(), + 1u32.into(), + vec![ + TypedStatement::definition( + Variable::field_element(Identifier::from("a")).into(), + FieldElementExpression::Identifier("a".into()).into(), + ), + TypedStatement::definition( + Variable::field_element(Identifier::from("a")).into(), + FieldElementExpression::Number(42usize.into()).into(), + ), + ], + ), + TypedStatement::Return( + TupleExpressionInner::Value(vec![FieldElementExpression::Identifier( + "a".into(), + ) + .into()]) + .annotate(TupleType::new(vec![Type::FieldElement])) + .into(), + ), + ], + signature: DeclarationSignature::new() + .generics(vec![]) + .inputs(vec![DeclarationType::FieldElement]) + .output(DeclarationType::FieldElement), + }; + + let expected: TypedFunction = TypedFunction { + arguments: vec![DeclarationVariable::field_element("a").into()], + statements: vec![ + TypedStatement::For( + Variable::uint("i", UBitwidth::B32), + 0u32.into(), + 1u32.into(), + vec![ + TypedStatement::definition( + Variable::field_element(Identifier::from("a")).into(), + FieldElementExpression::Identifier(Identifier::from("a")).into(), + ), + TypedStatement::definition( + Variable::field_element(Identifier::from("a")).into(), + FieldElementExpression::Number(42usize.into()).into(), + ), + ], + ), + TypedStatement::Return( + TupleExpressionInner::Value(vec![FieldElementExpression::Identifier( + Identifier::from("a").version(1), + ) + .into()]) + .annotate(TupleType::new(vec![Type::FieldElement])) + .into(), + ), + ], + signature: DeclarationSignature::new() + .generics(vec![]) + .inputs(vec![DeclarationType::FieldElement]) + .output(DeclarationType::FieldElement), + }; + + let mut versions = Versions::default(); + + let ssa = + ShallowTransformer::transform(f, &GGenericsAssignment::default(), &mut versions); + + assert_eq!( + ssa, + Output::Incomplete(expected, vec![vec![("a".into(), 0)].into_iter().collect()]) + ); + } + } + mod function_call { use super::*; use zokrates_ast::typed::types::GGenericsAssignment; @@ -775,21 +945,21 @@ mod tests { let f: TypedFunction = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::Identifier("a".into()).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), FieldElementExpression::function_call( DeclarationFunctionKey::with_location("main", "foo"), @@ -800,13 +970,13 @@ mod tests { ) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element("a").into(), (FieldElementExpression::Identifier("a".into()) * FieldElementExpression::function_call( @@ -844,25 +1014,25 @@ mod tests { let expected = TypedFunction { arguments: vec![DeclarationVariable::field_element("a").into()], statements: vec![ - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("K", UBitwidth::B32).into(), TypedExpression::Uint(1u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint("n", UBitwidth::B32).into(), TypedExpression::Uint(42u32.into()), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint(Identifier::from("n").version(1), UBitwidth::B32).into(), UExpressionInner::Identifier("n".into()) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(1)).into(), FieldElementExpression::Identifier("a".into()).into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(2)).into(), FieldElementExpression::function_call( DeclarationFunctionKey::with_location("main", "foo"), @@ -877,13 +1047,13 @@ mod tests { ) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::uint(Identifier::from("n").version(2), UBitwidth::B32).into(), UExpressionInner::Identifier(Identifier::from("n").version(1)) .annotate(UBitwidth::B32) .into(), ), - TypedStatement::Definition( + TypedStatement::definition( Variable::field_element(Identifier::from("a").version(3)).into(), (FieldElementExpression::Identifier(Identifier::from("a").version(2)) * FieldElementExpression::function_call( diff --git a/zokrates_core/src/static_analysis/variable_write_remover.rs b/zokrates_core/src/static_analysis/variable_write_remover.rs index 4b59d5040..ce80c9607 100644 --- a/zokrates_core/src/static_analysis/variable_write_remover.rs +++ b/zokrates_core/src/static_analysis/variable_write_remover.rs @@ -457,11 +457,11 @@ fn is_constant(assignee: &TypedAssignee) -> bool { impl<'ast, T: Field> Folder<'ast, T> for VariableWriteRemover { fn fold_statement(&mut self, s: TypedStatement<'ast, T>) -> Vec> { match s { - TypedStatement::Definition(assignee, expr) => { + TypedStatement::Definition(assignee, DefinitionRhs::Expression(expr)) => { let expr = self.fold_expression(expr); if is_constant(&assignee) { - vec![TypedStatement::Definition(assignee, expr)] + vec![TypedStatement::definition(assignee, expr)] } else { // Note: here we redefine the whole object, ideally we would only redefine some of it // Example: `a[0][i] = 42` we redefine `a` but we could redefine just `a[0]` @@ -511,7 +511,7 @@ impl<'ast, T: Field> Folder<'ast, T> for VariableWriteRemover { range_checks .into_iter() - .chain(std::iter::once(TypedStatement::Definition( + .chain(std::iter::once(TypedStatement::definition( TypedAssignee::Identifier(variable), e, ))) diff --git a/zokrates_core/src/static_analysis/zir_propagation.rs b/zokrates_core/src/static_analysis/zir_propagation.rs index 730bb00da..72bbdf1f5 100644 --- a/zokrates_core/src/static_analysis/zir_propagation.rs +++ b/zokrates_core/src/static_analysis/zir_propagation.rs @@ -1,18 +1,10 @@ use std::collections::HashMap; use std::fmt; -use zokrates_ast::zir::result_folder::fold_boolean_expression; -use zokrates_ast::zir::result_folder::fold_field_expression; -use zokrates_ast::zir::result_folder::fold_statement; -use zokrates_ast::zir::result_folder::fold_uint_expression_inner; -use zokrates_ast::zir::result_folder::ResultFold; -use zokrates_ast::zir::result_folder::ResultFolder; use zokrates_ast::zir::types::UBitwidth; -use zokrates_ast::zir::Conditional; -use zokrates_ast::zir::ConditionalExpression; -use zokrates_ast::zir::ConditionalOrExpression; -use zokrates_ast::zir::Expr; -use zokrates_ast::zir::SelectExpression; -use zokrates_ast::zir::SelectOrExpression; +use zokrates_ast::zir::{ + result_folder::*, Conditional, ConditionalExpression, ConditionalOrExpression, Expr, + SelectExpression, SelectOrExpression, +}; use zokrates_ast::zir::{ BooleanExpression, FieldElementExpression, Identifier, RuntimeError, UExpression, UExpressionInner, ZirExpression, ZirProgram, ZirStatement, @@ -667,6 +659,7 @@ mod tests { #[cfg(test)] mod field { + use zokrates_ast::zir::Conditional; use zokrates_ast::zir::Select; use super::*; @@ -868,6 +861,7 @@ mod tests { #[cfg(test)] mod bool { + use zokrates_ast::zir::Conditional; use zokrates_ast::zir::Select; use super::*; @@ -1174,6 +1168,8 @@ mod tests { #[cfg(test)] mod uint { + use zokrates_ast::zir::Conditional; + use super::*; #[test] diff --git a/zokrates_core_test/Cargo.toml b/zokrates_core_test/Cargo.toml index 54f57c619..cb0214bb2 100644 --- a/zokrates_core_test/Cargo.toml +++ b/zokrates_core_test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_core_test" -version = "0.2.7" +version = "0.2.8" authors = ["schaeff "] edition = "2018" diff --git a/zokrates_core_test/tests/tests/add.json b/zokrates_core_test/tests/tests/add.json index 62bc7bf27..b299e4ed7 100644 --- a/zokrates_core_test/tests/tests/add.json +++ b/zokrates_core_test/tests/tests/add.json @@ -1,30 +1,30 @@ { - "entry_point": "./tests/tests/add.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "abi": false, - "tests": [ - { - "input": { - "values": ["1", "2"] - }, - "output": { - "Ok": { - "value": ["3"] - } - } - }, - { - "input": { - "values": ["1", "2", "42"] - }, - "output": { - "Err": { - "WrongInputCount": { - "expected": 2, - "received": 3 - } - } - } - } - ] + "entry_point": "./tests/tests/add.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "abi": false, + "tests": [ + { + "input": { + "values": ["1", "2"] + }, + "output": { + "Ok": { + "value": ["3"] + } + } + }, + { + "input": { + "values": ["1", "2", "42"] + }, + "output": { + "Err": { + "WrongInputCount": { + "expected": 2, + "received": 3 + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/array_conditional.json b/zokrates_core_test/tests/tests/array_conditional.json index df98175e5..10cb0b91d 100644 --- a/zokrates_core_test/tests/tests/array_conditional.json +++ b/zokrates_core_test/tests/tests/array_conditional.json @@ -1,26 +1,26 @@ { - "entry_point": "./tests/tests/array_conditional.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [["1", "2"], ["3", "4"], "1"] - }, - "output": { - "Ok": { - "value": ["1", "2"] - } - } - }, - { - "input": { - "values": [["1", "2"], ["3", "4"], "2"] - }, - "output": { - "Ok": { - "value": ["3", "4"] - } - } - } - ] + "entry_point": "./tests/tests/array_conditional.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [["1", "2"], ["3", "4"], "1"] + }, + "output": { + "Ok": { + "value": ["1", "2"] + } + } + }, + { + "input": { + "values": [["1", "2"], ["3", "4"], "2"] + }, + "output": { + "Ok": { + "value": ["3", "4"] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/arrays/fun_spread.json b/zokrates_core_test/tests/tests/arrays/fun_spread.json index 5583d3068..8c3c047dd 100644 --- a/zokrates_core_test/tests/tests/arrays/fun_spread.json +++ b/zokrates_core_test/tests/tests/arrays/fun_spread.json @@ -1,6 +1,5 @@ { - "entry_point": "./tests/tests/arrays/fun_spread.zok", - "max_constraint_count": 1050, - "tests": [ - ] -} \ No newline at end of file + "entry_point": "./tests/tests/arrays/fun_spread.zok", + "max_constraint_count": 1050, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/arrays/identity.json b/zokrates_core_test/tests/tests/arrays/identity.json index d44f98c00..cb0b541dc 100644 --- a/zokrates_core_test/tests/tests/arrays/identity.json +++ b/zokrates_core_test/tests/tests/arrays/identity.json @@ -1,41 +1,41 @@ { - "entry_point": "./tests/tests/arrays/identity.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "abi": false, - "tests": [ - { - "input": { - "values": ["0", "0", "0"] - }, - "output": { - "Ok": { - "value": ["0", "0", "0"] - } - } - }, - { - "input": { - "values": ["1", "0", "1"] - }, - "output": { - "Ok": { - "value": ["1", "0", "1"] - } - } - }, - { - "input": { - "values": ["2", "1", "1"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "4", - "right": "2", - "error": "ArgumentBitness" - } - } - } - } - ] + "entry_point": "./tests/tests/arrays/identity.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "abi": false, + "tests": [ + { + "input": { + "values": ["0", "0", "0"] + }, + "output": { + "Ok": { + "value": ["0", "0", "0"] + } + } + }, + { + "input": { + "values": ["1", "0", "1"] + }, + "output": { + "Ok": { + "value": ["1", "0", "1"] + } + } + }, + { + "input": { + "values": ["2", "1", "1"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "4", + "right": "2", + "error": "ArgumentBitness" + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/arrays/select.json b/zokrates_core_test/tests/tests/arrays/select.json index 9ae0facc2..a84f3cad4 100644 --- a/zokrates_core_test/tests/tests/arrays/select.json +++ b/zokrates_core_test/tests/tests/arrays/select.json @@ -1,51 +1,51 @@ { - "entry_point": "./tests/tests/arrays/select.zok", - "max_constraint_count": 44, - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [["0", "11", "22"], "0"] - }, - "output": { - "Ok": { - "value": "0" - } - } - }, - { - "input": { - "values": [["0", "11", "22"], "1"] - }, - "output": { - "Ok": { - "value": "11" - } - } - }, - { - "input": { - "values": [["0", "11", "22"], "2"] - }, - "output": { - "Ok": { - "value": "22" - } - } - }, - { - "input": { - "values": [["0", "11", "22"], "3"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "0", - "error": "SelectRangeCheck" - } - } - } - } - ] + "entry_point": "./tests/tests/arrays/select.zok", + "max_constraint_count": 44, + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [["0", "11", "22"], "0"] + }, + "output": { + "Ok": { + "value": "0" + } + } + }, + { + "input": { + "values": [["0", "11", "22"], "1"] + }, + "output": { + "Ok": { + "value": "11" + } + } + }, + { + "input": { + "values": [["0", "11", "22"], "2"] + }, + "output": { + "Ok": { + "value": "22" + } + } + }, + { + "input": { + "values": [["0", "11", "22"], "3"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "0", + "error": "SelectRangeCheck" + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/assert_array_equality.json b/zokrates_core_test/tests/tests/assert_array_equality.json index 1422a3ed0..783f433b0 100644 --- a/zokrates_core_test/tests/tests/assert_array_equality.json +++ b/zokrates_core_test/tests/tests/assert_array_equality.json @@ -1,32 +1,32 @@ { - "entry_point": "./tests/tests/assert_array_equality.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [["1", "2"]] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": [["1", "1"]] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/assert_array_equality.zok:2:5" - } - } - } + "entry_point": "./tests/tests/assert_array_equality.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [["1", "2"]] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [["1", "1"]] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/assert_array_equality.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/assert_one.json b/zokrates_core_test/tests/tests/assert_one.json index ef7fd1da1..ff1b80946 100644 --- a/zokrates_core_test/tests/tests/assert_one.json +++ b/zokrates_core_test/tests/tests/assert_one.json @@ -1,22 +1,22 @@ { - "entry_point": "./tests/tests/assert_one.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/assert_one.zok:2:2" - } - } - } + "entry_point": "./tests/tests/assert_one.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/assert_one.zok:2:2" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/bool_compare.json b/zokrates_core_test/tests/tests/bool_compare.json index 1afabfbe8..3e3e41274 100644 --- a/zokrates_core_test/tests/tests/bool_compare.json +++ b/zokrates_core_test/tests/tests/bool_compare.json @@ -1,45 +1,36 @@ { - "entry_point": "./tests/tests/bool_compare.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [ - true, - true - ] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": [ - true, - false - ] - }, - "output": { - "Ok": { - "value": false - } - } - }, - { - "input": { - "values": [ - false, - false - ] - }, - "output": { - "Ok": { - "value": true - } - } + "entry_point": "./tests/tests/bool_compare.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [true, true] + }, + "output": { + "Ok": { + "value": true } - ] + } + }, + { + "input": { + "values": [true, false] + }, + "output": { + "Ok": { + "value": false + } + } + }, + { + "input": { + "values": [false, false] + }, + "output": { + "Ok": { + "value": true + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/cached_condition.json b/zokrates_core_test/tests/tests/cached_condition.json index 5b4edff36..0fdf5e715 100644 --- a/zokrates_core_test/tests/tests/cached_condition.json +++ b/zokrates_core_test/tests/tests/cached_condition.json @@ -2,4 +2,4 @@ "entry_point": "./tests/tests/cached_condition.zok", "max_constraint_count": 2015, "tests": [] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/compare_min_to_max.json b/zokrates_core_test/tests/tests/compare_min_to_max.json index 5e019cbdd..e1402336e 100644 --- a/zokrates_core_test/tests/tests/compare_min_to_max.json +++ b/zokrates_core_test/tests/tests/compare_min_to_max.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/compare_min_to_max.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": false - } - } - } - ] + "entry_point": "./tests/tests/compare_min_to_max.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": false + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/complex_call.json b/zokrates_core_test/tests/tests/complex_call.json index 584dd3b90..ff7179afe 100644 --- a/zokrates_core_test/tests/tests/complex_call.json +++ b/zokrates_core_test/tests/tests/complex_call.json @@ -1,14 +1,15 @@ { - "entry_point": "./tests/tests/complex_call.zok", - "tests": [ - { - "input": { - "values": [true, "2", {"a": [false, true], "b": "2"}, ["3", "4"]] - }, - "output": { - "Ok": { - "value": [{"a": [true, true], "b": "3"}, "4"] } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/complex_call.zok", + "tests": [ + { + "input": { + "values": [true, "2", { "a": [false, true], "b": "2" }, ["3", "4"]] + }, + "output": { + "Ok": { + "value": [{ "a": [true, true], "b": "3" }, "4"] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/constants/array_size.json b/zokrates_core_test/tests/tests/constants/array_size.json index 4f4e07c66..67bd3b991 100644 --- a/zokrates_core_test/tests/tests/constants/array_size.json +++ b/zokrates_core_test/tests/tests/constants/array_size.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/constants/array_size.zok", - "max_constraint_count": 2, - "tests": [ - { - "input": { - "values": [["42", "42"]] - }, - "output": { - "Ok": { - "value": ["42", "42"] - } - } + "entry_point": "./tests/tests/constants/array_size.zok", + "max_constraint_count": 2, + "tests": [ + { + "input": { + "values": [["42", "42"]] + }, + "output": { + "Ok": { + "value": ["42", "42"] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/constants/import/destination.json b/zokrates_core_test/tests/tests/constants/import/destination.json index 552e97784..4218f0845 100644 --- a/zokrates_core_test/tests/tests/constants/import/destination.json +++ b/zokrates_core_test/tests/tests/constants/import/destination.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/constants/import/destination.zok", - "tests": [] + "entry_point": "./tests/tests/constants/import/destination.zok", + "tests": [] } diff --git a/zokrates_core_test/tests/tests/constants/issue_1038/a.json b/zokrates_core_test/tests/tests/constants/issue_1038/a.json index 754485877..18a793756 100644 --- a/zokrates_core_test/tests/tests/constants/issue_1038/a.json +++ b/zokrates_core_test/tests/tests/constants/issue_1038/a.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/constants/issue_1038/a.zok", - "tests": [] + "entry_point": "./tests/tests/constants/issue_1038/a.zok", + "tests": [] } diff --git a/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.json b/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.json index 0de904eb9..d46d82b66 100644 --- a/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.json +++ b/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/constants/issue_1038/reversed/b.zok", - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/constants/issue_1038/reversed/b.zok", + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/constants/issue_1047/a.json b/zokrates_core_test/tests/tests/constants/issue_1047/a.json index f7bab70f0..79f54f991 100644 --- a/zokrates_core_test/tests/tests/constants/issue_1047/a.json +++ b/zokrates_core_test/tests/tests/constants/issue_1047/a.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/constants/issue_1047/a.zok", - "tests": [] + "entry_point": "./tests/tests/constants/issue_1047/a.zok", + "tests": [] } diff --git a/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.json b/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.json index 579bfe1b7..eaba26bb1 100644 --- a/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.json +++ b/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/constants/issue_1047/reversed/b.zok", - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/constants/issue_1047/reversed/b.zok", + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/constants/mixed.json b/zokrates_core_test/tests/tests/constants/mixed.json index ef8cdd371..1eab770ba 100644 --- a/zokrates_core_test/tests/tests/constants/mixed.json +++ b/zokrates_core_test/tests/tests/constants/mixed.json @@ -1,25 +1,25 @@ { - "entry_point": "./tests/tests/constants/mixed.zok", - "max_constraint_count": 6, - "tests": [ - { - "input": { - "values": [] + "entry_point": "./tests/tests/constants/mixed.zok", + "max_constraint_count": 6, + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [ + { + "a": ["1", "2"], + "b": true }, - "output": { - "Ok": { - "value": [ - { - "a": ["1", "2"], - "b": true - }, - { - "a": ["3", "4"], - "b": false - } - ] - } + { + "a": ["3", "4"], + "b": false } + ] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/constants/propagate.json b/zokrates_core_test/tests/tests/constants/propagate.json index e29cf239f..29ea6bd62 100644 --- a/zokrates_core_test/tests/tests/constants/propagate.json +++ b/zokrates_core_test/tests/tests/constants/propagate.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/constants/propagate.zok", - "max_constraint_count": 4, - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": ["42", "42", "42", "42"] - } - } + "entry_point": "./tests/tests/constants/propagate.zok", + "max_constraint_count": 4, + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": ["42", "42", "42", "42"] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/constants/struct.json b/zokrates_core_test/tests/tests/constants/struct.json index 1a520a429..79c724ce1 100644 --- a/zokrates_core_test/tests/tests/constants/struct.json +++ b/zokrates_core_test/tests/tests/constants/struct.json @@ -8,7 +8,13 @@ }, "output": { "Ok": { - "value": { "a": ["1", "2"], "b": [["3", "4"], ["5", "6"]]} + "value": { + "a": ["1", "2"], + "b": [ + ["3", "4"], + ["5", "6"] + ] + } } } } diff --git a/zokrates_core_test/tests/tests/div.json b/zokrates_core_test/tests/tests/div.json new file mode 100644 index 000000000..9b8a453e3 --- /dev/null +++ b/zokrates_core_test/tests/tests/div.json @@ -0,0 +1,65 @@ +{ + "entry_point": "./tests/tests/div.zok", + "max_constraint_count": 3, + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": ["0", "0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "4", + "right": "2", + "error": "Inverse" + } + } + } + }, + { + "input": { + "values": ["1", "0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "4", + "right": "2", + "error": "Inverse" + } + } + } + }, + { + "input": { + "values": ["0", "1"] + }, + "output": { + "Ok": { + "value": "0" + } + } + }, + { + "input": { + "values": ["2", "2"] + }, + "output": { + "Ok": { + "value": "1" + } + } + }, + { + "input": { + "values": ["4", "2"] + }, + "output": { + "Ok": { + "value": "2" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/div.zok b/zokrates_core_test/tests/tests/div.zok new file mode 100644 index 000000000..4e5966d29 --- /dev/null +++ b/zokrates_core_test/tests/tests/div.zok @@ -0,0 +1,3 @@ +def main(field x, field y) -> field { + return x / y; +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/fact_up_to_4.json b/zokrates_core_test/tests/tests/fact_up_to_4.json index ba6981a39..766c15e0d 100644 --- a/zokrates_core_test/tests/tests/fact_up_to_4.json +++ b/zokrates_core_test/tests/tests/fact_up_to_4.json @@ -1,56 +1,56 @@ { - "entry_point": "./tests/tests/fact_up_to_4.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": "1" - } - } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": "1" - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Ok": { - "value": "2" - } - } - }, - { - "input": { - "values": ["3"] - }, - "output": { - "Ok": { - "value": "6" - } - } - }, - { - "input": { - "values": ["4"] - }, - "output": { - "Ok": { - "value": "24" - } - } - } - ] + "entry_point": "./tests/tests/fact_up_to_4.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": "1" + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": "1" + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": "2" + } + } + }, + { + "input": { + "values": ["3"] + }, + "output": { + "Ok": { + "value": "6" + } + } + }, + { + "input": { + "values": ["4"] + }, + "output": { + "Ok": { + "value": "24" + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/generics/cache.json b/zokrates_core_test/tests/tests/generics/cache.json index bfe92ae77..8c2de3aea 100644 --- a/zokrates_core_test/tests/tests/generics/cache.json +++ b/zokrates_core_test/tests/tests/generics/cache.json @@ -1,15 +1,15 @@ { - "curves": ["Bn128", "Bls12_381"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "curves": ["Bn128", "Bls12_381"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/generics/call.json b/zokrates_core_test/tests/tests/generics/call.json index 4e45eccc3..1776d4148 100644 --- a/zokrates_core_test/tests/tests/generics/call.json +++ b/zokrates_core_test/tests/tests/generics/call.json @@ -1,4 +1,4 @@ { - "curves": ["Bn128", "Bls12_381"], - "tests": [] -} \ No newline at end of file + "curves": ["Bn128", "Bls12_381"], + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/generics/embed.json b/zokrates_core_test/tests/tests/generics/embed.json index 4e45eccc3..1776d4148 100644 --- a/zokrates_core_test/tests/tests/generics/embed.json +++ b/zokrates_core_test/tests/tests/generics/embed.json @@ -1,4 +1,4 @@ { - "curves": ["Bn128", "Bls12_381"], - "tests": [] -} \ No newline at end of file + "curves": ["Bn128", "Bls12_381"], + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/generics/multidef.json b/zokrates_core_test/tests/tests/generics/multidef.json index b8965574a..667b284ba 100644 --- a/zokrates_core_test/tests/tests/generics/multidef.json +++ b/zokrates_core_test/tests/tests/generics/multidef.json @@ -1,15 +1,15 @@ { - "curves": ["Bn128", "Bls12_381"], - "tests": [ - { - "input": { - "values": [["1", "2", "3"]] - }, - "output": { - "Ok": { - "value": ["1", "2", "3"] - } - } + "curves": ["Bn128", "Bls12_381"], + "tests": [ + { + "input": { + "values": [["1", "2", "3"]] + }, + "output": { + "Ok": { + "value": ["1", "2", "3"] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/generics/return_inference.json b/zokrates_core_test/tests/tests/generics/return_inference.json index 37c420d1d..043a0ff0e 100644 --- a/zokrates_core_test/tests/tests/generics/return_inference.json +++ b/zokrates_core_test/tests/tests/generics/return_inference.json @@ -1,15 +1,15 @@ { - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": ["42", "42"] - } - } + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": ["42", "42"] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/generics/same_parameter_name.json b/zokrates_core_test/tests/tests/generics/same_parameter_name.json index 4ba6bb104..bbf3368f7 100644 --- a/zokrates_core_test/tests/tests/generics/same_parameter_name.json +++ b/zokrates_core_test/tests/tests/generics/same_parameter_name.json @@ -1,15 +1,15 @@ { - "curves": ["Bn128", "Bls12_381"], - "tests": [ - { - "input": { - "values": [["1", "2", "3"]] - }, - "output": { - "Ok": { - "value": ["1", "2"] - } - } + "curves": ["Bn128", "Bls12_381"], + "tests": [ + { + "input": { + "values": [["1", "2", "3"]] + }, + "output": { + "Ok": { + "value": ["1", "2"] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/import/import.json b/zokrates_core_test/tests/tests/import/import.json index a14062bff..9e45d1662 100644 --- a/zokrates_core_test/tests/tests/import/import.json +++ b/zokrates_core_test/tests/tests/import/import.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/import/import.zok", - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": "3" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/import/import.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": "3" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/le.json b/zokrates_core_test/tests/tests/le.json index c41de4abd..a363d885a 100644 --- a/zokrates_core_test/tests/tests/le.json +++ b/zokrates_core_test/tests/tests/le.json @@ -1,86 +1,86 @@ { - "entry_point": "./tests/tests/le.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": ["41"] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": ["42"] - }, - "output": { - "Ok": { - "value": true - } - } - }, - { - "input": { - "values": ["43"] - }, - "output": { - "Ok": { - "value": false - } - } - }, - { - "input": { - "values": ["44"] - }, - "output": { - "Ok": { - "value": false - } - } - }, - { - "input": { - "values": ["100"] - }, - "output": { - "Ok": { - "value": false - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/le.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": true + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": true + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": true + } + } + }, + { + "input": { + "values": ["41"] + }, + "output": { + "Ok": { + "value": true + } + } + }, + { + "input": { + "values": ["42"] + }, + "output": { + "Ok": { + "value": true + } + } + }, + { + "input": { + "values": ["43"] + }, + "output": { + "Ok": { + "value": false + } + } + }, + { + "input": { + "values": ["44"] + }, + "output": { + "Ok": { + "value": false + } + } + }, + { + "input": { + "values": ["100"] + }, + "output": { + "Ok": { + "value": false + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/left_rotation.json b/zokrates_core_test/tests/tests/left_rotation.json index bccc8c006..d4a720374 100644 --- a/zokrates_core_test/tests/tests/left_rotation.json +++ b/zokrates_core_test/tests/tests/left_rotation.json @@ -1,46 +1,46 @@ { - "entry_point": "./tests/tests/left_rotation.zok", - "max_constraint_count": 34, - "tests": [ - { - "input": { - "values": ["0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x00000001"] - }, - "output": { - "Ok": { - "value": "0x00000004" - } - } - }, - { - "input": { - "values": ["0x0000002a"] - }, - "output": { - "Ok": { - "value": "0x000000a8" - } - } - }, - { - "input": { - "values": ["0x8000000a"] - }, - "output": { - "Ok": { - "value": "0x0000002a" - } - } + "entry_point": "./tests/tests/left_rotation.zok", + "max_constraint_count": 34, + "tests": [ + { + "input": { + "values": ["0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" } - ] + } + }, + { + "input": { + "values": ["0x00000001"] + }, + "output": { + "Ok": { + "value": "0x00000004" + } + } + }, + { + "input": { + "values": ["0x0000002a"] + }, + "output": { + "Ok": { + "value": "0x000000a8" + } + } + }, + { + "input": { + "values": ["0x8000000a"] + }, + "output": { + "Ok": { + "value": "0x0000002a" + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/left_rotation_bits.json b/zokrates_core_test/tests/tests/left_rotation_bits.json index 1fb3e505f..2b86510b5 100644 --- a/zokrates_core_test/tests/tests/left_rotation_bits.json +++ b/zokrates_core_test/tests/tests/left_rotation_bits.json @@ -1,46 +1,46 @@ { - "entry_point": "./tests/tests/left_rotation_bits.zok", - "max_constraint_count": 34, - "tests": [ - { - "input": { - "values": ["0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x00000001"] - }, - "output": { - "Ok": { - "value": "0x00000004" - } - } - }, - { - "input": { - "values": ["0x0000002a"] - }, - "output": { - "Ok": { - "value": "0x000000a8" - } - } - }, - { - "input": { - "values": ["0x8000000a"] - }, - "output": { - "Ok": { - "value": "0x0000002a" - } - } + "entry_point": "./tests/tests/left_rotation_bits.zok", + "max_constraint_count": 34, + "tests": [ + { + "input": { + "values": ["0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" } - ] + } + }, + { + "input": { + "values": ["0x00000001"] + }, + "output": { + "Ok": { + "value": "0x00000004" + } + } + }, + { + "input": { + "values": ["0x0000002a"] + }, + "output": { + "Ok": { + "value": "0x000000a8" + } + } + }, + { + "input": { + "values": ["0x8000000a"] + }, + "output": { + "Ok": { + "value": "0x0000002a" + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/memoize/memoize.json b/zokrates_core_test/tests/tests/memoize/memoize.json index 36a70747e..df3893ea9 100644 --- a/zokrates_core_test/tests/tests/memoize/memoize.json +++ b/zokrates_core_test/tests/tests/memoize/memoize.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/memoize/memoize.zok", - "max_constraint_count": 32, - "tests": [ - { - "input": { - "values": ["3"] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/memoize/memoize.zok", + "max_constraint_count": 32, + "tests": [ + { + "input": { + "values": ["3"] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/memoize/no_array_memoization.json b/zokrates_core_test/tests/tests/memoize/no_array_memoization.json index 1fd95ba27..a46e3531a 100644 --- a/zokrates_core_test/tests/tests/memoize/no_array_memoization.json +++ b/zokrates_core_test/tests/tests/memoize/no_array_memoization.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/memoize/no_array_memoization.zok", - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/memoize/no_array_memoization.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/native_le.json b/zokrates_core_test/tests/tests/native_le.json index fea28bf13..a2e3e270e 100644 --- a/zokrates_core_test/tests/tests/native_le.json +++ b/zokrates_core_test/tests/tests/native_le.json @@ -1,86 +1,86 @@ { - "entry_point": "./tests/tests/native_le.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0", "0x00000000"] - }, - "output": { - "Ok": { - "value": [true, true] - } - } - }, - { - "input": { - "values": ["1", "0x00000001"] - }, - "output": { - "Ok": { - "value": [true, true] - } - } - }, - { - "input": { - "values": ["2", "0x00000002"] - }, - "output": { - "Ok": { - "value": [true, true] - } - } - }, - { - "input": { - "values": ["41", "0x00000029"] - }, - "output": { - "Ok": { - "value": [true, true] - } - } - }, - { - "input": { - "values": ["42", "0x0000002a"] - }, - "output": { - "Ok": { - "value": [true, true] - } - } - }, - { - "input": { - "values": ["43", "0x0000002b"] - }, - "output": { - "Ok": { - "value": [false, false] - } - } - }, - { - "input": { - "values": ["44", "0x0000002c"] - }, - "output": { - "Ok": { - "value": [false, false] - } - } - }, - { - "input": { - "values": ["100", "0x00000064"] - }, - "output": { - "Ok": { - "value": [false, false] - } - } - } - ] + "entry_point": "./tests/tests/native_le.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0", "0x00000000"] + }, + "output": { + "Ok": { + "value": [true, true] + } + } + }, + { + "input": { + "values": ["1", "0x00000001"] + }, + "output": { + "Ok": { + "value": [true, true] + } + } + }, + { + "input": { + "values": ["2", "0x00000002"] + }, + "output": { + "Ok": { + "value": [true, true] + } + } + }, + { + "input": { + "values": ["41", "0x00000029"] + }, + "output": { + "Ok": { + "value": [true, true] + } + } + }, + { + "input": { + "values": ["42", "0x0000002a"] + }, + "output": { + "Ok": { + "value": [true, true] + } + } + }, + { + "input": { + "values": ["43", "0x0000002b"] + }, + "output": { + "Ok": { + "value": [false, false] + } + } + }, + { + "input": { + "values": ["44", "0x0000002c"] + }, + "output": { + "Ok": { + "value": [false, false] + } + } + }, + { + "input": { + "values": ["100", "0x00000064"] + }, + "output": { + "Ok": { + "value": [false, false] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/neg_pos.json b/zokrates_core_test/tests/tests/neg_pos.json index 3a356bd9f..7dff484c6 100644 --- a/zokrates_core_test/tests/tests/neg_pos.json +++ b/zokrates_core_test/tests/tests/neg_pos.json @@ -1,15 +1,23 @@ { - "entry_point": "./tests/tests/neg_pos.zok", - "tests": [ - { - "input": { - "values": ["1", "2", "0x01", "0x02"] - }, - "output": { - "Ok": { - "value": [["21888242871839275222246405745257275088548364400416034343698204186575808495615", "21888242871839275222246405745257275088548364400416034343698204186575808495616", "21888242871839275222246405745257275088548364400416034343698204186575808495616", "21888242871839275222246405745257275088548364400416034343698204186575808495616"], ["0xfe", "0xff", "0xff", "0xff"]] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/neg_pos.zok", + "tests": [ + { + "input": { + "values": ["1", "2", "0x01", "0x02"] + }, + "output": { + "Ok": { + "value": [ + [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ], + ["0xfe", "0xff", "0xff", "0xff"] + ] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/nested_loop.json b/zokrates_core_test/tests/tests/nested_loop.json index e1ba8cf9e..6930071f8 100644 --- a/zokrates_core_test/tests/tests/nested_loop.json +++ b/zokrates_core_test/tests/tests/nested_loop.json @@ -1,25 +1,25 @@ { - "entry_point": "./tests/tests/nested_loop.zok", - "tests": [ - { - "input": { - "values": [["1", "2", "3", "4"]] - }, - "output": { - "Ok": { - "value": ["4838400", "10", "25"] - } - } - }, - { - "input": { - "values": [["0", "1", "2", "3"]] - }, - "output": { - "Ok": { - "value": ["0", "10", "25"] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/nested_loop.zok", + "tests": [ + { + "input": { + "values": [["1", "2", "3", "4"]] + }, + "output": { + "Ok": { + "value": ["4838400", "10", "25"] + } + } + }, + { + "input": { + "values": [["0", "1", "2", "3"]] + }, + "output": { + "Ok": { + "value": ["0", "10", "25"] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/no_return.json b/zokrates_core_test/tests/tests/no_return.json new file mode 100644 index 000000000..ea4453f78 --- /dev/null +++ b/zokrates_core_test/tests/tests/no_return.json @@ -0,0 +1,4 @@ +{ + "entry_point": "./tests/tests/no_return.zok", + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/no_return.zok b/zokrates_core_test/tests/tests/no_return.zok new file mode 100644 index 000000000..940c50930 --- /dev/null +++ b/zokrates_core_test/tests/tests/no_return.zok @@ -0,0 +1,9 @@ +def foo() { + return; +} + +def bar() { + return foo(); +} + +def main() {} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json b/zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json index e4c0604c2..820ffbeb1 100644 --- a/zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json +++ b/zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json @@ -1,60 +1,54 @@ { - "entry_point": "./tests/tests/panics/conditional_bound_throw.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [ - "0x00000000" - ] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" - } - } - } + "entry_point": "./tests/tests/panics/conditional_bound_throw.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0x00000000"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" } - }, - { - "input": { - "values": [ - "0x00000001" - ] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "0", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["0x00000001"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "0", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" } - }, - { - "input": { - "values": [ - "0x00000002" - ] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "2", - "right": "0", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["0x00000002"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "2", + "right": "0", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/conditional_bound_throw.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/deep_branch.json b/zokrates_core_test/tests/tests/panics/deep_branch.json index 1777672c5..a9287c128 100644 --- a/zokrates_core_test/tests/tests/panics/deep_branch.json +++ b/zokrates_core_test/tests/tests/panics/deep_branch.json @@ -1,49 +1,49 @@ { - "entry_point": "./tests/tests/panics/deep_branch.zok", - "curves": ["Bn128"], - "config": { - "isolate_branches": true + "entry_point": "./tests/tests/panics/deep_branch.zok", + "curves": ["Bn128"], + "config": { + "isolate_branches": true + }, + "tests": [ + { + "input": { + "values": [[true, true, true]] + }, + "output": { + "Ok": { + "value": [true, true, true] + } + } + }, + { + "input": { + "values": [[false, false, false]] + }, + "output": { + "Ok": { + "value": [false, false, false] + } + } + }, + { + "input": { + "values": [[false, true, false]] + }, + "output": { + "Ok": { + "value": [false, true, false] + } + } }, - "tests": [ - { - "input": { - "values": [[true, true, true]] - }, - "output": { - "Ok": { - "value": [true, true, true] - } - } - }, - { - "input": { - "values": [[false, false, false]] - }, - "output": { - "Ok": { - "value": [false, false, false] - } - } - }, - { - "input": { - "values": [[false, true, false]] - }, - "output": { - "Ok": { - "value": [false, true, false] - } - } - }, - { - "input": { - "values": [[true, false, true]] - }, - "output": { - "Ok": { - "value": [true, false, true] - } - } + { + "input": { + "values": [[true, false, true]] + }, + "output": { + "Ok": { + "value": [true, false, true] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json b/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json index 0abf294c0..1a10b3853 100644 --- a/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json +++ b/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json @@ -1,24 +1,22 @@ { - "entry_point": "./tests/tests/panics/deep_branch.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [[ - false, false, false - ]] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/deep_branch.zok:2:5" - } - } - } + "entry_point": "./tests/tests/panics/deep_branch.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [[false, false, false]] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/deep_branch.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/internal_panic.json b/zokrates_core_test/tests/tests/panics/internal_panic.json index c35121372..6b5191253 100644 --- a/zokrates_core_test/tests/tests/panics/internal_panic.json +++ b/zokrates_core_test/tests/tests/panics/internal_panic.json @@ -1,33 +1,29 @@ { - "entry_point": "./tests/tests/panics/internal_panic.zok", - "curves": ["Bn128"], - "config": { - "isolate_branches": true + "entry_point": "./tests/tests/panics/internal_panic.zok", + "curves": ["Bn128"], + "config": { + "isolate_branches": true + }, + "tests": [ + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": "1" + } + } }, - "tests": [ - { - "input": { - "values": [ - "1" - ] - }, - "output": { - "Ok": { - "value": "1" - } - } - }, - { - "input": { - "values": [ - "0" - ] - }, - "output": { - "Ok": { - "value": "0" - } - } + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": "0" } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json b/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json index 8e8f027c7..c98e1cec2 100644 --- a/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json +++ b/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json @@ -1,34 +1,30 @@ { - "entry_point": "./tests/tests/panics/internal_panic.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [ - "1" - ] - }, - "output": { - "Ok": { - "value": "1" - } - } - }, - { - "input": { - "values": [ - "0" - ] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": "Inverse" - } - } - } + "entry_point": "./tests/tests/panics/internal_panic.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": "1" } - ] + } + }, + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": "Inverse" + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/loop_bound.json b/zokrates_core_test/tests/tests/panics/loop_bound.json index d13115d49..5caf89e0a 100644 --- a/zokrates_core_test/tests/tests/panics/loop_bound.json +++ b/zokrates_core_test/tests/tests/panics/loop_bound.json @@ -1,36 +1,32 @@ { - "entry_point": "./tests/tests/panics/loop_bound.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [ - "0" - ] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/loop_bound.zok:2:5" - } - } - } - } - }, - { - "input": { - "values": [ - "1" - ] - }, - "output": { - "Ok": { - "value": [] - } + "entry_point": "./tests/tests/panics/loop_bound.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/loop_bound.zok:2:5" } + } + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/panic_isolation.json b/zokrates_core_test/tests/tests/panics/panic_isolation.json index c698c45b8..434b45823 100644 --- a/zokrates_core_test/tests/tests/panics/panic_isolation.json +++ b/zokrates_core_test/tests/tests/panics/panic_isolation.json @@ -1,45 +1,45 @@ { - "entry_point": "./tests/tests/panics/panic_isolation.zok", - "config": { - "isolate_branches": true - }, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [true, ["42", "42"], "0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "21888242871839275222246405745257275088548364400416034343698204186575808495577", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/panic_isolation.zok:22:5" - } - } - } - } - }, - { - "input": { - "values": [true, ["1", "1"], "1"] - }, - "output": { - "Ok": { - "value": [true, ["1", "1"], "1"] - } - } - }, - { - "input": { - "values": [false, ["2", "2"], "0"] - }, - "output": { - "Ok": { - "value": [false, ["2", "2"], "0"] - } + "entry_point": "./tests/tests/panics/panic_isolation.zok", + "config": { + "isolate_branches": true + }, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [true, ["42", "42"], "0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "21888242871839275222246405745257275088548364400416034343698204186575808495577", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/panic_isolation.zok:22:5" } + } + } + } + }, + { + "input": { + "values": [true, ["1", "1"], "1"] + }, + "output": { + "Ok": { + "value": [true, ["1", "1"], "1"] + } + } + }, + { + "input": { + "values": [false, ["2", "2"], "0"] + }, + "output": { + "Ok": { + "value": [false, ["2", "2"], "0"] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/panics/panic_no_isolation.json b/zokrates_core_test/tests/tests/panics/panic_no_isolation.json index 22a408976..349358227 100644 --- a/zokrates_core_test/tests/tests/panics/panic_no_isolation.json +++ b/zokrates_core_test/tests/tests/panics/panic_no_isolation.json @@ -1,25 +1,25 @@ { - "entry_point": "./tests/tests/panics/panic_isolation.zok", - "config": { - "isolate_branches": false - }, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [true, ["1", "1"], "1"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "0", - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/panics/panic_isolation.zok:17:5" - } - } - } + "entry_point": "./tests/tests/panics/panic_isolation.zok", + "config": { + "isolate_branches": false + }, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [true, ["1", "1"], "1"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "0", + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/panics/panic_isolation.zok:17:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/pass_by_value.json b/zokrates_core_test/tests/tests/pass_by_value.json index c57d1fe25..3ff5d612b 100644 --- a/zokrates_core_test/tests/tests/pass_by_value.json +++ b/zokrates_core_test/tests/tests/pass_by_value.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/pass_by_value.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [["1"], { "a": "1" }, "1"] - }, - "output": { - "Ok": { - "value": [["2"], ["1"], { "a": "2"}, {"a": "1"}, "2", "1"] - } - } - } - ] + "entry_point": "./tests/tests/pass_by_value.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [["1"], { "a": "1" }, "1"] + }, + "output": { + "Ok": { + "value": [["2"], ["1"], { "a": "2" }, { "a": "1" }, "2", "1"] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/precedence.json b/zokrates_core_test/tests/tests/precedence.json index 3f1f5f9df..2480bf45b 100644 --- a/zokrates_core_test/tests/tests/precedence.json +++ b/zokrates_core_test/tests/tests/precedence.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/precedence.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/precedence.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range.json b/zokrates_core_test/tests/tests/range.json index 4d8c40408..3233033ce 100644 --- a/zokrates_core_test/tests/tests/range.json +++ b/zokrates_core_test/tests/tests/range.json @@ -1,76 +1,80 @@ { - "entry_point": "./tests/tests/range.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": [false, true, true, true, false] - } - } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": [false, false, true, true, true] - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Ok": { - "value": [false, false, true, true, false] - } - } - }, - { - "input": { - "values": ["254"] - }, - "output": { - "Ok": { - "value": [false, false, true, true, false] - } - } - }, - { - "input": { - "values": ["255"] - }, - "output": { - "Ok": { - "value": [false, false, false, true, false] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495615"] - }, - "output": { - "Ok": { - "value": [false, false, false, true, false] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }, - "output": { - "Ok": { - "value": [false, false, false, false, false] - } - } + "entry_point": "./tests/tests/range.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [false, true, true, true, false] } - ] + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [false, false, true, true, true] + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": [false, false, true, true, false] + } + } + }, + { + "input": { + "values": ["254"] + }, + "output": { + "Ok": { + "value": [false, false, true, true, false] + } + } + }, + { + "input": { + "values": ["255"] + }, + "output": { + "Ok": { + "value": [false, false, false, true, false] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615" + ] + }, + "output": { + "Ok": { + "value": [false, false, false, true, false] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Ok": { + "value": [false, false, false, false, false] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_ge.json b/zokrates_core_test/tests/tests/range_check/assert_ge.json index f4cc9084a..9cd01522f 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_ge.json +++ b/zokrates_core_test/tests/tests/range_check/assert_ge.json @@ -1,55 +1,55 @@ { - "entry_point": "./tests/tests/range_check/assert_ge.zok", - "max_constraint_count": 509, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_ge.zok:2:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_ge.zok", + "max_constraint_count": 509, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_ge.zok:2:5" } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_ge.zok:2:5" - } - } - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["15"] - }, - "output": { - "Ok": { - "value": [] - } + } + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_ge.zok:2:5" } + } + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_gt.json b/zokrates_core_test/tests/tests/range_check/assert_gt.json index daa3231bc..ea3314b06 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_gt.json +++ b/zokrates_core_test/tests/tests/range_check/assert_gt.json @@ -1,59 +1,59 @@ { - "entry_point": "./tests/tests/range_check/assert_gt.zok", - "max_constraint_count": 508, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_gt.zok", + "max_constraint_count": 508, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" - } - } - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" } - }, - { - "input": { - "values": ["15"] - }, - "output": { - "Ok": { - "value": [] - } + } + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt.zok:2:5" } + } + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.json b/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.json index 7b7dfc074..0d92e7b45 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.json +++ b/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.json @@ -1,45 +1,49 @@ { - "entry_point": "./tests/tests/range_check/assert_gt_big_constant.zok", - "max_constraint_count": 3, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt_big_constant.zok:4:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_gt_big_constant.zok", + "max_constraint_count": 3, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt_big_constant.zok:4:5" } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495615"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt_big_constant.zok:4:5" - } - } - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }, - "output": { - "Ok": { - "value": [] - } + } + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_gt_big_constant.zok:4:5" } + } + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_le.json b/zokrates_core_test/tests/tests/range_check/assert_le.json index ec106d9e4..27502fdc9 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_le.json +++ b/zokrates_core_test/tests/tests/range_check/assert_le.json @@ -1,55 +1,55 @@ { - "entry_point": "./tests/tests/range_check/assert_le.zok", - "max_constraint_count": 5, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["3"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_le.zok:2:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_le.zok", + "max_constraint_count": 5, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["3"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_le.zok:2:5" } - }, - { - "input": { - "values": ["15"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_le.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_le.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt.json b/zokrates_core_test/tests/tests/range_check/assert_lt.json index 060babc4d..bdaee03b4 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt.json +++ b/zokrates_core_test/tests/tests/range_check/assert_lt.json @@ -1,55 +1,55 @@ { - "entry_point": "./tests/tests/range_check/assert_lt.zok", - "max_constraint_count": 4, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["2"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt.zok:2:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_lt.zok", + "max_constraint_count": 4, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt.zok:2:5" } - }, - { - "input": { - "values": ["15"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.json b/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.json index 831d44f04..9baeb5aa3 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.json +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.json @@ -1,41 +1,45 @@ { - "entry_point": "./tests/tests/range_check/assert_lt_big_constant.zok", - "max_constraint_count": 509, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495614"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495615"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_big_constant.zok:4:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_lt_big_constant.zok", + "max_constraint_count": 509, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495614" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_big_constant.zok:4:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json index 7955aaa8b..3c2107c4c 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json @@ -1,55 +1,55 @@ { - "entry_point": "./tests/tests/range_check/assert_lt_u8.zok", - "max_constraint_count": 9, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["0x00"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["0x01"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["0x02"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_u8.zok:2:5" - } - } - } + "entry_point": "./tests/tests/range_check/assert_lt_u8.zok", + "max_constraint_count": 9, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0x00"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x01"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x02"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_u8.zok:2:5" } - }, - { - "input": { - "values": ["0x0f"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_u8.zok:2:5" - } - } - } + } + } + } + }, + { + "input": { + "values": ["0x0f"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": "Assertion failed at ./tests/tests/range_check/assert_lt_u8.zok:2:5" } + } } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/right_rotation.json b/zokrates_core_test/tests/tests/right_rotation.json index 6ab2794ea..7c15fea02 100644 --- a/zokrates_core_test/tests/tests/right_rotation.json +++ b/zokrates_core_test/tests/tests/right_rotation.json @@ -1,46 +1,46 @@ { - "entry_point": "./tests/tests/right_rotation.zok", - "max_constraint_count": 34, - "tests": [ - { - "input": { - "values": ["0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x00000001"] - }, - "output": { - "Ok": { - "value": "0x40000000" - } - } - }, - { - "input": { - "values": ["0x0000002a"] - }, - "output": { - "Ok": { - "value": "0x8000000a" - } - } - }, - { - "input": { - "values": ["0x8000000a"] - }, - "output": { - "Ok": { - "value": "0xa0000002" - } - } + "entry_point": "./tests/tests/right_rotation.zok", + "max_constraint_count": 34, + "tests": [ + { + "input": { + "values": ["0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" } - ] + } + }, + { + "input": { + "values": ["0x00000001"] + }, + "output": { + "Ok": { + "value": "0x40000000" + } + } + }, + { + "input": { + "values": ["0x0000002a"] + }, + "output": { + "Ok": { + "value": "0x8000000a" + } + } + }, + { + "input": { + "values": ["0x8000000a"] + }, + "output": { + "Ok": { + "value": "0xa0000002" + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/right_rotation_bits.json b/zokrates_core_test/tests/tests/right_rotation_bits.json index a0052ff89..7af354b6c 100644 --- a/zokrates_core_test/tests/tests/right_rotation_bits.json +++ b/zokrates_core_test/tests/tests/right_rotation_bits.json @@ -1,46 +1,46 @@ { - "entry_point": "./tests/tests/right_rotation_bits.zok", - "max_constraint_count": 34, - "tests": [ - { - "input": { - "values": ["0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x00000001"] - }, - "output": { - "Ok": { - "value": "0x40000000" - } - } - }, - { - "input": { - "values": ["0x0000002a"] - }, - "output": { - "Ok": { - "value": "0x8000000a" - } - } - }, - { - "input": { - "values": ["0x8000000a"] - }, - "output": { - "Ok": { - "value": "0xa0000002" - } - } + "entry_point": "./tests/tests/right_rotation_bits.zok", + "max_constraint_count": 34, + "tests": [ + { + "input": { + "values": ["0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" } - ] + } + }, + { + "input": { + "values": ["0x00000001"] + }, + "output": { + "Ok": { + "value": "0x40000000" + } + } + }, + { + "input": { + "values": ["0x0000002a"] + }, + "output": { + "Ok": { + "value": "0x8000000a" + } + } + }, + { + "input": { + "values": ["0x8000000a"] + }, + "output": { + "Ok": { + "value": "0xa0000002" + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/shadowing.json b/zokrates_core_test/tests/tests/shadowing.json new file mode 100644 index 000000000..4f425d353 --- /dev/null +++ b/zokrates_core_test/tests/tests/shadowing.json @@ -0,0 +1,15 @@ +{ + "entry_point": "./tests/tests/shadowing.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": ["2", "84"] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/shadowing.zok b/zokrates_core_test/tests/tests/shadowing.zok new file mode 100644 index 000000000..2475f5a49 --- /dev/null +++ b/zokrates_core_test/tests/tests/shadowing.zok @@ -0,0 +1,10 @@ +def main() -> (field, field) { + field mut a = 0; + field mut b = 0; + for u32 i in 0..2 { + a = a + 1; + field a = 42; + b = b + a; + } + return (a, b); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/single_return.json b/zokrates_core_test/tests/tests/single_return.json index 9f7097338..614631931 100644 --- a/zokrates_core_test/tests/tests/single_return.json +++ b/zokrates_core_test/tests/tests/single_return.json @@ -1,5 +1,4 @@ { - "entry_point": "./tests/tests/single_return.zok", - "tests": [ - ] -} \ No newline at end of file + "entry_point": "./tests/tests/single_return.zok", + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_1.json b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_1.json index d7ac49ec3..f4e4deacb 100644 --- a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_1.json +++ b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_1.json @@ -5,35 +5,39 @@ { "input": { "values": [ - ["14854361253166356985827940126714566475275412573126716429346293669288261212877767002588736768495892518280555332082", - "213732210873464696846782550184555137228225514409080200587629835423679101735680889388490505365220726936653232900722", - "87538607630632344401950048588801759619324114043687193925268161368645768079512372989046887060116208844098222887523", - "5657143080315521889991799092902512094315245718355471372723437558193333983953910948320586493950523700874011063560", - "57443068623489368358651325326719858590550354409074784986003051193396111859230778144944186401073595967957696940521", - "239017299818740889416561988179003000999440599788233589838386981563280711497257601212385904595560069610856834048609", - "210817940648895568697680255986492415724502544301527123629003695092329489846191300997148203752109923795482648905049", - "104796720182429147963427519368170838521257629224027565408974396362211239635140389257768036297199752289691646178885"], + [ + "14854361253166356985827940126714566475275412573126716429346293669288261212877767002588736768495892518280555332082", + "213732210873464696846782550184555137228225514409080200587629835423679101735680889388490505365220726936653232900722", + "87538607630632344401950048588801759619324114043687193925268161368645768079512372989046887060116208844098222887523", + "5657143080315521889991799092902512094315245718355471372723437558193333983953910948320586493950523700874011063560", + "57443068623489368358651325326719858590550354409074784986003051193396111859230778144944186401073595967957696940521", + "239017299818740889416561988179003000999440599788233589838386981563280711497257601212385904595560069610856834048609", + "210817940648895568697680255986492415724502544301527123629003695092329489846191300997148203752109923795482648905049", + "104796720182429147963427519368170838521257629224027565408974396362211239635140389257768036297199752289691646178885" + ], ["1"], - ["237849156256827398282019388933972533154056715710612980343582379691235964002811111531637163291964836316287473866944", - "121324456153144638357885760921484124420296650752569739652599982435599667566663818850130137668154167962818124679946", - "73600332144130508132510040050892177274732799381796146541825372722030832659283233558443467575385522990242420388929", - "44732797483932307692113794160403754043679743522093845554740681666841720206796756514002159097899004452746371432672", - "11133333007786916806537653763736510041397904969121754556887982143919681840159919608974969747422557814633960596319", - "90561577672782365102721874737156537447800052875073945376839636447536979602099666234669817779872333362600029687267", - "5450223346768511418345330845468131514992561567665451102957435878264997759483533580796977034429945593412389724558", - "235853237950439075722577332685219091953664185148611937130324227335365792837509030624805785387473218289296335533890", - "89396333230537847366322364436342481695658547414236326093675863540417141298105682739791578537835191912089484203681", - "115830385654423364502343021113073028365721746246232924567075277636234346135515984504152518055968175024342452068593", - "11263613907940703510226043272578077114062568830909561875804816268614922948545123959608046723806484765856945366386", - "85099371298035679603247495321780481321948685394995318303952199333118698031562067002765732094949837892213467834453", - "237849156256827398282019388933972533154056715710612980343582379691235964002811111531637163291964836316287473866944", - "121324456153144638357885760921484124420296650752569739652599982435599667566663818850130137668154167962818124679946", - "73600332144130508132510040050892177274732799381796146541825372722030832659283233558443467575385522990242420388929", - "44732797483932307692113794160403754043679743522093845554740681666841720206796756514002159097899004452746371432672", - "147751075268067473595930126919015490789314687953476809410426208666203744311411068892162888393693647317357680788622", - "253223744369647051774471619931702227054534749249995484100066505466186263584769989160049762529720081850824722544795", - "226753899873357669326157359116609350824063726018578587491538482132599227769745752321252816012800490263881222618536", - "176875521207730154886136120529839690202784860066517231969835480145708453592054364059780266900035568058186799176840"] + [ + "237849156256827398282019388933972533154056715710612980343582379691235964002811111531637163291964836316287473866944", + "121324456153144638357885760921484124420296650752569739652599982435599667566663818850130137668154167962818124679946", + "73600332144130508132510040050892177274732799381796146541825372722030832659283233558443467575385522990242420388929", + "44732797483932307692113794160403754043679743522093845554740681666841720206796756514002159097899004452746371432672", + "11133333007786916806537653763736510041397904969121754556887982143919681840159919608974969747422557814633960596319", + "90561577672782365102721874737156537447800052875073945376839636447536979602099666234669817779872333362600029687267", + "5450223346768511418345330845468131514992561567665451102957435878264997759483533580796977034429945593412389724558", + "235853237950439075722577332685219091953664185148611937130324227335365792837509030624805785387473218289296335533890", + "89396333230537847366322364436342481695658547414236326093675863540417141298105682739791578537835191912089484203681", + "115830385654423364502343021113073028365721746246232924567075277636234346135515984504152518055968175024342452068593", + "11263613907940703510226043272578077114062568830909561875804816268614922948545123959608046723806484765856945366386", + "85099371298035679603247495321780481321948685394995318303952199333118698031562067002765732094949837892213467834453", + "237849156256827398282019388933972533154056715710612980343582379691235964002811111531637163291964836316287473866944", + "121324456153144638357885760921484124420296650752569739652599982435599667566663818850130137668154167962818124679946", + "73600332144130508132510040050892177274732799381796146541825372722030832659283233558443467575385522990242420388929", + "44732797483932307692113794160403754043679743522093845554740681666841720206796756514002159097899004452746371432672", + "147751075268067473595930126919015490789314687953476809410426208666203744311411068892162888393693647317357680788622", + "253223744369647051774471619931702227054534749249995484100066505466186263584769989160049762529720081850824722544795", + "226753899873357669326157359116609350824063726018578587491538482132599227769745752321252816012800490263881222618536", + "176875521207730154886136120529839690202784860066517231969835480145708453592054364059780266900035568058186799176840" + ] ] }, "output": { diff --git a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_2.json b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_2.json index bdcb208e0..467857509 100644 --- a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_2.json +++ b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_2.json @@ -5,38 +5,41 @@ { "input": { "values": [ - ["30886639936493049016175318852868223421962513695924799011862965798142544864756272917016480650319179059444391880142", - "210714472424410627451557273311118253425679108293022860127144278352441005505195339659420709617036779682326673533186", - "101969549978420613687361685686211943788361418391955806064423246725556175258043096446227634997412743489772585976407", - "225606981549539274850150853435430709464645103097569777238240148161962808333007149588258118157237589076622092111900", - "94477902787810056005140833707514971680416163466937669331638397632516292559333058429168736236263588445181668773613", - "156965166665593649649919836247487186182263277589020558979047044043456286367751723077006781061358137877318135673282", - "137741518433065408317198878994358008499493756319076293122811213051853618947340414216838530582726247267590705502194", - "126547036337175013106414910386451161000910611736141896590177615068467376299665795605927145787930213987505973766731"], - ["2", - "4"], - ["26150522755032959261786285436959898551137848025504557005325333189168466417284586793885098543725273736029879389211", - "169754513648720531797744265077389392707096818238531464510797707592538650668826008029773773893361012602508598834793", - "172926009578431040673671475398833553033375949638930965254433842547261096474109828672139964685904707258254717562981", - "190737508410333459842769941580905855813961948279753848892816073188168697419955701512184037596994386514528425558736", - "1619785665530270858283718034422422029553639813181597813279549759777153426792287594479505827096186872882300711765", - "63694115876363306907024906479487765094262979049817897093877772048737865300854356915611214233650510384715733840309", - "138256625715993632167333368395637908886726696039897946710436000177289042559378071109224721507617736881530800812544", - "107857276706363405428900669135705736327281608718185524590709570009027542794964888233568166787710632979062032163927", - "117681951719142414345371029336876269027160875021843115377112400246872843732924494507290756295050251515524804614493", - "16932482238351125436073535332269385696327441869886865463514408400096260901383164481505901002564992831623879258663", - "46308513493241827384377341904914105301671994851198058483103383539450400464257917932036866988024757095122827891763", - "12774065758179916688827174319525442607170697024774973507481660009802587305759263737719583503498828398179974682702", - "26150522755032959261786285436959898551137848025504557005325333189168466417284586793885098543725273736029879389211", - "169754513648720531797744265077389392707096818238531464510797707592538650668826008029773773893361012602508598834793", - "172926009578431040673671475398833553033375949638930965254433842547261096474109828672139964685904707258254717562981", - "190737508410333459842769941580905855813961948279753848892816073188168697419955701512184037596994386514528425558736", - "187872074241198211214687054253180244660204447307195753216396863454451962530721491538379804696965671145239859590846", - "172889367615248592096001816975404506869611319851954669628812891122278364377518978073247194031011246327549860771430", - "227539811502856876734690781228675876891342950061206768786526280217867721882979938383152839106086209430522325241347", - "33214331578997688306993838825659395665609935174693430136691944882187065031251282996759071511854109007793069549563", - "231745969633345194328768544928321593376710672347115907704852838281813505601170157293937606734791368236398411854640", - "47237328152391646101146711114931457284784793248831449686265996627039097119070481703804420386021717476164037563466"] + [ + "30886639936493049016175318852868223421962513695924799011862965798142544864756272917016480650319179059444391880142", + "210714472424410627451557273311118253425679108293022860127144278352441005505195339659420709617036779682326673533186", + "101969549978420613687361685686211943788361418391955806064423246725556175258043096446227634997412743489772585976407", + "225606981549539274850150853435430709464645103097569777238240148161962808333007149588258118157237589076622092111900", + "94477902787810056005140833707514971680416163466937669331638397632516292559333058429168736236263588445181668773613", + "156965166665593649649919836247487186182263277589020558979047044043456286367751723077006781061358137877318135673282", + "137741518433065408317198878994358008499493756319076293122811213051853618947340414216838530582726247267590705502194", + "126547036337175013106414910386451161000910611736141896590177615068467376299665795605927145787930213987505973766731" + ], + ["2", "4"], + [ + "26150522755032959261786285436959898551137848025504557005325333189168466417284586793885098543725273736029879389211", + "169754513648720531797744265077389392707096818238531464510797707592538650668826008029773773893361012602508598834793", + "172926009578431040673671475398833553033375949638930965254433842547261096474109828672139964685904707258254717562981", + "190737508410333459842769941580905855813961948279753848892816073188168697419955701512184037596994386514528425558736", + "1619785665530270858283718034422422029553639813181597813279549759777153426792287594479505827096186872882300711765", + "63694115876363306907024906479487765094262979049817897093877772048737865300854356915611214233650510384715733840309", + "138256625715993632167333368395637908886726696039897946710436000177289042559378071109224721507617736881530800812544", + "107857276706363405428900669135705736327281608718185524590709570009027542794964888233568166787710632979062032163927", + "117681951719142414345371029336876269027160875021843115377112400246872843732924494507290756295050251515524804614493", + "16932482238351125436073535332269385696327441869886865463514408400096260901383164481505901002564992831623879258663", + "46308513493241827384377341904914105301671994851198058483103383539450400464257917932036866988024757095122827891763", + "12774065758179916688827174319525442607170697024774973507481660009802587305759263737719583503498828398179974682702", + "26150522755032959261786285436959898551137848025504557005325333189168466417284586793885098543725273736029879389211", + "169754513648720531797744265077389392707096818238531464510797707592538650668826008029773773893361012602508598834793", + "172926009578431040673671475398833553033375949638930965254433842547261096474109828672139964685904707258254717562981", + "190737508410333459842769941580905855813961948279753848892816073188168697419955701512184037596994386514528425558736", + "187872074241198211214687054253180244660204447307195753216396863454451962530721491538379804696965671145239859590846", + "172889367615248592096001816975404506869611319851954669628812891122278364377518978073247194031011246327549860771430", + "227539811502856876734690781228675876891342950061206768786526280217867721882979938383152839106086209430522325241347", + "33214331578997688306993838825659395665609935174693430136691944882187065031251282996759071511854109007793069549563", + "231745969633345194328768544928321593376710672347115907704852838281813505601170157293937606734791368236398411854640", + "47237328152391646101146711114931457284784793248831449686265996627039097119070481703804420386021717476164037563466" + ] ] }, "output": { diff --git a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_5.json b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_5.json index d1bc81b51..22837cc97 100644 --- a/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_5.json +++ b/zokrates_core_test/tests/tests/snark/snark_verify_bls12_377_5.json @@ -5,47 +5,47 @@ { "input": { "values": [ - ["60457684924193218954780799695448128402450659922819148866042534731462934804174889585425668379894806827192129355035", - "30692976080216123852486339295726836787768525847434467843252380267593056117653493955651719058012291818530914713503", - "125357500613234885873309304302314409734224357144836572740733227274842238671614205545693580811504410323545780196986", - "247651569074486453849718457544382537302063316144666696072138162914150063434773021124866593709430271032906775848230", - "205925817697152648573187530836257591106879527302418969217282393297385329815356611501846344314549412686571096624542", - "52408210490520029867007596145203947635265945726032430791270964404506413872638222587937059680769423104224418341783", - "245391920863498220927838330312555206148254951255756591670548373412908886220063896460749603543488483619267089689381", - "78589112605630898410537770266153128219408270888620016803188045523021815277982064356841045190284469829851165791293"], - ["2", - "2", - "2", - "2", - "8"], - ["177010185638377511324501604520563739739317808509681430951164029757345810095174696221494505373089763385490312116358", - "153053794329278051178743982884522858761476481700312111393093980133181276780354993379856934110282786295862092443919", - "119352601414532465114802089751399530705471140760948692288569726825270783170792459863146836606243083937386903791326", - "154395739702801688661668736325735092854144372763349598896957725187031688340840056329057020108410010039817499025290", - "219300867221825583189537695275783744511701200221265601874271468574900788700976161865886103325397401233680596662586", - "6184162650897786738969218350774078215930829358700672611442020481749290685465136203052430712512726892174302053960", - "223615432567648858214064557325028920329759681028000034077399269834838357009569712943919669143358231307616009815434", - "175981229674044997402551815995123920812483064905277870260193130162059294237262155034620065210131116619520563506519", - "149763821034046861511733819294494872607002147076380551480035933618221202037885306159876853613449195409389418630899", - "63613896436066139625271941484202721828670668029032907443649108037543119043920396499152980372905932782160074585332", - "83664647128245200609718804963435898883339854035469313658046832013326011731523365594256699720796643575140884572905", - "144568623182910160643612162930255558274463299944237682869943691750723939109705466332836308875557772911097578331002", - "177010185638377511324501604520563739739317808509681430951164029757345810095174696221494505373089763385490312116358", - "153053794329278051178743982884522858761476481700312111393093980133181276780354993379856934110282786295862092443919", - "119352601414532465114802089751399530705471140760948692288569726825270783170792459863146836606243083937386903791326", - "154395739702801688661668736325735092854144372763349598896957725187031688340840056329057020108410010039817499025290", - "149057616125424973478283591473814309565673764317022249169395023211664620308712452144732942791215282170059517214134", - "41780114592407788188439225711342125468082786659527520800331438243958377257657588645284569742745602805176661321513", - "221720891820590314635918157317325200201212159883016241641294528146177946855934688201173659819769674033460232363042", - "50797017918692117248188277962054664678983362179572320962314605303222488912037808946253081883636411158993624881368", - "45015881196637283857089803245084152220024891684216432418680197321055655838083895789012460620698622411348666936603", - "6614931577154387449192604140382084380965299734550787093003728565193454839715263838958636766466130999302518638149", - "245269024464910939632469903406535269950072210280644644046910525955649284275684019199442256400616717695144071175450", - "43420687027898212877864397162744483839228857355048382441491263977288496076621257227893835793326940537504242772685", - "83272518748948630820579332810320118472860479700707035306680609335770289292207880205558249065217561951629308682324", - "6938552589263177251253935997174459628120498877543020100980702178088439767196046212767463370826879237199769600513", - "170649759404749298159628447642105098367401676132263627894428382159110486377464596992614660456131317719055604455895", - "52917028619173381482821776446008133295138882162362339762583394451153359715914188291769779536313083815565710768404"] + [ + "60457684924193218954780799695448128402450659922819148866042534731462934804174889585425668379894806827192129355035", + "30692976080216123852486339295726836787768525847434467843252380267593056117653493955651719058012291818530914713503", + "125357500613234885873309304302314409734224357144836572740733227274842238671614205545693580811504410323545780196986", + "247651569074486453849718457544382537302063316144666696072138162914150063434773021124866593709430271032906775848230", + "205925817697152648573187530836257591106879527302418969217282393297385329815356611501846344314549412686571096624542", + "52408210490520029867007596145203947635265945726032430791270964404506413872638222587937059680769423104224418341783", + "245391920863498220927838330312555206148254951255756591670548373412908886220063896460749603543488483619267089689381", + "78589112605630898410537770266153128219408270888620016803188045523021815277982064356841045190284469829851165791293" + ], + ["2", "2", "2", "2", "8"], + [ + "177010185638377511324501604520563739739317808509681430951164029757345810095174696221494505373089763385490312116358", + "153053794329278051178743982884522858761476481700312111393093980133181276780354993379856934110282786295862092443919", + "119352601414532465114802089751399530705471140760948692288569726825270783170792459863146836606243083937386903791326", + "154395739702801688661668736325735092854144372763349598896957725187031688340840056329057020108410010039817499025290", + "219300867221825583189537695275783744511701200221265601874271468574900788700976161865886103325397401233680596662586", + "6184162650897786738969218350774078215930829358700672611442020481749290685465136203052430712512726892174302053960", + "223615432567648858214064557325028920329759681028000034077399269834838357009569712943919669143358231307616009815434", + "175981229674044997402551815995123920812483064905277870260193130162059294237262155034620065210131116619520563506519", + "149763821034046861511733819294494872607002147076380551480035933618221202037885306159876853613449195409389418630899", + "63613896436066139625271941484202721828670668029032907443649108037543119043920396499152980372905932782160074585332", + "83664647128245200609718804963435898883339854035469313658046832013326011731523365594256699720796643575140884572905", + "144568623182910160643612162930255558274463299944237682869943691750723939109705466332836308875557772911097578331002", + "177010185638377511324501604520563739739317808509681430951164029757345810095174696221494505373089763385490312116358", + "153053794329278051178743982884522858761476481700312111393093980133181276780354993379856934110282786295862092443919", + "119352601414532465114802089751399530705471140760948692288569726825270783170792459863146836606243083937386903791326", + "154395739702801688661668736325735092854144372763349598896957725187031688340840056329057020108410010039817499025290", + "149057616125424973478283591473814309565673764317022249169395023211664620308712452144732942791215282170059517214134", + "41780114592407788188439225711342125468082786659527520800331438243958377257657588645284569742745602805176661321513", + "221720891820590314635918157317325200201212159883016241641294528146177946855934688201173659819769674033460232363042", + "50797017918692117248188277962054664678983362179572320962314605303222488912037808946253081883636411158993624881368", + "45015881196637283857089803245084152220024891684216432418680197321055655838083895789012460620698622411348666936603", + "6614931577154387449192604140382084380965299734550787093003728565193454839715263838958636766466130999302518638149", + "245269024464910939632469903406535269950072210280644644046910525955649284275684019199442256400616717695144071175450", + "43420687027898212877864397162744483839228857355048382441491263977288496076621257227893835793326940537504242772685", + "83272518748948630820579332810320118472860479700707035306680609335770289292207880205558249065217561951629308682324", + "6938552589263177251253935997174459628120498877543020100980702178088439767196046212767463370826879237199769600513", + "170649759404749298159628447642105098367401676132263627894428382159110486377464596992614660456131317719055604455895", + "52917028619173381482821776446008133295138882162362339762583394451153359715914188291769779536313083815565710768404" + ] ] }, "output": { diff --git a/zokrates_core_test/tests/tests/split_bls.json b/zokrates_core_test/tests/tests/split_bls.json index d813830cb..1f4456f34 100644 --- a/zokrates_core_test/tests/tests/split_bls.json +++ b/zokrates_core_test/tests/tests/split_bls.json @@ -1,46 +1,1074 @@ { - "entry_point": "./tests/tests/split.zok", - "curves": ["Bls12_381"], - "tests": [ - { - "input": { - "values": ["140276878374021757553346392020722373336"] - }, - "output": { - "Ok": { - "value": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, true, false, false, true, true, false, false, false, true, false, false, false, false, true, false, true, true, false, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, true, true, true, false, true, true, false, false, false, false, true, true, true, true, false, false, false, false, false, true, true, false, true, false, false, false, true, true, false, true, true, false, false, true, false, false, false, false, false, false, false, true, true, false, true, true, false, true, false, true, true, false, true, false, false, true, true, false, true, true, false, true, false, true, true, true, true, false, true, false, true, false, false, true, true, true, true, false, true, false, false, true, false, true, true, false, true, true, false, false, false] - } - } - }, - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false] - } - } - }, - { - "input": { - "values": ["14474011154664524427946373126085988481658748083205070504932198000989141204991"] - }, - "output": { - "Ok": { - "value": [false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }, - "output": { - "Ok": { - "value": [false, true, true, false, false, false, false, false, true, true, false, false, true, false, false, false, true, false, false, true, true, true, false, false, true, true, true, false, false, true, false, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, true, true, false, true, false, false, false, false, false, false, false, true, false, true, false, false, true, true, false, true, true, true, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, true, false, true, true, false, true, true, false, true, false, false, false, false, false, false, true, true, false, false, false, false, false, false, true, false, true, false, true, true, false, false, false, false, true, false, true, true, true, false, true, false, false, true, false, true, false, false, false, false, false, true, true, false, false, true, true, true, true, true, false, true, false, false, false, false, true, false, false, true, false, false, false, false, true, true, true, true, false, false, true, true, false, true, true, true, false, false, true, false, true, true, true, false, false, false, false, true, false, false, true, false, false, false, true, false, true, false, false, false, false, true, true, true, true, true, false, false, false, false, true, true, true, true, true, false, true, false, true, true, false, false, true, false, false, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false] - } - } - } - ] + "entry_point": "./tests/tests/split.zok", + "curves": ["Bls12_381"], + "tests": [ + { + "input": { + "values": ["140276878374021757553346392020722373336"] + }, + "output": { + "Ok": { + "value": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + true, + false, + true, + false, + false, + true, + true, + false, + false, + false, + true, + false, + false, + false, + false, + true, + false, + true, + true, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + false, + true, + true, + true, + false, + true, + true, + false, + false, + false, + false, + true, + true, + true, + true, + false, + false, + false, + false, + false, + true, + true, + false, + true, + false, + false, + false, + true, + true, + false, + true, + true, + false, + false, + true, + false, + false, + false, + false, + false, + false, + false, + true, + true, + false, + true, + true, + false, + true, + false, + true, + true, + false, + true, + false, + false, + true, + true, + false, + true, + true, + false, + true, + false, + true, + true, + true, + true, + false, + true, + false, + true, + false, + false, + true, + true, + true, + true, + false, + true, + false, + false, + true, + false, + true, + true, + false, + true, + true, + false, + false, + false + ] + } + } + }, + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + } + } + }, + { + "input": { + "values": [ + "14474011154664524427946373126085988481658748083205070504932198000989141204991" + ] + }, + "output": { + "Ok": { + "value": [ + false, + false, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Ok": { + "value": [ + false, + true, + true, + false, + false, + false, + false, + false, + true, + true, + false, + false, + true, + false, + false, + false, + true, + false, + false, + true, + true, + true, + false, + false, + true, + true, + true, + false, + false, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false, + true, + true, + false, + false, + false, + true, + true, + false, + true, + false, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + true, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + true, + true, + false, + true, + true, + false, + true, + true, + false, + true, + false, + false, + false, + false, + false, + false, + true, + true, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + true, + true, + false, + false, + false, + false, + true, + false, + true, + true, + true, + false, + true, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + true, + false, + false, + true, + true, + true, + true, + true, + false, + true, + false, + false, + false, + false, + true, + false, + false, + true, + false, + false, + false, + false, + true, + true, + true, + true, + false, + false, + true, + true, + false, + true, + true, + true, + false, + false, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false, + true, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + true, + true, + true, + true, + true, + false, + false, + false, + false, + true, + true, + true, + true, + true, + false, + true, + false, + true, + true, + false, + false, + true, + false, + false, + true, + true, + true, + true, + true, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/split_bn.json b/zokrates_core_test/tests/tests/split_bn.json index 682448dea..76fc87404 100644 --- a/zokrates_core_test/tests/tests/split_bn.json +++ b/zokrates_core_test/tests/tests/split_bn.json @@ -1,46 +1,1070 @@ { - "entry_point": "./tests/tests/split.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["140276878374021757553346392020722373336"] - }, - "output": { - "Ok": { - "value": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, true, false, false, true, true, false, false, false, true, false, false, false, false, true, false, true, true, false, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, true, true, true, false, true, true, false, false, false, false, true, true, true, true, false, false, false, false, false, true, true, false, true, false, false, false, true, true, false, true, true, false, false, true, false, false, false, false, false, false, false, true, true, false, true, true, false, true, false, true, true, false, true, false, false, true, true, false, true, true, false, true, false, true, true, true, true, false, true, false, true, false, false, true, true, true, true, false, true, false, false, true, false, true, true, false, true, true, false, false, false] - } - } - }, - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false] - } - } - }, - { - "input": { - "values": ["14474011154664524427946373126085988481658748083205070504932198000989141204991"] - }, - "output": { - "Ok": { - "value": [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true] - } - } - }, - { - "input": { - "values": ["21888242871839275222246405745257275088548364400416034343698204186575808495616"] - }, - "output": { - "Ok": { - "value": [true, true, false, false, false, false, false, true, true, false, false, true, false, false, false, true, false, false, true, true, true, false, false, true, true, true, false, false, true, false, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, true, true, false, true, false, false, false, false, false, false, false, true, false, true, false, false, true, true, false, true, true, true, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, true, false, true, true, false, true, true, false, true, false, false, false, false, false, false, true, true, false, false, false, false, false, false, true, false, true, false, true, true, false, false, false, false, true, false, true, true, true, false, true, false, false, true, false, true, false, false, false, false, false, true, true, false, false, true, true, true, true, true, false, true, false, false, false, false, true, false, false, true, false, false, false, false, true, true, true, true, false, false, true, true, false, true, true, true, false, false, true, false, true, true, true, false, false, false, false, true, false, false, true, false, false, false, true, false, true, false, false, false, false, true, true, true, true, true, false, false, false, false, true, true, true, true, true, false, true, false, true, true, false, false, true, false, false, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/split.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["140276878374021757553346392020722373336"] + }, + "output": { + "Ok": { + "value": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + true, + false, + true, + false, + false, + true, + true, + false, + false, + false, + true, + false, + false, + false, + false, + true, + false, + true, + true, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + false, + true, + true, + true, + false, + true, + true, + false, + false, + false, + false, + true, + true, + true, + true, + false, + false, + false, + false, + false, + true, + true, + false, + true, + false, + false, + false, + true, + true, + false, + true, + true, + false, + false, + true, + false, + false, + false, + false, + false, + false, + false, + true, + true, + false, + true, + true, + false, + true, + false, + true, + true, + false, + true, + false, + false, + true, + true, + false, + true, + true, + false, + true, + false, + true, + true, + true, + true, + false, + true, + false, + true, + false, + false, + true, + true, + true, + true, + false, + true, + false, + false, + true, + false, + true, + true, + false, + true, + true, + false, + false, + false + ] + } + } + }, + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + } + } + }, + { + "input": { + "values": [ + "14474011154664524427946373126085988481658748083205070504932198000989141204991" + ] + }, + "output": { + "Ok": { + "value": [ + false, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Ok": { + "value": [ + true, + true, + false, + false, + false, + false, + false, + true, + true, + false, + false, + true, + false, + false, + false, + true, + false, + false, + true, + true, + true, + false, + false, + true, + true, + true, + false, + false, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false, + true, + true, + false, + false, + false, + true, + true, + false, + true, + false, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + true, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + true, + true, + false, + true, + true, + false, + true, + true, + false, + true, + false, + false, + false, + false, + false, + false, + true, + true, + false, + false, + false, + false, + false, + false, + true, + false, + true, + false, + true, + true, + false, + false, + false, + false, + true, + false, + true, + true, + true, + false, + true, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + true, + false, + false, + true, + true, + true, + true, + true, + false, + true, + false, + false, + false, + false, + true, + false, + false, + true, + false, + false, + false, + false, + true, + true, + true, + true, + false, + false, + true, + true, + false, + true, + true, + true, + false, + false, + true, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false, + true, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + true, + true, + true, + true, + true, + false, + false, + false, + false, + true, + true, + true, + true, + true, + false, + true, + false, + true, + true, + false, + false, + true, + false, + false, + true, + true, + true, + true, + true, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/spread_slice.json b/zokrates_core_test/tests/tests/spread_slice.json index d09d9424f..195657e43 100644 --- a/zokrates_core_test/tests/tests/spread_slice.json +++ b/zokrates_core_test/tests/tests/spread_slice.json @@ -1,17 +1,17 @@ { - "entry_point": "./tests/tests/spread_slice.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "max_constraint_count": 9, - "tests": [ - { - "input": { - "values": [["1", "2", "3"], ["4", "5", "6"], "7"] - }, - "output": { - "Ok": { - "value": ["1", "2", "5", "6", "1", "2", "3", "5", "7"] - } - } - } - ] + "entry_point": "./tests/tests/spread_slice.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "max_constraint_count": 9, + "tests": [ + { + "input": { + "values": [["1", "2", "3"], ["4", "5", "6"], "7"] + }, + "output": { + "Ok": { + "value": ["1", "2", "5", "6", "1", "2", "3", "5", "7"] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/structs/constant.json b/zokrates_core_test/tests/tests/structs/constant.json index a989144a4..f2430b646 100644 --- a/zokrates_core_test/tests/tests/structs/constant.json +++ b/zokrates_core_test/tests/tests/structs/constant.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/structs/constant.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/structs/constant.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/structs/identity.json b/zokrates_core_test/tests/tests/structs/identity.json index 681d852fc..262a3cc80 100644 --- a/zokrates_core_test/tests/tests/structs/identity.json +++ b/zokrates_core_test/tests/tests/structs/identity.json @@ -1,41 +1,41 @@ { - "entry_point": "./tests/tests/structs/identity.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "abi": false, - "tests": [ - { - "input": { - "values": ["42", "0"] - }, - "output": { - "Ok": { - "value": ["42", "0"] - } - } - }, - { - "input": { - "values": ["42", "1"] - }, - "output": { - "Ok": { - "value": ["42", "1"] - } - } - }, - { - "input": { - "values": ["42", "3"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "9", - "right": "3", - "error": "ArgumentBitness" - } - } - } - } - ] + "entry_point": "./tests/tests/structs/identity.zok", + "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], + "abi": false, + "tests": [ + { + "input": { + "values": ["42", "0"] + }, + "output": { + "Ok": { + "value": ["42", "0"] + } + } + }, + { + "input": { + "values": ["42", "1"] + }, + "output": { + "Ok": { + "value": ["42", "1"] + } + } + }, + { + "input": { + "values": ["42", "3"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "9", + "right": "3", + "error": "ArgumentBitness" + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/structs/member_order.json b/zokrates_core_test/tests/tests/structs/member_order.json index bf493ffb5..f91a79579 100644 --- a/zokrates_core_test/tests/tests/structs/member_order.json +++ b/zokrates_core_test/tests/tests/structs/member_order.json @@ -1,20 +1,22 @@ { - "entry_point": "./tests/tests/structs/member_order.zok", - "curves": ["Bn128"], - "tests": [ - { - "abi": true, - "input": { - "values": [{ - "a":true, - "b": "3" - }] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] + "entry_point": "./tests/tests/structs/member_order.zok", + "curves": ["Bn128"], + "tests": [ + { + "abi": true, + "input": { + "values": [ + { + "a": true, + "b": "3" + } + ] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/tuples/conditional.json b/zokrates_core_test/tests/tests/tuples/conditional.json index afe10214a..f49ee9ab0 100644 --- a/zokrates_core_test/tests/tests/tuples/conditional.json +++ b/zokrates_core_test/tests/tests/tuples/conditional.json @@ -1,26 +1,26 @@ { - "entry_point": "./tests/tests/tuples/conditional.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [true] - }, - "output": { - "Ok": { - "value": ["1", "2"] - } - } - }, - { - "input": { - "values": [false] - }, - "output": { - "Ok": { - "value": ["2", "1"] - } - } + "entry_point": "./tests/tests/tuples/conditional.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [true] + }, + "output": { + "Ok": { + "value": ["1", "2"] } - ] + } + }, + { + "input": { + "values": [false] + }, + "output": { + "Ok": { + "value": ["2", "1"] + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/tuples/constant.json b/zokrates_core_test/tests/tests/tuples/constant.json index 486324dcf..4cbdf1c5b 100644 --- a/zokrates_core_test/tests/tests/tuples/constant.json +++ b/zokrates_core_test/tests/tests/tuples/constant.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/tuples/constant.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/tuples/constant.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/tuples/element_order.json b/zokrates_core_test/tests/tests/tuples/element_order.json index 09f47ed4d..543c506c8 100644 --- a/zokrates_core_test/tests/tests/tuples/element_order.json +++ b/zokrates_core_test/tests/tests/tuples/element_order.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/tuples/element_order.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [["3", true]] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/tuples/element_order.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [["3", true]] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/tuples/empty.json b/zokrates_core_test/tests/tests/tuples/empty.json index f13f140c3..237b852cd 100644 --- a/zokrates_core_test/tests/tests/tuples/empty.json +++ b/zokrates_core_test/tests/tests/tuples/empty.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/tuples/empty.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [[]] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/tuples/empty.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [[]] + }, + "output": { + "Ok": { + "value": [] } - ] + } + } + ] } diff --git a/zokrates_core_test/tests/tests/tuples/identity.json b/zokrates_core_test/tests/tests/tuples/identity.json index 205e0c6d7..9d0b39033 100644 --- a/zokrates_core_test/tests/tests/tuples/identity.json +++ b/zokrates_core_test/tests/tests/tuples/identity.json @@ -1,41 +1,41 @@ { - "entry_point": "./tests/tests/tuples/identity.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [["42", false]] - }, - "output": { - "Ok": { - "value": ["42", false] - } - } - }, - { - "input": { - "values": [["42", true]] - }, - "output": { - "Ok": { - "value": ["42", true] - } - } - }, - { - "abi": false, - "input": { - "values": ["42", "3"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "9", - "right": "3", - "error": "ArgumentBitness" - } - } - } - } - ] + "entry_point": "./tests/tests/tuples/identity.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [["42", false]] + }, + "output": { + "Ok": { + "value": ["42", false] + } + } + }, + { + "input": { + "values": [["42", true]] + }, + "output": { + "Ok": { + "value": ["42", true] + } + } + }, + { + "abi": false, + "input": { + "values": ["42", "3"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "9", + "right": "3", + "error": "ArgumentBitness" + } + } + } + } + ] } diff --git a/zokrates_core_test/tests/tests/uint/add_loop.json b/zokrates_core_test/tests/tests/uint/add_loop.json index 4888d28e5..42f082bb1 100644 --- a/zokrates_core_test/tests/tests/uint/add_loop.json +++ b/zokrates_core_test/tests/tests/uint/add_loop.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/uint/add_loop.zok", - "max_constraint_count": 76, - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/add_loop.zok", + "max_constraint_count": 76, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/uint/ch.json b/zokrates_core_test/tests/tests/uint/ch.json index 098d6ec0f..0039cf2a6 100644 --- a/zokrates_core_test/tests/tests/uint/ch.json +++ b/zokrates_core_test/tests/tests/uint/ch.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/uint/ch.zok", - "max_constraint_count": 200, - "tests": [ - { - "input": { - "values": ["0x00000000", "0x00000000", "0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/ch.zok", + "max_constraint_count": 200, + "tests": [ + { + "input": { + "values": ["0x00000000", "0x00000000", "0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/conditional.json b/zokrates_core_test/tests/tests/uint/conditional.json index 329cccb85..07b2ffc22 100644 --- a/zokrates_core_test/tests/tests/uint/conditional.json +++ b/zokrates_core_test/tests/tests/uint/conditional.json @@ -1,25 +1,26 @@ { - "entry_point": "./tests/tests/uint/conditional.zok", - "max_constraint_count": 31, - "tests": [{ - "input": { - "values": [true, "0x00", "0xff"] - }, - "output": { - "Ok": { - "value": "0x00" - } - } - }, - { - "input": { - "values": [false, "0x00", "0xff"] - }, - "output": { - "Ok": { - "value": "0xff" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/conditional.zok", + "max_constraint_count": 31, + "tests": [ + { + "input": { + "values": [true, "0x00", "0xff"] + }, + "output": { + "Ok": { + "value": "0x00" + } + } + }, + { + "input": { + "values": [false, "0x00", "0xff"] + }, + "output": { + "Ok": { + "value": "0xff" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/constant.json b/zokrates_core_test/tests/tests/uint/constant.json index 3271e92fa..dec24a18d 100644 --- a/zokrates_core_test/tests/tests/uint/constant.json +++ b/zokrates_core_test/tests/tests/uint/constant.json @@ -1,15 +1,16 @@ { - "entry_point": "./tests/tests/uint/constant.zok", - "max_constraint_count": 1, - "tests": [{ - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": "0x01234567" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/constant.zok", + "max_constraint_count": 1, + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": "0x01234567" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/eq.json b/zokrates_core_test/tests/tests/uint/eq.json index 9c1e9c7e0..527313eb5 100644 --- a/zokrates_core_test/tests/tests/uint/eq.json +++ b/zokrates_core_test/tests/tests/uint/eq.json @@ -1,4 +1,4 @@ { - "entry_point": "./tests/tests/uint/eq.zok", - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/eq.zok", + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/uint/extend.json b/zokrates_core_test/tests/tests/uint/extend.json index 86e32de3b..f2ce8cf88 100644 --- a/zokrates_core_test/tests/tests/uint/extend.json +++ b/zokrates_core_test/tests/tests/uint/extend.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/uint/extend.zok", - "max_constraint_count": 2280, - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/extend.zok", + "max_constraint_count": 2280, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/uint/from_to_bits.json b/zokrates_core_test/tests/tests/uint/from_to_bits.json index dd0eb612d..7565e3df5 100644 --- a/zokrates_core_test/tests/tests/uint/from_to_bits.json +++ b/zokrates_core_test/tests/tests/uint/from_to_bits.json @@ -1,35 +1,36 @@ { - "entry_point": "./tests/tests/uint/from_to_bits.zok", - "max_constraint_count": 128, - "tests": [{ - "input": { - "values": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"] - }, - "output": { - "Ok": { - "value": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"] - } - } - }, - { - "input": { - "values": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"] - }, - "output": { - "Ok": { - "value": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"] - } - } - }, - { - "input": { - "values": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"] - }, - "output": { - "Ok": { - "value": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/from_to_bits.zok", + "max_constraint_count": 128, + "tests": [ + { + "input": { + "values": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"] + }, + "output": { + "Ok": { + "value": ["0x0000000000000000", "0x00000000", "0x0000", "0x00"] + } + } + }, + { + "input": { + "values": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"] + }, + "output": { + "Ok": { + "value": ["0xffffffffffffffff", "0xffffffff", "0xffff", "0xff"] + } + } + }, + { + "input": { + "values": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"] + }, + "output": { + "Ok": { + "value": ["0x1234567812345678", "0x12345678", "0x1234", "0x12"] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/maj.json b/zokrates_core_test/tests/tests/uint/maj.json index 030a147b3..d44225e77 100644 --- a/zokrates_core_test/tests/tests/uint/maj.json +++ b/zokrates_core_test/tests/tests/uint/maj.json @@ -1,25 +1,26 @@ { - "entry_point": "./tests/tests/uint/maj.zok", - "max_constraint_count": 166, - "tests": [{ - "input": { - "values": ["0x00000000", "0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x01234567", "0x23456789"] - }, - "output": { - "Ok": { - "value": "0x03254769" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/maj.zok", + "max_constraint_count": 166, + "tests": [ + { + "input": { + "values": ["0x00000000", "0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" + } + } + }, + { + "input": { + "values": ["0x01234567", "0x23456789"] + }, + "output": { + "Ok": { + "value": "0x03254769" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/operations.json b/zokrates_core_test/tests/tests/uint/operations.json index b86ab498d..23a4bf3a1 100644 --- a/zokrates_core_test/tests/tests/uint/operations.json +++ b/zokrates_core_test/tests/tests/uint/operations.json @@ -1,14 +1,19 @@ { - "entry_point": "./tests/tests/uint/operations.zok", - "tests": [{ - "input": { - "values": ["0x12345678", "0x01234567", ["0xfefefefe", "0xefefefef", "0xffffffff", "0xeeeeeeee"]] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/operations.zok", + "tests": [ + { + "input": { + "values": [ + "0x12345678", + "0x01234567", + ["0xfefefefe", "0xefefefef", "0xffffffff", "0xeeeeeeee"] + ] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/propagation/rotate.json b/zokrates_core_test/tests/tests/uint/propagation/rotate.json index 6b55671f4..a27b8af64 100644 --- a/zokrates_core_test/tests/tests/uint/propagation/rotate.json +++ b/zokrates_core_test/tests/tests/uint/propagation/rotate.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/uint/propagation/rotate.zok", - "max_constraint_count": 1, - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/propagation/rotate.zok", + "max_constraint_count": 1, + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/rotate.json b/zokrates_core_test/tests/tests/uint/rotate.json index 637219eef..de3df9d09 100644 --- a/zokrates_core_test/tests/tests/uint/rotate.json +++ b/zokrates_core_test/tests/tests/uint/rotate.json @@ -1,25 +1,26 @@ { - "entry_point": "./tests/tests/uint/rotate.zok", - "max_constraint_count": 34, - "tests": [{ - "input": { - "values": ["0x000000f0"] - }, - "output": { - "Ok": { - "value": "0x0000000f" - } - } - }, - { - "input": { - "values": ["0x12345678"] - }, - "output": { - "Ok": { - "value": "0x81234567" - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/rotate.zok", + "max_constraint_count": 34, + "tests": [ + { + "input": { + "values": ["0x000000f0"] + }, + "output": { + "Ok": { + "value": "0x0000000f" + } + } + }, + { + "input": { + "values": ["0x12345678"] + }, + "output": { + "Ok": { + "value": "0x81234567" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/sha256.json b/zokrates_core_test/tests/tests/uint/sha256.json index 260a0f4ca..4e45a8669 100644 --- a/zokrates_core_test/tests/tests/uint/sha256.json +++ b/zokrates_core_test/tests/tests/uint/sha256.json @@ -1,15 +1,46 @@ { - "entry_point": "./tests/tests/uint/sha256.zok", - "max_constraint_count": 30000, - "tests": [{ - "input": { - "values": [[["0x243f6a88", "0x85a308d3", "0x13198a2e", "0x03707344", "0xa4093822", "0x299f31d0", "0x082efa98", "0xec4e6c89", "0x452821e6", "0x38d01377", "0xbe5466cf", "0x34e90c6c", "0xc0ac29b7", "0xc97c50dd", "0x3f84d5b5", "0xb5470917"]]] - }, - "output": { - "Ok": { - "value": ["0xcf0ae4eb", "0x67d38ffe", "0xb9406898", "0x4b22abde", "0x4e92bc54", "0x8d14585e", "0x48dca888", "0x2d7b09ce"] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/sha256.zok", + "max_constraint_count": 30000, + "tests": [ + { + "input": { + "values": [ + [ + [ + "0x243f6a88", + "0x85a308d3", + "0x13198a2e", + "0x03707344", + "0xa4093822", + "0x299f31d0", + "0x082efa98", + "0xec4e6c89", + "0x452821e6", + "0x38d01377", + "0xbe5466cf", + "0x34e90c6c", + "0xc0ac29b7", + "0xc97c50dd", + "0x3f84d5b5", + "0xb5470917" + ] + ] + ] + }, + "output": { + "Ok": { + "value": [ + "0xcf0ae4eb", + "0x67d38ffe", + "0xb9406898", + "0x4b22abde", + "0x4e92bc54", + "0x8d14585e", + "0x48dca888", + "0x2d7b09ce" + ] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/temp1.json b/zokrates_core_test/tests/tests/uint/temp1.json index 88a00b54e..06c3d5c68 100644 --- a/zokrates_core_test/tests/tests/uint/temp1.json +++ b/zokrates_core_test/tests/tests/uint/temp1.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/uint/temp1.zok", - "max_constraint_count": 398, - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/temp1.zok", + "max_constraint_count": 398, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/uint/temp2.json b/zokrates_core_test/tests/tests/uint/temp2.json index 2bc7a3219..2884a85b1 100644 --- a/zokrates_core_test/tests/tests/uint/temp2.json +++ b/zokrates_core_test/tests/tests/uint/temp2.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/uint/temp2.zok", - "max_constraint_count": 364, - "tests": [] -} \ No newline at end of file + "entry_point": "./tests/tests/uint/temp2.zok", + "max_constraint_count": 364, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/uint/u16/add.json b/zokrates_core_test/tests/tests/uint/u16/add.json index 48f5e2f36..4b47fb6ac 100644 --- a/zokrates_core_test/tests/tests/uint/u16/add.json +++ b/zokrates_core_test/tests/tests/uint/u16/add.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/add.zok", "max_constraint_count": 53, - "tests": [ + "tests": [ { "input": { "values": ["0xffff", "0x0001"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/and.json b/zokrates_core_test/tests/tests/uint/u16/and.json index 86c367143..4dde99276 100644 --- a/zokrates_core_test/tests/tests/uint/u16/and.json +++ b/zokrates_core_test/tests/tests/uint/u16/and.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u16/and.zok", - "max_constraint_count": 51, - "tests": [ - { - "input": { - "values": ["0xffff", "0xffff"] - }, - "output": { - "Ok": { - "value": "0xffff" - } - } - }, - { - "input": { - "values": ["0xffff", "0x0000"] - }, - "output": { - "Ok": { - "value": "0x0000" - } - } - }, - { - "input": { - "values": ["0x1234", "0x5678"] - }, - "output": { - "Ok": { - "value": "0x1230" - } - } + "entry_point": "./tests/tests/uint/u16/and.zok", + "max_constraint_count": 51, + "tests": [ + { + "input": { + "values": ["0xffff", "0xffff"] + }, + "output": { + "Ok": { + "value": "0xffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffff", "0x0000"] + }, + "output": { + "Ok": { + "value": "0x0000" + } + } + }, + { + "input": { + "values": ["0x1234", "0x5678"] + }, + "output": { + "Ok": { + "value": "0x1230" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u16/div.json b/zokrates_core_test/tests/tests/uint/u16/div.json index e18dea1c4..8a788c788 100644 --- a/zokrates_core_test/tests/tests/uint/u16/div.json +++ b/zokrates_core_test/tests/tests/uint/u16/div.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u16/div.zok", - "max_constraint_count": 88, - "tests": [ - { - "input": { - "values": ["0x1000", "0x1000"] - }, - "output": { - "Ok": { - "value": "0x0001" - } - } - }, - { - "input": { - "values": ["0x1000", "0x0002"] - }, - "output": { - "Ok": { - "value": "0x0800" - } - } - }, - { - "input": { - "values": ["0x1001", "0x0002"] - }, - "output": { - "Ok": { - "value": "0x0800" - } - } + "entry_point": "./tests/tests/uint/u16/div.zok", + "max_constraint_count": 88, + "tests": [ + { + "input": { + "values": ["0x1000", "0x1000"] + }, + "output": { + "Ok": { + "value": "0x0001" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0x1000", "0x0002"] + }, + "output": { + "Ok": { + "value": "0x0800" + } + } + }, + { + "input": { + "values": ["0x1001", "0x0002"] + }, + "output": { + "Ok": { + "value": "0x0800" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u16/eq.json b/zokrates_core_test/tests/tests/uint/u16/eq.json index 615a2a896..d09892bfb 100644 --- a/zokrates_core_test/tests/tests/uint/u16/eq.json +++ b/zokrates_core_test/tests/tests/uint/u16/eq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/eq.zok", "max_constraint_count": 37, - "tests": [ + "tests": [ { "input": { "values": ["0x0002", "0x0002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/gt.json b/zokrates_core_test/tests/tests/uint/u16/gt.json index 96eb30f5c..fecff162c 100644 --- a/zokrates_core_test/tests/tests/uint/u16/gt.json +++ b/zokrates_core_test/tests/tests/uint/u16/gt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/gt.zok", "max_constraint_count": 697, - "tests": [ + "tests": [ { "input": { "values": ["0x0004", "0x0002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/gte.json b/zokrates_core_test/tests/tests/uint/u16/gte.json index 06253494c..226dc8a2d 100644 --- a/zokrates_core_test/tests/tests/uint/u16/gte.json +++ b/zokrates_core_test/tests/tests/uint/u16/gte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/gte.zok", "max_constraint_count": 699, - "tests": [ + "tests": [ { "input": { "values": ["0x0004", "0x0002"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/lshift.json b/zokrates_core_test/tests/tests/uint/u16/lshift.json index cea9c042a..805fb73ad 100644 --- a/zokrates_core_test/tests/tests/uint/u16/lshift.json +++ b/zokrates_core_test/tests/tests/uint/u16/lshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/lshift.zok", "max_constraint_count": 18, - "tests": [ + "tests": [ { "input": { "values": ["0x0002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/lt.json b/zokrates_core_test/tests/tests/uint/u16/lt.json index 785616219..f1a366024 100644 --- a/zokrates_core_test/tests/tests/uint/u16/lt.json +++ b/zokrates_core_test/tests/tests/uint/u16/lt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/lt.zok", "max_constraint_count": 697, - "tests": [ + "tests": [ { "input": { "values": ["0x0002", "0x0004"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/lte.json b/zokrates_core_test/tests/tests/uint/u16/lte.json index a9003332b..49c15abea 100644 --- a/zokrates_core_test/tests/tests/uint/u16/lte.json +++ b/zokrates_core_test/tests/tests/uint/u16/lte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/lte.zok", "max_constraint_count": 699, - "tests": [ + "tests": [ { "input": { "values": ["0x0002", "0x0004"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/mul.json b/zokrates_core_test/tests/tests/uint/u16/mul.json index bc1791fb9..05fc539e6 100644 --- a/zokrates_core_test/tests/tests/uint/u16/mul.json +++ b/zokrates_core_test/tests/tests/uint/u16/mul.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/mul.zok", "max_constraint_count": 69, - "tests": [ + "tests": [ { "input": { "values": ["0x0002", "0x0008"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/neq.json b/zokrates_core_test/tests/tests/uint/u16/neq.json index 72ed60a0b..00a6b1573 100644 --- a/zokrates_core_test/tests/tests/uint/u16/neq.json +++ b/zokrates_core_test/tests/tests/uint/u16/neq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/neq.zok", "max_constraint_count": 37, - "tests": [ + "tests": [ { "input": { "values": ["0x0002", "0x0002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/not.json b/zokrates_core_test/tests/tests/uint/u16/not.json index 497cfb644..dcb554b39 100644 --- a/zokrates_core_test/tests/tests/uint/u16/not.json +++ b/zokrates_core_test/tests/tests/uint/u16/not.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/not.zok", "max_constraint_count": 18, - "tests": [ + "tests": [ { "input": { "values": ["0x0001"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/or.json b/zokrates_core_test/tests/tests/uint/u16/or.json index 5e23592a1..5f92efa66 100644 --- a/zokrates_core_test/tests/tests/uint/u16/or.json +++ b/zokrates_core_test/tests/tests/uint/u16/or.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u16/or.zok", - "max_constraint_count": 51, - "tests": [ - { - "input": { - "values": ["0xffff", "0xffff"] - }, - "output": { - "Ok": { - "value": "0xffff" - } - } - }, - { - "input": { - "values": ["0xffff", "0x0000"] - }, - "output": { - "Ok": { - "value": "0xffff" - } - } - }, - { - "input": { - "values": ["0x1234", "0x5678"] - }, - "output": { - "Ok": { - "value": "0x567c" - } - } + "entry_point": "./tests/tests/uint/u16/or.zok", + "max_constraint_count": 51, + "tests": [ + { + "input": { + "values": ["0xffff", "0xffff"] + }, + "output": { + "Ok": { + "value": "0xffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffff", "0x0000"] + }, + "output": { + "Ok": { + "value": "0xffff" + } + } + }, + { + "input": { + "values": ["0x1234", "0x5678"] + }, + "output": { + "Ok": { + "value": "0x567c" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u16/rem.json b/zokrates_core_test/tests/tests/uint/u16/rem.json index f619c9756..afebdba57 100644 --- a/zokrates_core_test/tests/tests/uint/u16/rem.json +++ b/zokrates_core_test/tests/tests/uint/u16/rem.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u16/rem.zok", - "max_constraint_count": 88, - "tests": [ - { - "input": { - "values": ["0x0002", "0x0004"] - }, - "output": { - "Ok": { - "value": "0x0002" - } - } - }, - { - "input": { - "values": ["0xffff", "0x0001"] - }, - "output": { - "Ok": { - "value": "0x0000" - } - } - }, - { - "input": { - "values": ["0x1001", "0x0002"] - }, - "output": { - "Ok": { - "value": "0x0001" - } - } + "entry_point": "./tests/tests/uint/u16/rem.zok", + "max_constraint_count": 88, + "tests": [ + { + "input": { + "values": ["0x0002", "0x0004"] + }, + "output": { + "Ok": { + "value": "0x0002" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffff", "0x0001"] + }, + "output": { + "Ok": { + "value": "0x0000" + } + } + }, + { + "input": { + "values": ["0x1001", "0x0002"] + }, + "output": { + "Ok": { + "value": "0x0001" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u16/rshift.json b/zokrates_core_test/tests/tests/uint/u16/rshift.json index 293a1ca95..d06e495c0 100644 --- a/zokrates_core_test/tests/tests/uint/u16/rshift.json +++ b/zokrates_core_test/tests/tests/uint/u16/rshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/rshift.zok", "max_constraint_count": 18, - "tests": [ + "tests": [ { "input": { "values": ["0x1000"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/sub.json b/zokrates_core_test/tests/tests/uint/u16/sub.json index 3e83e7058..cae481213 100644 --- a/zokrates_core_test/tests/tests/uint/u16/sub.json +++ b/zokrates_core_test/tests/tests/uint/u16/sub.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u16/sub.zok", "max_constraint_count": 91, - "tests": [ + "tests": [ { "input": { "values": ["0xffff", "0x0001"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u16/xor.json b/zokrates_core_test/tests/tests/uint/u16/xor.json index 0d9a6f54e..e7875f7bb 100644 --- a/zokrates_core_test/tests/tests/uint/u16/xor.json +++ b/zokrates_core_test/tests/tests/uint/u16/xor.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u16/xor.zok", - "max_constraint_count": 51, - "tests": [ - { - "input": { - "values": ["0xffff", "0xffff"] - }, - "output": { - "Ok": { - "value": "0x0000" - } - } - }, - { - "input": { - "values": ["0xffff", "0x0000"] - }, - "output": { - "Ok": { - "value": "0xffff" - } - } - }, - { - "input": { - "values": ["0x1234", "0x5678"] - }, - "output": { - "Ok": { - "value": "0x444c" - } - } + "entry_point": "./tests/tests/uint/u16/xor.zok", + "max_constraint_count": 51, + "tests": [ + { + "input": { + "values": ["0xffff", "0xffff"] + }, + "output": { + "Ok": { + "value": "0x0000" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffff", "0x0000"] + }, + "output": { + "Ok": { + "value": "0xffff" + } + } + }, + { + "input": { + "values": ["0x1234", "0x5678"] + }, + "output": { + "Ok": { + "value": "0x444c" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u32/add.json b/zokrates_core_test/tests/tests/uint/u32/add.json index 3e5a9fb87..d195878e1 100644 --- a/zokrates_core_test/tests/tests/uint/u32/add.json +++ b/zokrates_core_test/tests/tests/uint/u32/add.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/add.zok", "max_constraint_count": 101, - "tests": [ + "tests": [ { "input": { "values": ["0xffffffff", "0x00000001"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/and.json b/zokrates_core_test/tests/tests/uint/u32/and.json index c56fd984e..a3862936a 100644 --- a/zokrates_core_test/tests/tests/uint/u32/and.json +++ b/zokrates_core_test/tests/tests/uint/u32/and.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u32/and.zok", - "max_constraint_count": 99, - "tests": [ - { - "input": { - "values": ["0xffffffff", "0xffffffff"] - }, - "output": { - "Ok": { - "value": "0xffffffff" - } - } - }, - { - "input": { - "values": ["0xffffffff", "0x00000000"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x12345678", "0x87654321"] - }, - "output": { - "Ok": { - "value": "0x02244220" - } - } + "entry_point": "./tests/tests/uint/u32/and.zok", + "max_constraint_count": 99, + "tests": [ + { + "input": { + "values": ["0xffffffff", "0xffffffff"] + }, + "output": { + "Ok": { + "value": "0xffffffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffff", "0x00000000"] + }, + "output": { + "Ok": { + "value": "0x00000000" + } + } + }, + { + "input": { + "values": ["0x12345678", "0x87654321"] + }, + "output": { + "Ok": { + "value": "0x02244220" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u32/div.json b/zokrates_core_test/tests/tests/uint/u32/div.json index 2ea5653bb..d4c0c9a78 100644 --- a/zokrates_core_test/tests/tests/uint/u32/div.json +++ b/zokrates_core_test/tests/tests/uint/u32/div.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u32/div.zok", - "max_constraint_count": 168, - "tests": [ - { - "input": { - "values": ["0x10000000", "0x10000000"] - }, - "output": { - "Ok": { - "value": "0x00000001" - } - } - }, - { - "input": { - "values": ["0x10000000", "0x00000002"] - }, - "output": { - "Ok": { - "value": "0x08000000" - } - } - }, - { - "input": { - "values": ["0x10000001", "0x00000002"] - }, - "output": { - "Ok": { - "value": "0x08000000" - } - } + "entry_point": "./tests/tests/uint/u32/div.zok", + "max_constraint_count": 168, + "tests": [ + { + "input": { + "values": ["0x10000000", "0x10000000"] + }, + "output": { + "Ok": { + "value": "0x00000001" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0x10000000", "0x00000002"] + }, + "output": { + "Ok": { + "value": "0x08000000" + } + } + }, + { + "input": { + "values": ["0x10000001", "0x00000002"] + }, + "output": { + "Ok": { + "value": "0x08000000" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u32/eq.json b/zokrates_core_test/tests/tests/uint/u32/eq.json index d3bd3c9ef..2da47d3d9 100644 --- a/zokrates_core_test/tests/tests/uint/u32/eq.json +++ b/zokrates_core_test/tests/tests/uint/u32/eq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/eq.zok", "max_constraint_count": 69, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002", "0x00000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/gt.json b/zokrates_core_test/tests/tests/uint/u32/gt.json index ff29ce648..9ba9c3c0b 100644 --- a/zokrates_core_test/tests/tests/uint/u32/gt.json +++ b/zokrates_core_test/tests/tests/uint/u32/gt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/gt.zok", "max_constraint_count": 729, - "tests": [ + "tests": [ { "input": { "values": ["0x00000004", "0x00000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/gte.json b/zokrates_core_test/tests/tests/uint/u32/gte.json index acfd1621c..f5cd7383d 100644 --- a/zokrates_core_test/tests/tests/uint/u32/gte.json +++ b/zokrates_core_test/tests/tests/uint/u32/gte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/gte.zok", "max_constraint_count": 731, - "tests": [ + "tests": [ { "input": { "values": ["0x00000004", "0x00000002"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/lshift.json b/zokrates_core_test/tests/tests/uint/u32/lshift.json index cb8b3f287..4ccb2485f 100644 --- a/zokrates_core_test/tests/tests/uint/u32/lshift.json +++ b/zokrates_core_test/tests/tests/uint/u32/lshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/lshift.zok", "max_constraint_count": 34, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/lt.json b/zokrates_core_test/tests/tests/uint/u32/lt.json index acb29d0d9..39555042c 100644 --- a/zokrates_core_test/tests/tests/uint/u32/lt.json +++ b/zokrates_core_test/tests/tests/uint/u32/lt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/lt.zok", "max_constraint_count": 729, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002", "0x00000004"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/lte.json b/zokrates_core_test/tests/tests/uint/u32/lte.json index 35bfad0b0..7decdec05 100644 --- a/zokrates_core_test/tests/tests/uint/u32/lte.json +++ b/zokrates_core_test/tests/tests/uint/u32/lte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/lte.zok", "max_constraint_count": 731, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002", "0x00000004"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/mul.json b/zokrates_core_test/tests/tests/uint/u32/mul.json index 41be3e0e8..cf16b7b35 100644 --- a/zokrates_core_test/tests/tests/uint/u32/mul.json +++ b/zokrates_core_test/tests/tests/uint/u32/mul.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/mul.zok", "max_constraint_count": 133, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002", "0x00000008"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/neq.json b/zokrates_core_test/tests/tests/uint/u32/neq.json index adcc43c40..832ef5862 100644 --- a/zokrates_core_test/tests/tests/uint/u32/neq.json +++ b/zokrates_core_test/tests/tests/uint/u32/neq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/neq.zok", "max_constraint_count": 69, - "tests": [ + "tests": [ { "input": { "values": ["0x00000002", "0x00000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/not.json b/zokrates_core_test/tests/tests/uint/u32/not.json index 59374a7d0..962e57ccb 100644 --- a/zokrates_core_test/tests/tests/uint/u32/not.json +++ b/zokrates_core_test/tests/tests/uint/u32/not.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/not.zok", "max_constraint_count": 34, - "tests": [ + "tests": [ { "input": { "values": ["0x00000001"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/or.json b/zokrates_core_test/tests/tests/uint/u32/or.json index cb13e6ac3..1e5d6787f 100644 --- a/zokrates_core_test/tests/tests/uint/u32/or.json +++ b/zokrates_core_test/tests/tests/uint/u32/or.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u32/or.zok", - "max_constraint_count": 99, - "tests": [ - { - "input": { - "values": ["0xffffffff", "0xffffffff"] - }, - "output": { - "Ok": { - "value": "0xffffffff" - } - } - }, - { - "input": { - "values": ["0xffffffff", "0x00000000"] - }, - "output": { - "Ok": { - "value": "0xffffffff" - } - } - }, - { - "input": { - "values": ["0x12345678", "0x87654321"] - }, - "output": { - "Ok": { - "value": "0x97755779" - } - } + "entry_point": "./tests/tests/uint/u32/or.zok", + "max_constraint_count": 99, + "tests": [ + { + "input": { + "values": ["0xffffffff", "0xffffffff"] + }, + "output": { + "Ok": { + "value": "0xffffffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffff", "0x00000000"] + }, + "output": { + "Ok": { + "value": "0xffffffff" + } + } + }, + { + "input": { + "values": ["0x12345678", "0x87654321"] + }, + "output": { + "Ok": { + "value": "0x97755779" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u32/rem.json b/zokrates_core_test/tests/tests/uint/u32/rem.json index 4936830e8..4b24f228a 100644 --- a/zokrates_core_test/tests/tests/uint/u32/rem.json +++ b/zokrates_core_test/tests/tests/uint/u32/rem.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u32/rem.zok", - "max_constraint_count": 168, - "tests": [ - { - "input": { - "values": ["0x00000002", "0x00000004"] - }, - "output": { - "Ok": { - "value": "0x00000002" - } - } - }, - { - "input": { - "values": ["0xffffffff", "0x00000001"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0x10000001", "0x00000002"] - }, - "output": { - "Ok": { - "value": "0x00000001" - } - } + "entry_point": "./tests/tests/uint/u32/rem.zok", + "max_constraint_count": 168, + "tests": [ + { + "input": { + "values": ["0x00000002", "0x00000004"] + }, + "output": { + "Ok": { + "value": "0x00000002" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffff", "0x00000001"] + }, + "output": { + "Ok": { + "value": "0x00000000" + } + } + }, + { + "input": { + "values": ["0x10000001", "0x00000002"] + }, + "output": { + "Ok": { + "value": "0x00000001" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u32/rshift.json b/zokrates_core_test/tests/tests/uint/u32/rshift.json index c19036257..3b764bd21 100644 --- a/zokrates_core_test/tests/tests/uint/u32/rshift.json +++ b/zokrates_core_test/tests/tests/uint/u32/rshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/rshift.zok", "max_constraint_count": 34, - "tests": [ + "tests": [ { "input": { "values": ["0x10000000"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/sub.json b/zokrates_core_test/tests/tests/uint/u32/sub.json index 07e79a8e1..836abc5f0 100644 --- a/zokrates_core_test/tests/tests/uint/u32/sub.json +++ b/zokrates_core_test/tests/tests/uint/u32/sub.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u32/sub.zok", "max_constraint_count": 171, - "tests": [ + "tests": [ { "input": { "values": ["0xffffffff", "0x00000001"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u32/xor.json b/zokrates_core_test/tests/tests/uint/u32/xor.json index 0c7ae6290..70c0ffb42 100644 --- a/zokrates_core_test/tests/tests/uint/u32/xor.json +++ b/zokrates_core_test/tests/tests/uint/u32/xor.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u32/xor.zok", - "max_constraint_count": 99, - "tests": [ - { - "input": { - "values": ["0xffffffff", "0xffffffff"] - }, - "output": { - "Ok": { - "value": "0x00000000" - } - } - }, - { - "input": { - "values": ["0xffffffff", "0x00000000"] - }, - "output": { - "Ok": { - "value": "0xffffffff" - } - } - }, - { - "input": { - "values": ["0x12345678", "0x87654321"] - }, - "output": { - "Ok": { - "value": "0x95511559" - } - } + "entry_point": "./tests/tests/uint/u32/xor.zok", + "max_constraint_count": 99, + "tests": [ + { + "input": { + "values": ["0xffffffff", "0xffffffff"] + }, + "output": { + "Ok": { + "value": "0x00000000" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffff", "0x00000000"] + }, + "output": { + "Ok": { + "value": "0xffffffff" + } + } + }, + { + "input": { + "values": ["0x12345678", "0x87654321"] + }, + "output": { + "Ok": { + "value": "0x95511559" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u64/add.json b/zokrates_core_test/tests/tests/uint/u64/add.json index 310504ec4..c2d4a15e4 100644 --- a/zokrates_core_test/tests/tests/uint/u64/add.json +++ b/zokrates_core_test/tests/tests/uint/u64/add.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/add.zok", "max_constraint_count": 197, - "tests": [ + "tests": [ { "input": { "values": ["0xffffffffffffffff", "0x0000000000000001"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/and.json b/zokrates_core_test/tests/tests/uint/u64/and.json index 95e0ce673..9c181c344 100644 --- a/zokrates_core_test/tests/tests/uint/u64/and.json +++ b/zokrates_core_test/tests/tests/uint/u64/and.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u64/and.zok", - "max_constraint_count": 195, - "tests": [ - { - "input": { - "values": ["0xffffffffffffffff", "0xffffffffffffffff"] - }, - "output": { - "Ok": { - "value": "0xffffffffffffffff" - } - } - }, - { - "input": { - "values": ["0xffffffffffffffff", "0x0000000000000000"] - }, - "output": { - "Ok": { - "value": "0x0000000000000000" - } - } - }, - { - "input": { - "values": ["0x1234567812345678", "0x8765432187654321"] - }, - "output": { - "Ok": { - "value": "0x0224422002244220" - } - } + "entry_point": "./tests/tests/uint/u64/and.zok", + "max_constraint_count": 195, + "tests": [ + { + "input": { + "values": ["0xffffffffffffffff", "0xffffffffffffffff"] + }, + "output": { + "Ok": { + "value": "0xffffffffffffffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffffffffffff", "0x0000000000000000"] + }, + "output": { + "Ok": { + "value": "0x0000000000000000" + } + } + }, + { + "input": { + "values": ["0x1234567812345678", "0x8765432187654321"] + }, + "output": { + "Ok": { + "value": "0x0224422002244220" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u64/div.json b/zokrates_core_test/tests/tests/uint/u64/div.json index 3f5533aff..98a66c336 100644 --- a/zokrates_core_test/tests/tests/uint/u64/div.json +++ b/zokrates_core_test/tests/tests/uint/u64/div.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u64/div.zok", - "max_constraint_count": 328, - "tests": [ - { - "input": { - "values": ["0x1000000000000000", "0x1000000000000000"] - }, - "output": { - "Ok": { - "value": "0x0000000000000001" - } - } - }, - { - "input": { - "values": ["0x1000000000000000", "0x0000000000000002"] - }, - "output": { - "Ok": { - "value": "0x0800000000000000" - } - } - }, - { - "input": { - "values": ["0x1000000000000001", "0x0000000000000002"] - }, - "output": { - "Ok": { - "value": "0x0800000000000000" - } - } + "entry_point": "./tests/tests/uint/u64/div.zok", + "max_constraint_count": 328, + "tests": [ + { + "input": { + "values": ["0x1000000000000000", "0x1000000000000000"] + }, + "output": { + "Ok": { + "value": "0x0000000000000001" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0x1000000000000000", "0x0000000000000002"] + }, + "output": { + "Ok": { + "value": "0x0800000000000000" + } + } + }, + { + "input": { + "values": ["0x1000000000000001", "0x0000000000000002"] + }, + "output": { + "Ok": { + "value": "0x0800000000000000" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u64/eq.json b/zokrates_core_test/tests/tests/uint/u64/eq.json index 25c87248a..0c4cbdfae 100644 --- a/zokrates_core_test/tests/tests/uint/u64/eq.json +++ b/zokrates_core_test/tests/tests/uint/u64/eq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/eq.zok", "max_constraint_count": 133, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002", "0x0000000000000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/gt.json b/zokrates_core_test/tests/tests/uint/u64/gt.json index 77fbd3c45..6be1f5df7 100644 --- a/zokrates_core_test/tests/tests/uint/u64/gt.json +++ b/zokrates_core_test/tests/tests/uint/u64/gt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/gt.zok", "max_constraint_count": 793, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000004", "0x0000000000000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/gte.json b/zokrates_core_test/tests/tests/uint/u64/gte.json index 566bb6974..ca26a0db5 100644 --- a/zokrates_core_test/tests/tests/uint/u64/gte.json +++ b/zokrates_core_test/tests/tests/uint/u64/gte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/gte.zok", "max_constraint_count": 795, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000004", "0x0000000000000002"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/lshift.json b/zokrates_core_test/tests/tests/uint/u64/lshift.json index ff271b6dd..77195f3af 100644 --- a/zokrates_core_test/tests/tests/uint/u64/lshift.json +++ b/zokrates_core_test/tests/tests/uint/u64/lshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/lshift.zok", "max_constraint_count": 66, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/lt.json b/zokrates_core_test/tests/tests/uint/u64/lt.json index cb4db05ff..7711a135c 100644 --- a/zokrates_core_test/tests/tests/uint/u64/lt.json +++ b/zokrates_core_test/tests/tests/uint/u64/lt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/lt.zok", "max_constraint_count": 793, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002", "0x0000000000000004"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/lte.json b/zokrates_core_test/tests/tests/uint/u64/lte.json index 47fea3c9e..42b9b26f7 100644 --- a/zokrates_core_test/tests/tests/uint/u64/lte.json +++ b/zokrates_core_test/tests/tests/uint/u64/lte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/lte.zok", "max_constraint_count": 795, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002", "0x0000000000000004"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/mul.json b/zokrates_core_test/tests/tests/uint/u64/mul.json index 5e4cd4002..dec7d788d 100644 --- a/zokrates_core_test/tests/tests/uint/u64/mul.json +++ b/zokrates_core_test/tests/tests/uint/u64/mul.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/mul.zok", "max_constraint_count": 261, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002", "0x0000000000000008"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/neq.json b/zokrates_core_test/tests/tests/uint/u64/neq.json index 87bb9b59d..0709908af 100644 --- a/zokrates_core_test/tests/tests/uint/u64/neq.json +++ b/zokrates_core_test/tests/tests/uint/u64/neq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/neq.zok", "max_constraint_count": 133, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000002", "0x0000000000000002"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/not.json b/zokrates_core_test/tests/tests/uint/u64/not.json index 0da11cc26..12d2a4157 100644 --- a/zokrates_core_test/tests/tests/uint/u64/not.json +++ b/zokrates_core_test/tests/tests/uint/u64/not.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/not.zok", "max_constraint_count": 66, - "tests": [ + "tests": [ { "input": { "values": ["0x0000000000000001"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/or.json b/zokrates_core_test/tests/tests/uint/u64/or.json index a78e32504..8dc4b3c78 100644 --- a/zokrates_core_test/tests/tests/uint/u64/or.json +++ b/zokrates_core_test/tests/tests/uint/u64/or.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u64/or.zok", - "max_constraint_count": 195, - "tests": [ - { - "input": { - "values": ["0xffffffffffffffff", "0xffffffffffffffff"] - }, - "output": { - "Ok": { - "value": "0xffffffffffffffff" - } - } - }, - { - "input": { - "values": ["0xffffffffffffffff", "0x0000000000000000"] - }, - "output": { - "Ok": { - "value": "0xffffffffffffffff" - } - } - }, - { - "input": { - "values": ["0x1234567812345678", "0x8765432187654321"] - }, - "output": { - "Ok": { - "value": "0x9775577997755779" - } - } + "entry_point": "./tests/tests/uint/u64/or.zok", + "max_constraint_count": 195, + "tests": [ + { + "input": { + "values": ["0xffffffffffffffff", "0xffffffffffffffff"] + }, + "output": { + "Ok": { + "value": "0xffffffffffffffff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffffffffffff", "0x0000000000000000"] + }, + "output": { + "Ok": { + "value": "0xffffffffffffffff" + } + } + }, + { + "input": { + "values": ["0x1234567812345678", "0x8765432187654321"] + }, + "output": { + "Ok": { + "value": "0x9775577997755779" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u64/rem.json b/zokrates_core_test/tests/tests/uint/u64/rem.json index e38fc891f..c10e559b6 100644 --- a/zokrates_core_test/tests/tests/uint/u64/rem.json +++ b/zokrates_core_test/tests/tests/uint/u64/rem.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u64/rem.zok", - "max_constraint_count": 328, - "tests": [ - { - "input": { - "values": ["0x0000000000000002", "0x0000000000000004"] - }, - "output": { - "Ok": { - "value": "0x0000000000000002" - } - } - }, - { - "input": { - "values": ["0xffffffffffffffff", "0x0000000000000001"] - }, - "output": { - "Ok": { - "value": "0x0000000000000000" - } - } - }, - { - "input": { - "values": ["0x1000000000000001", "0x0000000000000002"] - }, - "output": { - "Ok": { - "value": "0x0000000000000001" - } - } + "entry_point": "./tests/tests/uint/u64/rem.zok", + "max_constraint_count": 328, + "tests": [ + { + "input": { + "values": ["0x0000000000000002", "0x0000000000000004"] + }, + "output": { + "Ok": { + "value": "0x0000000000000002" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffffffffffff", "0x0000000000000001"] + }, + "output": { + "Ok": { + "value": "0x0000000000000000" + } + } + }, + { + "input": { + "values": ["0x1000000000000001", "0x0000000000000002"] + }, + "output": { + "Ok": { + "value": "0x0000000000000001" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u64/rshift.json b/zokrates_core_test/tests/tests/uint/u64/rshift.json index f8d64f905..6886bec87 100644 --- a/zokrates_core_test/tests/tests/uint/u64/rshift.json +++ b/zokrates_core_test/tests/tests/uint/u64/rshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u64/rshift.zok", "max_constraint_count": 66, - "tests": [ + "tests": [ { "input": { "values": ["0x1000000000000000"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/sub.json b/zokrates_core_test/tests/tests/uint/u64/sub.json index af3d4972a..252075ca9 100644 --- a/zokrates_core_test/tests/tests/uint/u64/sub.json +++ b/zokrates_core_test/tests/tests/uint/u64/sub.json @@ -1,14 +1,18 @@ { "entry_point": "./tests/tests/uint/u64/sub.zok", "max_constraint_count": 331, - "tests": [ + "tests": [ { "input": { "values": ["0xffffffffffffffff", "0x0000000000000001"] }, "output": { "Ok": { - "value": ["0xfffffffffffffffe", "0xfffffffffffffffe", "0x0000000000000002"] + "value": [ + "0xfffffffffffffffe", + "0xfffffffffffffffe", + "0x0000000000000002" + ] } } }, @@ -18,9 +22,13 @@ }, "output": { "Ok": { - "value": ["0xffffffffffffffff", "0xffffffffffffffff", "0x0000000000000001"] + "value": [ + "0xffffffffffffffff", + "0xffffffffffffffff", + "0x0000000000000001" + ] } } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u64/xor.json b/zokrates_core_test/tests/tests/uint/u64/xor.json index 2ee39f00a..5c6ea5b06 100644 --- a/zokrates_core_test/tests/tests/uint/u64/xor.json +++ b/zokrates_core_test/tests/tests/uint/u64/xor.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u64/xor.zok", - "max_constraint_count": 195, - "tests": [ - { - "input": { - "values": ["0xffffffffffffffff", "0xffffffffffffffff"] - }, - "output": { - "Ok": { - "value": "0x0000000000000000" - } - } - }, - { - "input": { - "values": ["0xffffffffffffffff", "0x0000000000000000"] - }, - "output": { - "Ok": { - "value": "0xffffffffffffffff" - } - } - }, - { - "input": { - "values": ["0x1234567812345678", "0x8765432187654321"] - }, - "output": { - "Ok": { - "value": "0x9551155995511559" - } - } + "entry_point": "./tests/tests/uint/u64/xor.zok", + "max_constraint_count": 195, + "tests": [ + { + "input": { + "values": ["0xffffffffffffffff", "0xffffffffffffffff"] + }, + "output": { + "Ok": { + "value": "0x0000000000000000" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xffffffffffffffff", "0x0000000000000000"] + }, + "output": { + "Ok": { + "value": "0xffffffffffffffff" + } + } + }, + { + "input": { + "values": ["0x1234567812345678", "0x8765432187654321"] + }, + "output": { + "Ok": { + "value": "0x9551155995511559" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u8/add.json b/zokrates_core_test/tests/tests/uint/u8/add.json index eb00a398a..b73aaa3b2 100644 --- a/zokrates_core_test/tests/tests/uint/u8/add.json +++ b/zokrates_core_test/tests/tests/uint/u8/add.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/add.zok", "max_constraint_count": 29, - "tests": [ + "tests": [ { "input": { "values": ["0xff", "0x01"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/and.json b/zokrates_core_test/tests/tests/uint/u8/and.json index 47694a03d..aa56c7785 100644 --- a/zokrates_core_test/tests/tests/uint/u8/and.json +++ b/zokrates_core_test/tests/tests/uint/u8/and.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u8/and.zok", - "max_constraint_count": 27, - "tests": [ - { - "input": { - "values": ["0xff", "0xff"] - }, - "output": { - "Ok": { - "value": "0xff" - } - } - }, - { - "input": { - "values": ["0xff", "0x00"] - }, - "output": { - "Ok": { - "value": "0x00" - } - } - }, - { - "input": { - "values": ["0x23", "0x34"] - }, - "output": { - "Ok": { - "value": "0x20" - } - } + "entry_point": "./tests/tests/uint/u8/and.zok", + "max_constraint_count": 27, + "tests": [ + { + "input": { + "values": ["0xff", "0xff"] + }, + "output": { + "Ok": { + "value": "0xff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xff", "0x00"] + }, + "output": { + "Ok": { + "value": "0x00" + } + } + }, + { + "input": { + "values": ["0x23", "0x34"] + }, + "output": { + "Ok": { + "value": "0x20" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u8/div.json b/zokrates_core_test/tests/tests/uint/u8/div.json index 0a017ece8..3f2ec3e46 100644 --- a/zokrates_core_test/tests/tests/uint/u8/div.json +++ b/zokrates_core_test/tests/tests/uint/u8/div.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u8/div.zok", - "max_constraint_count": 48, - "tests": [ - { - "input": { - "values": ["0x02", "0x02"] - }, - "output": { - "Ok": { - "value": "0x01" - } - } - }, - { - "input": { - "values": ["0x04", "0x02"] - }, - "output": { - "Ok": { - "value": "0x02" - } - } - }, - { - "input": { - "values": ["0x2a", "0x0a"] - }, - "output": { - "Ok": { - "value": "0x04" - } - } + "entry_point": "./tests/tests/uint/u8/div.zok", + "max_constraint_count": 48, + "tests": [ + { + "input": { + "values": ["0x02", "0x02"] + }, + "output": { + "Ok": { + "value": "0x01" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0x04", "0x02"] + }, + "output": { + "Ok": { + "value": "0x02" + } + } + }, + { + "input": { + "values": ["0x2a", "0x0a"] + }, + "output": { + "Ok": { + "value": "0x04" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u8/eq.json b/zokrates_core_test/tests/tests/uint/u8/eq.json index 5362c0e8d..9e660b748 100644 --- a/zokrates_core_test/tests/tests/uint/u8/eq.json +++ b/zokrates_core_test/tests/tests/uint/u8/eq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/eq.zok", "max_constraint_count": 21, - "tests": [ + "tests": [ { "input": { "values": ["0x02", "0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/gt.json b/zokrates_core_test/tests/tests/uint/u8/gt.json index 6703f2fba..5f08fa9d8 100644 --- a/zokrates_core_test/tests/tests/uint/u8/gt.json +++ b/zokrates_core_test/tests/tests/uint/u8/gt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/gt.zok", "max_constraint_count": 681, - "tests": [ + "tests": [ { "input": { "values": ["0x04", "0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/gte.json b/zokrates_core_test/tests/tests/uint/u8/gte.json index b67cd5007..4592ee5ec 100644 --- a/zokrates_core_test/tests/tests/uint/u8/gte.json +++ b/zokrates_core_test/tests/tests/uint/u8/gte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/gte.zok", "max_constraint_count": 683, - "tests": [ + "tests": [ { "input": { "values": ["0x04", "0x02"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/lshift.json b/zokrates_core_test/tests/tests/uint/u8/lshift.json index d457a0459..dc9eb6ec6 100644 --- a/zokrates_core_test/tests/tests/uint/u8/lshift.json +++ b/zokrates_core_test/tests/tests/uint/u8/lshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/lshift.zok", "max_constraint_count": 10, - "tests": [ + "tests": [ { "input": { "values": ["0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/lt.json b/zokrates_core_test/tests/tests/uint/u8/lt.json index cb489e202..cbb9baa2e 100644 --- a/zokrates_core_test/tests/tests/uint/u8/lt.json +++ b/zokrates_core_test/tests/tests/uint/u8/lt.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/lt.zok", "max_constraint_count": 681, - "tests": [ + "tests": [ { "input": { "values": ["0x02", "0x04"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/lte.json b/zokrates_core_test/tests/tests/uint/u8/lte.json index 3e7af976c..412a41f0e 100644 --- a/zokrates_core_test/tests/tests/uint/u8/lte.json +++ b/zokrates_core_test/tests/tests/uint/u8/lte.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/lte.zok", "max_constraint_count": 683, - "tests": [ + "tests": [ { "input": { "values": ["0x02", "0x04"] @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/mul.json b/zokrates_core_test/tests/tests/uint/u8/mul.json index 4ee7da4b0..43239f0e7 100644 --- a/zokrates_core_test/tests/tests/uint/u8/mul.json +++ b/zokrates_core_test/tests/tests/uint/u8/mul.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/mul.zok", "max_constraint_count": 37, - "tests": [ + "tests": [ { "input": { "values": ["0x02", "0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/neq.json b/zokrates_core_test/tests/tests/uint/u8/neq.json index 352bdbd2a..61b7388f6 100644 --- a/zokrates_core_test/tests/tests/uint/u8/neq.json +++ b/zokrates_core_test/tests/tests/uint/u8/neq.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/neq.zok", "max_constraint_count": 21, - "tests": [ + "tests": [ { "input": { "values": ["0x02", "0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/not.json b/zokrates_core_test/tests/tests/uint/u8/not.json index 8028e53d4..9f2044cc2 100644 --- a/zokrates_core_test/tests/tests/uint/u8/not.json +++ b/zokrates_core_test/tests/tests/uint/u8/not.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/not.zok", "max_constraint_count": 10, - "tests": [ + "tests": [ { "input": { "values": ["0x01"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/or.json b/zokrates_core_test/tests/tests/uint/u8/or.json index d59d013cd..b6237cbd3 100644 --- a/zokrates_core_test/tests/tests/uint/u8/or.json +++ b/zokrates_core_test/tests/tests/uint/u8/or.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u8/or.zok", - "max_constraint_count": 27, - "tests": [ - { - "input": { - "values": ["0xff", "0xff"] - }, - "output": { - "Ok": { - "value": "0xff" - } - } - }, - { - "input": { - "values": ["0xff", "0x00"] - }, - "output": { - "Ok": { - "value": "0xff" - } - } - }, - { - "input": { - "values": ["0x23", "0x34"] - }, - "output": { - "Ok": { - "value": "0x37" - } - } + "entry_point": "./tests/tests/uint/u8/or.zok", + "max_constraint_count": 27, + "tests": [ + { + "input": { + "values": ["0xff", "0xff"] + }, + "output": { + "Ok": { + "value": "0xff" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xff", "0x00"] + }, + "output": { + "Ok": { + "value": "0xff" + } + } + }, + { + "input": { + "values": ["0x23", "0x34"] + }, + "output": { + "Ok": { + "value": "0x37" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u8/rem.json b/zokrates_core_test/tests/tests/uint/u8/rem.json index e70b1c011..587194ab6 100644 --- a/zokrates_core_test/tests/tests/uint/u8/rem.json +++ b/zokrates_core_test/tests/tests/uint/u8/rem.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u8/rem.zok", - "max_constraint_count": 48, - "tests": [ - { - "input": { - "values": ["0x02", "0x04"] - }, - "output": { - "Ok": { - "value": "0x02" - } - } - }, - { - "input": { - "values": ["0xff", "0x01"] - }, - "output": { - "Ok": { - "value": "0x00" - } - } - }, - { - "input": { - "values": ["0x2a", "0x0a"] - }, - "output": { - "Ok": { - "value": "0x02" - } - } + "entry_point": "./tests/tests/uint/u8/rem.zok", + "max_constraint_count": 48, + "tests": [ + { + "input": { + "values": ["0x02", "0x04"] + }, + "output": { + "Ok": { + "value": "0x02" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xff", "0x01"] + }, + "output": { + "Ok": { + "value": "0x00" + } + } + }, + { + "input": { + "values": ["0x2a", "0x0a"] + }, + "output": { + "Ok": { + "value": "0x02" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/uint/u8/rshift.json b/zokrates_core_test/tests/tests/uint/u8/rshift.json index d2fa9f8ad..183fdae93 100644 --- a/zokrates_core_test/tests/tests/uint/u8/rshift.json +++ b/zokrates_core_test/tests/tests/uint/u8/rshift.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/rshift.zok", "max_constraint_count": 10, - "tests": [ + "tests": [ { "input": { "values": ["0x02"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/sub.json b/zokrates_core_test/tests/tests/uint/u8/sub.json index e45cffebd..f8e73b8a3 100644 --- a/zokrates_core_test/tests/tests/uint/u8/sub.json +++ b/zokrates_core_test/tests/tests/uint/u8/sub.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/uint/u8/sub.zok", "max_constraint_count": 51, - "tests": [ + "tests": [ { "input": { "values": ["0xff", "0x01"] @@ -23,4 +23,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_core_test/tests/tests/uint/u8/xor.json b/zokrates_core_test/tests/tests/uint/u8/xor.json index 7d9db904b..36fd2493b 100644 --- a/zokrates_core_test/tests/tests/uint/u8/xor.json +++ b/zokrates_core_test/tests/tests/uint/u8/xor.json @@ -1,36 +1,36 @@ { - "entry_point": "./tests/tests/uint/u8/xor.zok", - "max_constraint_count": 27, - "tests": [ - { - "input": { - "values": ["0xff", "0xff"] - }, - "output": { - "Ok": { - "value": "0x00" - } - } - }, - { - "input": { - "values": ["0xff", "0x00"] - }, - "output": { - "Ok": { - "value": "0xff" - } - } - }, - { - "input": { - "values": ["0x23", "0x34"] - }, - "output": { - "Ok": { - "value": "0x17" - } - } + "entry_point": "./tests/tests/uint/u8/xor.zok", + "max_constraint_count": 27, + "tests": [ + { + "input": { + "values": ["0xff", "0xff"] + }, + "output": { + "Ok": { + "value": "0x00" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["0xff", "0x00"] + }, + "output": { + "Ok": { + "value": "0xff" + } + } + }, + { + "input": { + "values": ["0x23", "0x34"] + }, + "output": { + "Ok": { + "value": "0x17" + } + } + } + ] +} diff --git a/zokrates_js/Cargo.toml b/zokrates_js/Cargo.toml index 4c946aef4..59b20e610 100644 --- a/zokrates_js/Cargo.toml +++ b/zokrates_js/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_js" -version = "1.1.2" +version = "1.1.3" authors = ["Darko Macesic"] edition = "2018" diff --git a/zokrates_js/build.rs b/zokrates_js/build.rs index be5616b90..5eea2bc9d 100644 --- a/zokrates_js/build.rs +++ b/zokrates_js/build.rs @@ -14,7 +14,9 @@ fn export_stdlib() { for entry in WalkDir::new(root) .into_iter() .map(Result::unwrap) - .filter(|e| !e.file_type().is_dir()) + .filter(|e| { + !e.file_type().is_dir() && e.path().extension().map(|e| e == "zok").unwrap_or(false) + }) { let path: &Path = entry.path(); let source = fs::read_to_string(path).unwrap(); diff --git a/zokrates_js/index.d.ts b/zokrates_js/index.d.ts index e300941f6..979603e86 100644 --- a/zokrates_js/index.d.ts +++ b/zokrates_js/index.d.ts @@ -35,7 +35,7 @@ declare module "zokrates-js" { } export type LogCallback = (log: string) => void; - + export interface ComputeOptions { snarkjs?: boolean; logCallback?: LogCallback; diff --git a/zokrates_js/package-lock.json b/zokrates_js/package-lock.json index 77f2adb01..74772fd07 100644 --- a/zokrates_js/package-lock.json +++ b/zokrates_js/package-lock.json @@ -12,21 +12,23 @@ "dree": "^2.6.1", "mocha": "^9.2.0", "rimraf": "^3.0.2", - "snarkjs": "^0.4.19", + "snarkjs": "^0.4.24", "wasm-pack": "^0.10.2" } }, "node_modules/@iden3/bigarray": { "version": "0.0.2", - "dev": true, - "license": "GPL-3.0" + "resolved": "https://registry.npmjs.org/@iden3/bigarray/-/bigarray-0.0.2.tgz", + "integrity": "sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g==", + "dev": true }, "node_modules/@iden3/binfileutils": { - "version": "0.0.10", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/@iden3/binfileutils/-/binfileutils-0.0.11.tgz", + "integrity": "sha512-LylnJoZ0CTdgErnKY8OxohvW4K+p6UHD3sxt+3P9AmMyBQjYR4IpoqoYZZ+9aMj89cmCQ21UvdhndAx04er3NA==", "dev": true, - "license": "GPL-3.0", "dependencies": { - "fastfile": "0.0.19", + "fastfile": "0.0.20", "ffjavascript": "^0.2.48" } }, @@ -86,10 +88,26 @@ "dev": true, "license": "MIT" }, + "node_modules/bfj": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", + "integrity": "sha512-+e/UqUzwmzJamNF50tBV6tZPTORow7gQ96iFow+8b562OdMpEK0BcJEq2OSPEDmAbSMBQ7PKZ87ubFkgxpYWgw==", + "dev": true, + "dependencies": { + "bluebird": "^3.5.5", + "check-types": "^11.1.1", + "hoopy": "^0.1.4", + "tryer": "^1.0.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/big-integer": { "version": "1.6.51", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", + "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", "dev": true, - "license": "Unlicense", "engines": { "node": ">=0.6" } @@ -118,8 +136,15 @@ }, "node_modules/blakejs": { "version": "1.2.1", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", + "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", + "dev": true + }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", + "dev": true }, "node_modules/brace-expansion": { "version": "1.1.11", @@ -135,6 +160,12 @@ "dev": true, "license": "ISC" }, + "node_modules/check-types": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.1.2.tgz", + "integrity": "sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ==", + "dev": true + }, "node_modules/chownr": { "version": "2.0.0", "dev": true, @@ -144,27 +175,17 @@ } }, "node_modules/circom_runtime": { - "version": "0.1.17", + "version": "0.1.18", + "resolved": "https://registry.npmjs.org/circom_runtime/-/circom_runtime-0.1.18.tgz", + "integrity": "sha512-j6k+Jg1DXCYFVgjDRbJDmkAJ9E17js8h1iR7F1UX0IUr5v8NXeOXkfRh9+/73JqSgXb3Eo166a4JHdA/CeoEeA==", "dev": true, - "license": "Apache-2.0", "dependencies": { - "ffjavascript": "0.2.48" + "ffjavascript": "0.2.55" }, "bin": { "calcwit": "calcwit.js" } }, - "node_modules/circom_runtime/node_modules/ffjavascript": { - "version": "0.2.48", - "dev": true, - "license": "GPL-3.0", - "dependencies": { - "big-integer": "^1.6.48", - "wasmbuilder": "^0.0.12", - "wasmcurves": "0.1.0", - "web-worker": "^1.2.0" - } - }, "node_modules/cliui": { "version": "7.0.4", "dev": true, @@ -271,14 +292,16 @@ } }, "node_modules/fastfile": { - "version": "0.0.19", - "dev": true, - "license": "GPL-3.0" + "version": "0.0.20", + "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.20.tgz", + "integrity": "sha512-r5ZDbgImvVWCP0lA/cGNgQcZqR+aYdFx3u+CtJqUE510pBUVGMn4ulL/iRTI4tACTYsNJ736uzFxEBXesPAktA==", + "dev": true }, "node_modules/ffjavascript": { - "version": "0.2.54", + "version": "0.2.55", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.55.tgz", + "integrity": "sha512-8X0FCIPOWiK6DTWh3pnE3O6D6nIQsirStAXpWMzRDnoDX7SEnDX4I28aVhwjL7L35XS1vy2AU7zc0UCGYxdLjw==", "dev": true, - "license": "GPL-3.0", "dependencies": { "big-integer": "^1.6.48", "wasmbuilder": "^0.0.12", @@ -399,6 +422,15 @@ "he": "bin/he" } }, + "node_modules/hoopy": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", + "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", + "dev": true, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/inflight": { "version": "1.0.6", "dev": true, @@ -1017,25 +1049,15 @@ } }, "node_modules/r1csfile": { - "version": "0.0.35", + "version": "0.0.40", + "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.40.tgz", + "integrity": "sha512-3tKaFLncf42ZTRpPMlgyiFBdk6kir4S4O3X+u4UQjgLYoDPHfizazNbK0Jzj++PVIXVUFAqugSbIo4W3UDuHcQ==", "dev": true, - "license": "GPL-3.0", "dependencies": { "@iden3/bigarray": "0.0.2", - "@iden3/binfileutils": "0.0.10", - "fastfile": "0.0.19", - "ffjavascript": "0.2.48" - } - }, - "node_modules/r1csfile/node_modules/ffjavascript": { - "version": "0.2.48", - "dev": true, - "license": "GPL-3.0", - "dependencies": { - "big-integer": "^1.6.48", - "wasmbuilder": "^0.0.12", - "wasmcurves": "0.1.0", - "web-worker": "^1.2.0" + "@iden3/binfileutils": "0.0.11", + "fastfile": "0.0.20", + "ffjavascript": "0.2.55" } }, "node_modules/randombytes": { @@ -1046,11 +1068,6 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/readline": { - "version": "1.3.0", - "dev": true, - "license": "BSD" - }, "node_modules/require-directory": { "version": "2.1.1", "dev": true, @@ -1087,20 +1104,21 @@ } }, "node_modules/snarkjs": { - "version": "0.4.19", + "version": "0.4.25", + "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.4.25.tgz", + "integrity": "sha512-20manpB7xCd5gkfkioD6GaAR7tgJmN7xQQislJcPV3Xs2Vkf+1Dz6V+LKRwlc/rU/vT/EopUBm5apqvTOKidbQ==", "dev": true, - "license": "GPL-3.0", "dependencies": { - "@iden3/binfileutils": "0.0.10", + "@iden3/binfileutils": "0.0.11", + "bfj": "^7.0.2", "blake2b-wasm": "^2.4.0", - "circom_runtime": "0.1.17", + "circom_runtime": "0.1.18", "ejs": "^3.1.6", - "fastfile": "0.0.19", - "ffjavascript": "0.2.54", + "fastfile": "0.0.20", + "ffjavascript": "0.2.55", "js-sha3": "^0.8.0", "logplease": "^1.2.15", - "r1csfile": "0.0.35", - "readline": "^1.3.0" + "r1csfile": "0.0.40" }, "bin": { "snarkjs": "build/cli.cjs" @@ -1186,6 +1204,12 @@ "dev": true, "license": "ISC" }, + "node_modules/tryer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", + "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", + "dev": true + }, "node_modules/wasm-pack": { "version": "0.10.2", "dev": true, @@ -1200,16 +1224,18 @@ }, "node_modules/wasmbuilder": { "version": "0.0.12", + "resolved": "https://registry.npmjs.org/wasmbuilder/-/wasmbuilder-0.0.12.tgz", + "integrity": "sha512-dTMpBgrnLOXrN58i2zakn2ScynsBhq9LfyQIsPz4CyxRF9k1GAORniuqn3xmE9NnI1l7g3iiVCkoB2Cl0/oG8w==", "dev": true, - "license": "GPL-3.0", "dependencies": { "big-integer": "^1.6.48" } }, "node_modules/wasmcurves": { "version": "0.1.0", + "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.1.0.tgz", + "integrity": "sha512-kIlcgbVUAv2uQ6lGsepGz/m5V40+Z6rvTBkqCYn3Y2+OcXst+UaP4filJYLh/xDxjJl62FFjZZeAnpeli1Y5/Q==", "dev": true, - "license": "GPL-3.0", "dependencies": { "big-integer": "^1.6.42", "blakejs": "^1.1.0" @@ -1217,8 +1243,9 @@ }, "node_modules/web-worker": { "version": "1.2.0", - "dev": true, - "license": "Apache-2.0" + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", + "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==", + "dev": true }, "node_modules/workerpool": { "version": "6.2.0", @@ -1330,13 +1357,17 @@ "dependencies": { "@iden3/bigarray": { "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@iden3/bigarray/-/bigarray-0.0.2.tgz", + "integrity": "sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g==", "dev": true }, "@iden3/binfileutils": { - "version": "0.0.10", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/@iden3/binfileutils/-/binfileutils-0.0.11.tgz", + "integrity": "sha512-LylnJoZ0CTdgErnKY8OxohvW4K+p6UHD3sxt+3P9AmMyBQjYR4IpoqoYZZ+9aMj89cmCQ21UvdhndAx04er3NA==", "dev": true, "requires": { - "fastfile": "0.0.19", + "fastfile": "0.0.20", "ffjavascript": "^0.2.48" } }, @@ -1380,8 +1411,22 @@ "version": "1.0.0", "dev": true }, + "bfj": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", + "integrity": "sha512-+e/UqUzwmzJamNF50tBV6tZPTORow7gQ96iFow+8b562OdMpEK0BcJEq2OSPEDmAbSMBQ7PKZ87ubFkgxpYWgw==", + "dev": true, + "requires": { + "bluebird": "^3.5.5", + "check-types": "^11.1.1", + "hoopy": "^0.1.4", + "tryer": "^1.0.1" + } + }, "big-integer": { "version": "1.6.51", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", + "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", "dev": true }, "binary-install": { @@ -1403,6 +1448,14 @@ }, "blakejs": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", + "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", + "dev": true + }, + "bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, "brace-expansion": { @@ -1417,27 +1470,23 @@ "version": "1.3.1", "dev": true }, + "check-types": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.1.2.tgz", + "integrity": "sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ==", + "dev": true + }, "chownr": { "version": "2.0.0", "dev": true }, "circom_runtime": { - "version": "0.1.17", + "version": "0.1.18", + "resolved": "https://registry.npmjs.org/circom_runtime/-/circom_runtime-0.1.18.tgz", + "integrity": "sha512-j6k+Jg1DXCYFVgjDRbJDmkAJ9E17js8h1iR7F1UX0IUr5v8NXeOXkfRh9+/73JqSgXb3Eo166a4JHdA/CeoEeA==", "dev": true, "requires": { - "ffjavascript": "0.2.48" - }, - "dependencies": { - "ffjavascript": { - "version": "0.2.48", - "dev": true, - "requires": { - "big-integer": "^1.6.48", - "wasmbuilder": "^0.0.12", - "wasmcurves": "0.1.0", - "web-worker": "^1.2.0" - } - } + "ffjavascript": "0.2.55" } }, "cliui": { @@ -1516,11 +1565,15 @@ "dev": true }, "fastfile": { - "version": "0.0.19", + "version": "0.0.20", + "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.20.tgz", + "integrity": "sha512-r5ZDbgImvVWCP0lA/cGNgQcZqR+aYdFx3u+CtJqUE510pBUVGMn4ulL/iRTI4tACTYsNJ736uzFxEBXesPAktA==", "dev": true }, "ffjavascript": { - "version": "0.2.54", + "version": "0.2.55", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.55.tgz", + "integrity": "sha512-8X0FCIPOWiK6DTWh3pnE3O6D6nIQsirStAXpWMzRDnoDX7SEnDX4I28aVhwjL7L35XS1vy2AU7zc0UCGYxdLjw==", "dev": true, "requires": { "big-integer": "^1.6.48", @@ -1595,6 +1648,12 @@ "version": "1.2.0", "dev": true }, + "hoopy": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", + "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", + "dev": true + }, "inflight": { "version": "1.0.6", "dev": true, @@ -1965,25 +2024,15 @@ "dev": true }, "r1csfile": { - "version": "0.0.35", + "version": "0.0.40", + "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.40.tgz", + "integrity": "sha512-3tKaFLncf42ZTRpPMlgyiFBdk6kir4S4O3X+u4UQjgLYoDPHfizazNbK0Jzj++PVIXVUFAqugSbIo4W3UDuHcQ==", "dev": true, "requires": { "@iden3/bigarray": "0.0.2", - "@iden3/binfileutils": "0.0.10", - "fastfile": "0.0.19", - "ffjavascript": "0.2.48" - }, - "dependencies": { - "ffjavascript": { - "version": "0.2.48", - "dev": true, - "requires": { - "big-integer": "^1.6.48", - "wasmbuilder": "^0.0.12", - "wasmcurves": "0.1.0", - "web-worker": "^1.2.0" - } - } + "@iden3/binfileutils": "0.0.11", + "fastfile": "0.0.20", + "ffjavascript": "0.2.55" } }, "randombytes": { @@ -1993,10 +2042,6 @@ "safe-buffer": "^5.1.0" } }, - "readline": { - "version": "1.3.0", - "dev": true - }, "require-directory": { "version": "2.1.1", "dev": true @@ -2020,19 +2065,21 @@ } }, "snarkjs": { - "version": "0.4.19", + "version": "0.4.25", + "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.4.25.tgz", + "integrity": "sha512-20manpB7xCd5gkfkioD6GaAR7tgJmN7xQQislJcPV3Xs2Vkf+1Dz6V+LKRwlc/rU/vT/EopUBm5apqvTOKidbQ==", "dev": true, "requires": { - "@iden3/binfileutils": "0.0.10", + "@iden3/binfileutils": "0.0.11", + "bfj": "^7.0.2", "blake2b-wasm": "^2.4.0", - "circom_runtime": "0.1.17", + "circom_runtime": "0.1.18", "ejs": "^3.1.6", - "fastfile": "0.0.19", - "ffjavascript": "0.2.54", + "fastfile": "0.0.20", + "ffjavascript": "0.2.55", "js-sha3": "^0.8.0", "logplease": "^1.2.15", - "r1csfile": "0.0.35", - "readline": "^1.3.0" + "r1csfile": "0.0.40" } }, "string-width": { @@ -2090,6 +2137,12 @@ } } }, + "tryer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", + "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", + "dev": true + }, "wasm-pack": { "version": "0.10.2", "dev": true, @@ -2099,6 +2152,8 @@ }, "wasmbuilder": { "version": "0.0.12", + "resolved": "https://registry.npmjs.org/wasmbuilder/-/wasmbuilder-0.0.12.tgz", + "integrity": "sha512-dTMpBgrnLOXrN58i2zakn2ScynsBhq9LfyQIsPz4CyxRF9k1GAORniuqn3xmE9NnI1l7g3iiVCkoB2Cl0/oG8w==", "dev": true, "requires": { "big-integer": "^1.6.48" @@ -2106,6 +2161,8 @@ }, "wasmcurves": { "version": "0.1.0", + "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.1.0.tgz", + "integrity": "sha512-kIlcgbVUAv2uQ6lGsepGz/m5V40+Z6rvTBkqCYn3Y2+OcXst+UaP4filJYLh/xDxjJl62FFjZZeAnpeli1Y5/Q==", "dev": true, "requires": { "big-integer": "^1.6.42", @@ -2114,6 +2171,8 @@ }, "web-worker": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", + "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==", "dev": true }, "workerpool": { diff --git a/zokrates_js/package.json b/zokrates_js/package.json index c5f4bada4..6ddcb0c84 100644 --- a/zokrates_js/package.json +++ b/zokrates_js/package.json @@ -1,6 +1,6 @@ { "name": "zokrates-js", - "version": "1.1.2", + "version": "1.1.3", "module": "index.js", "main": "node/index.js", "description": "JavaScript bindings for ZoKrates", @@ -46,7 +46,7 @@ "dree": "^2.6.1", "mocha": "^9.2.0", "rimraf": "^3.0.2", - "snarkjs": "^0.4.19", + "snarkjs": "^0.4.25", "wasm-pack": "^0.10.2" } -} \ No newline at end of file +} diff --git a/zokrates_js/tests/tests.js b/zokrates_js/tests/tests.js index 38ae18b8e..86ed3bcd0 100644 --- a/zokrates_js/tests/tests.js +++ b/zokrates_js/tests/tests.js @@ -18,12 +18,15 @@ describe("tests", () => { .mkdtemp(path.join(os.tmpdir(), path.sep)) .then((folder) => { tmpFolder = folder; + return; }); }); }); after(() => { - if (globalThis.curve_bn128) globalThis.curve_bn128.terminate(); + if (globalThis.curve_bn128) { + return globalThis.curve_bn128.terminate(); + } }); describe("metadata", () => { @@ -164,17 +167,24 @@ describe("tests", () => { it("compile", () => { assert.doesNotThrow(() => { - const code = - "def main(private field a, field b) -> bool { return a * a == b; }"; + const code = `def main(private field a, field b) -> bool { + bool check = if (a == 0){ true} else {a * a == b}; + assert(check); + return true; + }`; artifacts = provider.compile(code, { snarkjs: true }); }); }); it("compute witness", () => { assert.doesNotThrow(() => { - computationResult = provider.computeWitness(artifacts, ["2", "4"], { - snarkjs: true, - }); + computationResult = provider.computeWitness( + artifacts, + ["337", "113569"], + { + snarkjs: true, + } + ); }); }); @@ -194,12 +204,15 @@ describe("tests", () => { // write program to fs let r1csPath = tmpFolder + "/prog.r1cs"; let zkeyPath = tmpFolder + "/key.zkey"; + return fs.promises .writeFile(r1csPath, artifacts.snarkjs.program) .then(() => { - return snarkjs.zKey - .newZKey(r1csPath, "./tests/powersOfTau5_0000.ptau", zkeyPath) - .then(() => {}); + return snarkjs.zKey.newZKey( + r1csPath, + "./tests/powersOfTau5_0000.ptau", + zkeyPath + ); }); }); } @@ -230,10 +243,21 @@ describe("tests", () => { // write witness to fs let witnessPath = tmpFolder + "/witness.wtns"; let zkeyPath = tmpFolder + "/key.zkey"; + return fs.promises .writeFile(witnessPath, computationResult.snarkjs.witness) .then(() => { return snarkjs.groth16.prove(zkeyPath, witnessPath); + }) + .then((r) => { + return snarkjs.zKey.exportVerificationKey(zkeyPath).then((vk) => { + return snarkjs.groth16 + .verify(vk, r.publicSignals, r.proof) + .then((res) => { + assert.deepEqual(res, true); + return; + }); + }); }); }); } diff --git a/zokrates_parser/Cargo.toml b/zokrates_parser/Cargo.toml index d968e8223..d5b222ddc 100644 --- a/zokrates_parser/Cargo.toml +++ b/zokrates_parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_parser" -version = "0.3.1" +version = "0.3.2" authors = ["JacobEberhardt "] edition = "2018" diff --git a/zokrates_parser/src/textmate/language-configuration.json b/zokrates_parser/src/textmate/language-configuration.json index bdf838281..158e13c35 100644 --- a/zokrates_parser/src/textmate/language-configuration.json +++ b/zokrates_parser/src/textmate/language-configuration.json @@ -1,28 +1,28 @@ { - "comments": { - // symbol used for single line comment. Remove this entry if your language does not support line comments - "lineComment": "//", - // symbols used for start and end a block comment. Remove this entry if your language does not support block comments - "blockComment": [ "/*", "*/" ] - }, - // symbols used as brackets - "brackets": [ - ["{", "}"], - ["[", "]"], - ["(", ")"] - ], - // symbols that are auto closed when typing - "autoClosingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""], - ], - // symbols that can be used to surround a selection - "surroundingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""], - ] -} \ No newline at end of file + "comments": { + // symbol used for single line comment. Remove this entry if your language does not support line comments + "lineComment": "//", + // symbols used for start and end a block comment. Remove this entry if your language does not support block comments + "blockComment": ["/*", "*/"] + }, + // symbols used as brackets + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + // symbols that are auto closed when typing + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""] + ], + // symbols that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""] + ] +} diff --git a/zokrates_parser/src/textmate/package.json b/zokrates_parser/src/textmate/package.json index 2b2806288..3693426e7 100644 --- a/zokrates_parser/src/textmate/package.json +++ b/zokrates_parser/src/textmate/package.json @@ -1,36 +1,36 @@ { - "name": "zokrates", - "displayName": "zokrates", - "description": "Syntax highlighting for the ZoKrates language", - "publisher": "zokrates", - "repository": "https://github.com/ZoKrates/ZoKrates", - "version": "0.1.0", - "engines": { - "vscode": "^1.53.0" - }, - "categories": [ - "Programming Languages" - ], - "contributes": { - "languages": [ - { - "id": "zokrates", - "aliases": [ - "ZoKrates", - "zokrates" - ], - "extensions": [ - ".zok" - ], - "configuration": "./language-configuration.json" - } - ], - "grammars": [ - { - "language": "zokrates", - "scopeName": "source.zok", - "path": "./syntaxes/zokrates.tmLanguage.json" - } - ] - } -} \ No newline at end of file + "name": "zokrates", + "displayName": "zokrates", + "description": "Syntax highlighting for the ZoKrates language", + "publisher": "zokrates", + "repository": "https://github.com/ZoKrates/ZoKrates", + "version": "0.1.0", + "engines": { + "vscode": "^1.53.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "zokrates", + "aliases": [ + "ZoKrates", + "zokrates" + ], + "extensions": [ + ".zok" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "zokrates", + "scopeName": "source.zok", + "path": "./syntaxes/zokrates.tmLanguage.json" + } + ] + } +} diff --git a/zokrates_stdlib/Cargo.toml b/zokrates_stdlib/Cargo.toml index 5ce77db8d..d70995209 100644 --- a/zokrates_stdlib/Cargo.toml +++ b/zokrates_stdlib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_stdlib" -version = "0.3.1" +version = "0.3.2" authors = ["Stefan Deml ", "schaeff "] edition = "2018" diff --git a/zokrates_stdlib/stdlib/utils/casts.zok b/zokrates_stdlib/stdlib/utils/casts.zok new file mode 100644 index 000000000..6cfe6aee6 --- /dev/null +++ b/zokrates_stdlib/stdlib/utils/casts.zok @@ -0,0 +1,532 @@ +from "EMBED" import u64_to_bits, u32_to_bits, u16_to_bits, u8_to_bits, u8_from_bits, u16_from_bits, u32_from_bits, u64_from_bits; + +// Cast a boolean array of size 8 to an 8-bit unsigned integer (u8) +def cast(bool[8] input) -> u8 { + return u8_from_bits(input); +} + +// Cast a boolean array of size N to an array of 8-bit unsigned integers (u8) of size P +// The following condition must be true `N == 8 * P`, otherwise the cast will fail +def cast(bool[N] input) -> u8[P] { + assert(N == 8 * P); + u8[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = u8_from_bits(input[i * 8..(i + 1) * 8]); + } + return r; +} + +// Cast a boolean array of size 16 to a 16-bit unsigned integer (u16) +def cast(bool[16] input) -> u16 { + return u16_from_bits(input); +} + +// Cast a boolean array of size N to an array of 16-bit unsigned integers (u16) of size P +// The following condition must be true `N == 16 * P`, otherwise the cast will fail +def cast(bool[N] input) -> u16[P] { + assert(N == 16 * P); + u16[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = u16_from_bits(input[i * 16..(i + 1) * 16]); + } + return r; +} + +// Cast a boolean array of size 32 to a 32-bit unsigned integer (u32) +def cast(bool[32] input) -> u32 { + return u32_from_bits(input); +} + +// Cast a boolean array of size N to an array of 32-bit unsigned integers (u32) of size P +// The following condition must be true `N == 32 * P`, otherwise the cast will fail +def cast(bool[N] input) -> u32[P] { + assert(N == 32 * P); + u32[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = u32_from_bits(input[i * 32..(i + 1) * 32]); + } + return r; +} + +// Cast a boolean array of size 64 to a 64-bit unsigned integer (u64) +def cast(bool[64] input) -> u64 { + return u64_from_bits(input); +} + +// Cast a boolean array of size N to an array of 64-bit unsigned integers (u64) of size P +// The following condition must be true `N == 64 * P`, otherwise the cast will fail +def cast(bool[N] input) -> u64[P] { + assert(N == 64 * P); + u64[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = u64_from_bits(input[i * 64..(i + 1) * 64]); + } + return r; +} + +// Cast an 8-bit unsigned integer (u8) to a boolean array of size 8 (bool[8]) +def cast(u8 input) -> bool[8] { + return u8_to_bits(input); +} + +// Cast an array of 8-bit unsigned integers (u8) of size N to a boolean array of size P +// The following condition must be true `P == 8 * N`, otherwise the cast will fail +def cast(u8[N] input) -> bool[P] { + assert(P == 8 * N); + bool[P] mut r = [false; P]; + for u32 i in 0..N { + bool[8] bits = u8_to_bits(input[i]); + for u32 j in 0..8 { + r[i * 8 + j] = bits[j]; + } + } + return r; +} + +// Cast an 8-bit unsigned integer (u8) to a field element +def cast(u8 input) -> field { + bool[8] bits = u8_to_bits(input); + field mut r = 0; + for u32 i in 0..8 { + u32 exponent = 8 - i - 1; + r = r + (bits[i] ? 2 ** exponent : 0); + } + return r; +} + +// Cast an array of 8-bit unsigned integers (u8) to an array of field elements +def cast(u8[N] input) -> field[N] { + field[N] mut r = [0; N]; + for u32 i in 0..N { + r[i] = cast(input[i]); + } + return r; +} + +// Upcast an 8-bit unsigned integer (u8) to a 16-bit unsigned integer (u16) +def cast(u8 input) -> u16 { + bool[8] bits = u8_to_bits(input); + return u16_from_bits([...[false; 8], ...bits]); +} + +// Cast an array of two 8-bit unsigned integers (u8[2]) to a 16-bit unsigned integer (u16) +def cast(u8[2] input) -> u16 { + bool[16] bits = [ + ...u8_to_bits(input[0]), + ...u8_to_bits(input[1]) + ]; + return u16_from_bits(bits); +} + +// Cast an array of 8-bit unsigned integers (u8) of size N to an array of 16-bit unsigned integers (u16) of size P +// The following condition must be true `N == 2 * P`, otherwise the cast will fail +def cast(u8[N] input) -> u16[P] { + assert(N == 2 * P); + u16[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 2..(i + 1) * 2]); + } + return r; +} + +// Upcast an 8-bit unsigned integer (u8) to a 32-bit unsigned integer (u32) +def cast(u8 input) -> u32 { + bool[8] bits = u8_to_bits(input); + return u32_from_bits([...[false; 24], ...bits]); +} + +// Cast an array of four 8-bit unsigned integers (u8[4]) to a 32-bit unsigned integer (u32) +def cast(u8[4] input) -> u32 { + bool[32] bits = [ + ...u8_to_bits(input[0]), + ...u8_to_bits(input[1]), + ...u8_to_bits(input[2]), + ...u8_to_bits(input[3]) + ]; + return u32_from_bits(bits); +} + +// Cast an array of 8-bit unsigned integers (u8) of size N to an array of 32-bit unsigned integers (u32) of size P +// The following condition must be true `N == 4 * P`, otherwise the cast will fail +def cast(u8[N] input) -> u32[P] { + assert(N == 4 * P); + u32[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 4..(i + 1) * 4]); + } + return r; +} + +// Upcast an 8-bit unsigned integer (u8) to a 64-bit unsigned integer (u64) +def cast(u8 input) -> u64 { + bool[8] bits = u8_to_bits(input); + return u64_from_bits([...[false; 56], ...bits]); +} + +// Cast an array of eight 8-bit unsigned integers (u8[8]) to a 64-bit unsigned integer (u64) +def cast(u8[8] input) -> u64 { + bool[64] bits = [ + ...u8_to_bits(input[0]), + ...u8_to_bits(input[1]), + ...u8_to_bits(input[2]), + ...u8_to_bits(input[3]), + ...u8_to_bits(input[4]), + ...u8_to_bits(input[5]), + ...u8_to_bits(input[6]), + ...u8_to_bits(input[7]) + ]; + return u64_from_bits(bits); +} + +// Cast an array of 8-bit unsigned integers (u8) of size N to an array of 64-bit unsigned integers (u64) of size P +// The following condition must be true `N == 8 * P`, otherwise the cast will fail +def cast(u8[N] input) -> u64[P] { + assert(N == 8 * P); + u64[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 8..(i + 1) * 8]); + } + return r; +} + +// Cast a 16-bit unsigned integer (u16) to a boolean array of size 16 (bool[16]) +def cast(u16 input) -> bool[16] { + return u16_to_bits(input); +} + +// Cast an array of 16-bit unsigned integers (u16) of size N to a boolean array of size P +// The following condition must be true `P == 16 * N`, otherwise the cast will fail +def cast(u16[N] input) -> bool[P] { + assert(P == 16 * N); + bool[P] mut r = [false; P]; + for u32 i in 0..N { + bool[16] bits = u16_to_bits(input[i]); + for u32 j in 0..16 { + r[i * 16 + j] = bits[j]; + } + } + return r; +} + +// Cast a 16-bit unsigned integer (u16) to a field element +def cast(u16 input) -> field { + bool[16] bits = u16_to_bits(input); + field mut r = 0; + for u32 i in 0..16 { + u32 exponent = 16 - i - 1; + r = r + (bits[i] ? 2 ** exponent : 0); + } + return r; +} + +// Cast an array of 16-bit unsigned integers (u16) to an array of field elements +def cast(u16[N] input) -> field[N] { + field[N] mut r = [0; N]; + for u32 i in 0..N { + r[i] = cast(input[i]); + } + return r; +} + +// Cast a 16-bit unsigned integer (u16) to an array of two 8-bit unsigned integers (u8[2]) +def cast(u16 input) -> u8[2] { + bool[16] bits = u16_to_bits(input); + return [ + u8_from_bits(bits[0..8]), + u8_from_bits(bits[8..16]) + ]; +} + +// Cast an array of 16-bit unsigned integers (u16) of size N to an array of 8-bit unsigned integers of size P +// The following condition must be true `P == 2 * N`, otherwise the cast will fail +def cast(u16[N] input) -> u8[P] { + assert(P == 2 * N); + u8[P] mut r = [0; P]; + for u32 i in 0..N { + u8[2] t = cast(input[i]); + r[i * 2] = t[0]; + r[i * 2 + 1] = t[1]; + } + return r; +} + +// Upcast a 16-bit unsigned integer (u16) to a 32-bit unsigned integer (u32) +def cast(u16 input) -> u32 { + bool[16] bits = u16_to_bits(input); + return u32_from_bits([...[false; 16], ...bits]); +} + +// Cast an array of two 16-bit unsigned integers (u16[2]) to a 32-bit unsigned integer (u32) +def cast(u16[2] input) -> u32 { + bool[32] bits = [ + ...u16_to_bits(input[0]), + ...u16_to_bits(input[1]) + ]; + return u32_from_bits(bits); +} + +// Cast an array of 16-bit unsigned integers (u16) of size N to an array of 32-bit unsigned integers (u32) of size P +// The following condition must be true `N == 2 * P`, otherwise the cast will fail +def cast(u16[N] input) -> u32[P] { + assert(N == 2 * P); + u32[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 2..(i + 1) * 2]); + } + return r; +} + +// Upcast a 16-bit unsigned integer (u16) to a 64-bit unsigned integer (u64) +def cast(u16 input) -> u64 { + bool[16] bits = u16_to_bits(input); + return u64_from_bits([...[false; 48], ...bits]); +} + +// Cast an array of four 16-bit unsigned integers (u16[4]) to a 64-bit unsigned integer (u64) +def cast(u16[4] input) -> u64 { + bool[64] bits = [ + ...u16_to_bits(input[0]), + ...u16_to_bits(input[1]), + ...u16_to_bits(input[2]), + ...u16_to_bits(input[3]) + ]; + return u64_from_bits(bits); +} + +// Cast an array of 16-bit unsigned integers (u16) of size N to an array of 64-bit unsigned integers (u64) of size P +// The following condition must be true `N == 4 * P`, otherwise the cast will fail +def cast(u16[N] input) -> u64[P] { + assert(N == 4 * P); + u64[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 4..(i + 1) * 4]); + } + return r; +} + +// Cast a 32-bit unsigned integer (u32) to a boolean array of size 32 (bool[32]) +def cast(u32 input) -> bool[32] { + return u32_to_bits(input); +} + +// Cast an array of 32-bit unsigned integers (u32) of size N to a boolean array of size P +// The following condition must be true `P == 32 * N`, otherwise the cast will fail +def cast(u32[N] input) -> bool[P] { + assert(P == 32 * N); + bool[P] mut r = [false; P]; + for u32 i in 0..N { + bool[32] bits = u32_to_bits(input[i]); + for u32 j in 0..32 { + r[i * 32 + j] = bits[j]; + } + } + return r; +} + +// Cast a 32-bit unsigned integer (u32) to a field element +def cast(u32 input) -> field { + bool[32] bits = u32_to_bits(input); + field mut r = 0; + for u32 i in 0..32 { + u32 exponent = 32 - i - 1; + r = r + (bits[i] ? 2 ** exponent : 0); + } + return r; +} + +// Cast an array of 32-bit unsigned integers (u32) to an array of field elements +def cast(u32[N] input) -> field[N] { + field[N] mut r = [0; N]; + for u32 i in 0..N { + r[i] = cast(input[i]); + } + return r; +} + +// Cast a 32-bit unsigned integer (u32) to an array of four 8-bit unsigned integers (u8[4]) +def cast(u32 input) -> u8[4] { + bool[32] bits = u32_to_bits(input); + return [ + u8_from_bits(bits[0..8]), + u8_from_bits(bits[8..16]), + u8_from_bits(bits[16..24]), + u8_from_bits(bits[24..32]) + ]; +} + +// Cast an array of 32-bit unsigned integers (u32) of size N to an array of 8-bit unsigned integers of size P +// The following condition must be true `P == 4 * N`, otherwise the cast will fail +def cast(u32[N] input) -> u8[P] { + assert(P == 4 * N); + u8[P] mut r = [0; P]; + for u32 i in 0..N { + u8[4] t = cast(input[i]); + for u32 j in 0..4 { + r[i * 4 + j] = t[j]; + } + } + return r; +} + +// Cast a 32-bit unsigned integer (u32) to an array of two 16-bit unsigned integers (u16[2]) +def cast(u32 input) -> u16[2] { + bool[32] bits = u32_to_bits(input); + return [ + u16_from_bits(bits[0..16]), + u16_from_bits(bits[16..32]) + ]; +} + +// Cast an array of 32-bit unsigned integers (u32) of size N to an array of 16-bit unsigned integers of size P +// The following condition must be true `P == 2 * N`, otherwise the cast will fail +def cast(u32[N] input) -> u16[P] { + assert(P == 2 * N); + u16[P] mut r = [0; P]; + for u32 i in 0..N { + u16[2] t = cast(input[i]); + r[i * 2] = t[0]; + r[i * 2 + 1] = t[1]; + } + return r; +} + +// Upcast a 32-bit unsigned integer (u32) to a 64-bit unsigned integer (u64) +def cast(u32 input) -> u64 { + bool[32] bits = u32_to_bits(input); + return u64_from_bits([...[false; 32], ...bits]); +} + +// Cast an array of two 32-bit unsigned integers (u32[2]) to a 64-bit unsigned integer (u64) +def cast(u32[2] input) -> u64 { + bool[64] bits = [ + ...u32_to_bits(input[0]), + ...u32_to_bits(input[1]) + ]; + return u64_from_bits(bits); +} + +// Cast an array of 32-bit unsigned integers (u32) of size N to an array of 64-bit unsigned integers (u64) of size P +// The following condition must be true `N == 2 * P`, otherwise the cast will fail +def cast(u32[N] input) -> u64[P] { + assert(N == 2 * P); + u64[P] mut r = [0; P]; + for u32 i in 0..P { + r[i] = cast(input[i * 2..(i + 1) * 2]); + } + return r; +} + +// Cast a 64-bit unsigned integer (u64) to a boolean array of size 64 (bool[64]) +def cast(u64 input) -> bool[64] { + return u64_to_bits(input); +} + +// Cast an array of 64-bit unsigned integers (u64) of size N to a boolean array of size P +// The following condition must be true `P == 64 * N`, otherwise the cast will fail +def cast(u64[N] input) -> bool[P] { + assert(P == 64 * N); + bool[P] mut r = [false; P]; + for u32 i in 0..N { + bool[64] bits = u64_to_bits(input[i]); + for u32 j in 0..64 { + r[i * 64 + j] = bits[j]; + } + } + return r; +} + +// Cast 64-bit unsigned integer (u64) to a field element +def cast(u64 input) -> field { + bool[64] bits = u64_to_bits(input); + field mut r = 0; + for u32 i in 0..64 { + u32 exponent = 64 - i - 1; + r = r + (bits[i] ? 2 ** exponent : 0); + } + return r; +} + +// Cast an array of 64-bit unsigned integers (u64) to an array of field elements +def cast(u64[N] input) -> field[N] { + field[N] mut r = [0; N]; + for u32 i in 0..N { + r[i] = cast(input[i]); + } + return r; +} + +// Cast a 64-bit unsigned integer (u64) to an array of 8 8-bit unsigned integers (u8[8]) +def cast(u64 input) -> u8[8] { + bool[64] bits = u64_to_bits(input); + return [ + u8_from_bits(bits[0..8]), + u8_from_bits(bits[8..16]), + u8_from_bits(bits[16..24]), + u8_from_bits(bits[24..32]), + u8_from_bits(bits[32..40]), + u8_from_bits(bits[40..48]), + u8_from_bits(bits[48..56]), + u8_from_bits(bits[56..64]) + ]; +} + +// Cast an array of 64-bit unsigned integers (u64) of size N to an array of 8-bit unsigned integers of size P +// The following condition must be true `P == 8 * N`, otherwise the cast will fail +def cast(u64[N] input) -> u8[P] { + assert(P == 8 * N); + u8[P] mut r = [0; P]; + for u32 i in 0..N { + u8[8] t = cast(input[i]); + for u32 j in 0..8 { + r[i * 8 + j] = t[j]; + } + } + return r; +} + +// Cast a 64-bit unsigned integer (u64) to an array of 4 16-bit unsigned integers (u16[4]) +def cast(u64 input) -> u16[4] { + bool[64] bits = u64_to_bits(input); + return [ + u16_from_bits(bits[0..16]), + u16_from_bits(bits[16..32]), + u16_from_bits(bits[32..48]), + u16_from_bits(bits[48..64]) + ]; +} + +// Cast an array of 64-bit unsigned integers (u64) of size N to an array of 16-bit unsigned integers of size P +// The following condition must be true `P == 4 * N`, otherwise the cast will fail +def cast(u64[N] input) -> u16[P] { + assert(P == 4 * N); + u16[P] mut r = [0; P]; + for u32 i in 0..N { + u16[4] t = cast(input[i]); + for u32 j in 0..4 { + r[i * 4 + j] = t[j]; + } + } + return r; +} + +// Cast a 64-bit unsigned integer (u64) to an array of 2 32-bit unsigned integers (u32[2]) +def cast(u64 input) -> u32[2] { + bool[64] bits = u64_to_bits(input); + return [ + u32_from_bits(bits[0..32]), + u32_from_bits(bits[32..64]) + ]; +} + +// Cast an array of 64-bit unsigned integers (u64) of size N to an array of 32-bit unsigned integers of size P +// The following condition must be true `P == 2 * N`, otherwise the cast will fail +def cast(u64[N] input) -> u32[P] { + assert(P == 2 * N); + u32[P] mut r = [0; P]; + for u32 i in 0..N { + u32[2] t = cast(input[i]); + r[i * 2] = t[0]; + r[i * 2 + 1] = t[1]; + } + return r; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/ecc/edwardsAdd.json b/zokrates_stdlib/tests/tests/ecc/edwardsAdd.json index 9cafcf182..606cf381c 100644 --- a/zokrates_stdlib/tests/tests/ecc/edwardsAdd.json +++ b/zokrates_stdlib/tests/tests/ecc/edwardsAdd.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/edwardsAdd.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/edwardsAdd.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/ecc/edwardsCompress.json b/zokrates_stdlib/tests/tests/ecc/edwardsCompress.json index 3e61fbc4d..a6d986972 100644 --- a/zokrates_stdlib/tests/tests/ecc/edwardsCompress.json +++ b/zokrates_stdlib/tests/tests/ecc/edwardsCompress.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/edwardsCompress.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/edwardsCompress.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/ecc/edwardsOnCurve.json b/zokrates_stdlib/tests/tests/ecc/edwardsOnCurve.json index 5b64f1417..936ae4431 100644 --- a/zokrates_stdlib/tests/tests/ecc/edwardsOnCurve.json +++ b/zokrates_stdlib/tests/tests/ecc/edwardsOnCurve.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/edwardsOnCurve.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/edwardsOnCurve.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/ecc/edwardsOrderCheck.json b/zokrates_stdlib/tests/tests/ecc/edwardsOrderCheck.json index 9a15568a5..a22c24724 100644 --- a/zokrates_stdlib/tests/tests/ecc/edwardsOrderCheck.json +++ b/zokrates_stdlib/tests/tests/ecc/edwardsOrderCheck.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/edwardsOrderCheck.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/edwardsOrderCheck.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/ecc/edwardsScalarMult.json b/zokrates_stdlib/tests/tests/ecc/edwardsScalarMult.json index 224716408..55857dde5 100644 --- a/zokrates_stdlib/tests/tests/ecc/edwardsScalarMult.json +++ b/zokrates_stdlib/tests/tests/ecc/edwardsScalarMult.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/edwardsScalarMult.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/edwardsScalarMult.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/ecc/proofOfOwnership.json b/zokrates_stdlib/tests/tests/ecc/proofOfOwnership.json index 23206d96a..d08778bfd 100644 --- a/zokrates_stdlib/tests/tests/ecc/proofOfOwnership.json +++ b/zokrates_stdlib/tests/tests/ecc/proofOfOwnership.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/ecc/proofOfOwnership.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/ecc/proofOfOwnership.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/field.json b/zokrates_stdlib/tests/tests/field.json index cfd464948..a84eafe29 100644 --- a/zokrates_stdlib/tests/tests/field.json +++ b/zokrates_stdlib/tests/tests/field.json @@ -1,18 +1,22 @@ { - "entry_point": "./tests/tests/field.zok", - "max_constraint_count": 3, - "curves": ["Bn128"], - "abi": false, - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": ["0", "21888242871839275222246405745257275088548364400416034343698204186575808495616", "254"] - } - } + "entry_point": "./tests/tests/field.zok", + "max_constraint_count": 3, + "curves": ["Bn128"], + "abi": false, + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [ + "0", + "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "254" + ] } - ] + } + } + ] } diff --git a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1024bit.json b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1024bit.json index 2a204d09b..d31aff4da 100644 --- a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1024bit.json +++ b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1024bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1536bit.json b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1536bit.json index d072b2cc6..068ae94fb 100644 --- a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1536bit.json +++ b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1536bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_512bit.json b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_512bit.json index 2956ff2d7..1a1a46f35 100644 --- a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_512bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_8192bit.json b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_8192bit.json index 1b9d2413a..d4317e598 100644 --- a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_8192bit.json +++ b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_8192bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_p.json b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_p.json index db942173b..6f595f878 100644 --- a/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_p.json +++ b/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_p.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/keccak/224bit.json b/zokrates_stdlib/tests/tests/hashes/keccak/224bit.json index 10b3c78a4..ff4d0881c 100644 --- a/zokrates_stdlib/tests/tests/hashes/keccak/224bit.json +++ b/zokrates_stdlib/tests/tests/hashes/keccak/224bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/keccak/256bit.json b/zokrates_stdlib/tests/tests/hashes/keccak/256bit.json index 53984f59f..1011d369c 100644 --- a/zokrates_stdlib/tests/tests/hashes/keccak/256bit.json +++ b/zokrates_stdlib/tests/tests/hashes/keccak/256bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/keccak/384bit.json b/zokrates_stdlib/tests/tests/hashes/keccak/384bit.json index c28a774c3..69a760b04 100644 --- a/zokrates_stdlib/tests/tests/hashes/keccak/384bit.json +++ b/zokrates_stdlib/tests/tests/hashes/keccak/384bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/keccak/512bit.json b/zokrates_stdlib/tests/tests/hashes/keccak/512bit.json index b340ee1d4..580febef0 100644 --- a/zokrates_stdlib/tests/tests/hashes/keccak/512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/keccak/512bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/keccak/keccak.json b/zokrates_stdlib/tests/tests/hashes/keccak/keccak.json index bee7ccda3..1b6ebc0f3 100644 --- a/zokrates_stdlib/tests/tests/hashes/keccak/keccak.json +++ b/zokrates_stdlib/tests/tests/hashes/keccak/keccak.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/mimc7/mimc7.json b/zokrates_stdlib/tests/tests/hashes/mimc7/mimc7.json index c58e8147f..36dab4ca5 100644 --- a/zokrates_stdlib/tests/tests/hashes/mimc7/mimc7.json +++ b/zokrates_stdlib/tests/tests/hashes/mimc7/mimc7.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/mimc7/mimc7.zok", - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/hashes/mimc7/mimc7.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcFeistel.json b/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcFeistel.json index b15cf975d..4bd338f48 100644 --- a/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcFeistel.json +++ b/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcFeistel.json @@ -1,29 +1,31 @@ { - "entry_point": "./tests/tests/hashes/mimcSponge/mimcFeistel.zok", - "tests": [ - { - "input": { - "values": ["1", "2", "3"] - }, - "output": { - "Ok": { - "value": [ - "18444058245820418255538785847032978363886102372504864086197416499869253008979", "2646733164649743153031645792459389637917704265581895142760676293265176296759" - ] - } - } - }, - { - "input": { - "values": ["0", "0", "0"] - }, - "output": { - "Ok": { - "value": [ - "14543742788565021628577424853847564376151732847602780516906950225481254681152", "21165881269406212375659499083070944693027168220143204011932538650149052385959" - ] - } - } + "entry_point": "./tests/tests/hashes/mimcSponge/mimcFeistel.zok", + "tests": [ + { + "input": { + "values": ["1", "2", "3"] + }, + "output": { + "Ok": { + "value": [ + "18444058245820418255538785847032978363886102372504864086197416499869253008979", + "2646733164649743153031645792459389637917704265581895142760676293265176296759" + ] } - ] + } + }, + { + "input": { + "values": ["0", "0", "0"] + }, + "output": { + "Ok": { + "value": [ + "14543742788565021628577424853847564376151732847602780516906950225481254681152", + "21165881269406212375659499083070944693027168220143204011932538650149052385959" + ] + } + } + } + ] } diff --git a/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcSponge.json b/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcSponge.json index 9b5fc5e07..714f712c5 100644 --- a/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcSponge.json +++ b/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcSponge.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/mimcSponge/mimcSponge.zok", - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } + "entry_point": "./tests/tests/hashes/mimcSponge/mimcSponge.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/pedersen/512bit.json b/zokrates_stdlib/tests/tests/hashes/pedersen/512bit.json index 744dcc734..953c7dba1 100644 --- a/zokrates_stdlib/tests/tests/hashes/pedersen/512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/pedersen/512bit.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/hashes/pedersen/512bit.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/pedersen/512bit.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/pedersen/512bitBool.json b/zokrates_stdlib/tests/tests/hashes/pedersen/512bitBool.json index 9236510fe..7229d9aa0 100644 --- a/zokrates_stdlib/tests/tests/hashes/pedersen/512bitBool.json +++ b/zokrates_stdlib/tests/tests/hashes/pedersen/512bitBool.json @@ -1,14 +1,16 @@ { - "entry_point": "./tests/tests/hashes/pedersen/512bitBool.zok", - "curves": ["Bn128"], - "tests": [{ - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } + "entry_point": "./tests/tests/hashes/pedersen/512bitBool.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - }] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_1.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_1.json index 03f4fb2fa..d199fc4e0 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_1.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_1.json @@ -1,25 +1,25 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_1.zok", - "tests": [ - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": "18586133768512220936620570745912940619677854269274689475585506675881198879027" - } - } - }, - { - "input": { - "values": ["42"] - }, - "output": { - "Ok": { - "value": "12326503012965816391338144612242952408728683609716147019497703475006801258307" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_1.zok", + "tests": [ + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": "18586133768512220936620570745912940619677854269274689475585506675881198879027" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": ["42"] + }, + "output": { + "Ok": { + "value": "12326503012965816391338144612242952408728683609716147019497703475006801258307" + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.json index 2f3c59355..1b9e3ee6e 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_2.zok", - "tests": [ - { - "input": { - "values": [["1", "2"]] - }, - "output": { - "Ok": { - "value": "7853200120776062878684798364095072458815029376092732009249414926327459813530" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_2.zok", + "tests": [ + { + "input": { + "values": [["1", "2"]] + }, + "output": { + "Ok": { + "value": "7853200120776062878684798364095072458815029376092732009249414926327459813530" } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.json index 98f61d532..7edbd6166 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_3.zok", - "tests": [ - { - "input": { - "values": [["1", "2", "3"]] - }, - "output": { - "Ok": { - "value": "6542985608222806190361240322586112750744169038454362455181422643027100751666" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_3.zok", + "tests": [ + { + "input": { + "values": [["1", "2", "3"]] + }, + "output": { + "Ok": { + "value": "6542985608222806190361240322586112750744169038454362455181422643027100751666" } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.json index 84a38c333..c83d20366 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_4.zok", - "tests": [ - { - "input": { - "values": [["1", "2", "3", "4"]] - }, - "output": { - "Ok": { - "value": "18821383157269793795438455681495246036402687001665670618754263018637548127333" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_4.zok", + "tests": [ + { + "input": { + "values": [["1", "2", "3", "4"]] + }, + "output": { + "Ok": { + "value": "18821383157269793795438455681495246036402687001665670618754263018637548127333" } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_5.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_5.json index 8f09afff4..52316c887 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_5.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_5.json @@ -1,35 +1,35 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_5.zok", - "tests": [ - { - "input": { - "values": [["1", "2", "3", "4", "5"]] - }, - "output": { - "Ok": { - "value": "6183221330272524995739186171720101788151706631170188140075976616310159254464" - } - } - }, - { - "input": { - "values": [["1", "2", "0", "0", "0"]] - }, - "output": { - "Ok": { - "value": "1018317224307729531995786483840663576608797660851238720571059489595066344487" - } - } - }, - { - "input": { - "values": [["3", "4", "0", "0", "0"]] - }, - "output": { - "Ok": { - "value": "5811595552068139067952687508729883632420015185677766880877743348592482390548" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_5.zok", + "tests": [ + { + "input": { + "values": [["1", "2", "3", "4", "5"]] + }, + "output": { + "Ok": { + "value": "6183221330272524995739186171720101788151706631170188140075976616310159254464" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": [["1", "2", "0", "0", "0"]] + }, + "output": { + "Ok": { + "value": "1018317224307729531995786483840663576608797660851238720571059489595066344487" + } + } + }, + { + "input": { + "values": [["3", "4", "0", "0", "0"]] + }, + "output": { + "Ok": { + "value": "5811595552068139067952687508729883632420015185677766880877743348592482390548" + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_6.json b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_6.json index a6f8f568a..9887ef923 100644 --- a/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_6.json +++ b/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_6.json @@ -1,35 +1,35 @@ { - "entry_point": "./tests/tests/hashes/poseidon/poseidon_6.zok", - "tests": [ - { - "input": { - "values": [["1", "2", "3", "4", "5", "6"]] - }, - "output": { - "Ok": { - "value": "20400040500897583745843009878988256314335038853985262692600694741116813247201" - } - } - }, - { - "input": { - "values": [["1", "2", "0", "0", "0", "0"]] - }, - "output": { - "Ok": { - "value": "15336558801450556532856248569924170992202208561737609669134139141992924267169" - } - } - }, - { - "input": { - "values": [["3", "4", "0", "0", "0", "0"]] - }, - "output": { - "Ok": { - "value": "12263118664590987767234828103155242843640892839966517009184493198782366909018" - } - } + "entry_point": "./tests/tests/hashes/poseidon/poseidon_6.zok", + "tests": [ + { + "input": { + "values": [["1", "2", "3", "4", "5", "6"]] + }, + "output": { + "Ok": { + "value": "20400040500897583745843009878988256314335038853985262692600694741116813247201" } - ] -} \ No newline at end of file + } + }, + { + "input": { + "values": [["1", "2", "0", "0", "0", "0"]] + }, + "output": { + "Ok": { + "value": "15336558801450556532856248569924170992202208561737609669134139141992924267169" + } + } + }, + { + "input": { + "values": [["3", "4", "0", "0", "0", "0"]] + }, + "output": { + "Ok": { + "value": "12263118664590987767234828103155242843640892839966517009184493198782366909018" + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/1024bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/1024bitPadded.json index 98f308bf8..ccc952855 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/1024bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/1024bitPadded.json @@ -1,15 +1,15 @@ { - "entry_point": "./tests/tests/hashes/sha256/1024bitPadded.zok", - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/sha256/1024bitPadded.zok", + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.json index 1d24231ac..c3a95a334 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.json @@ -1,14 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/256bitPadded.zok", - "curves": ["Bn128"], - "tests": [{ - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } + "entry_point": "./tests/tests/hashes/sha256/256bitPadded.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - }] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/512bit.json b/zokrates_stdlib/tests/tests/hashes/sha256/512bit.json index 3d64dcc5a..1f846cf58 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/512bit.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/512bit.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/sha256/512bit.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked.json b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked.json index dc6cca9bd..c89de0966 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked.json @@ -1,16 +1,19 @@ { - "entry_point": "./stdlib/hashes/sha256/512bitPacked.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [["0", "0", "0", "5"]] - }, - "output": { - "Ok": { - "value": ["263561599766550617289250058199814760685", "65303172752238645975888084098459749904"] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./stdlib/hashes/sha256/512bitPacked.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [["0", "0", "0", "5"]] + }, + "output": { + "Ok": { + "value": [ + "263561599766550617289250058199814760685", + "65303172752238645975888084098459749904" + ] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked2.json b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked2.json index 0f9684428..29ef1e9c0 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked2.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked2.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/512bitPacked.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/sha256/512bitPacked.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPadded.json index 333cc17e4..195788b83 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/512bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/512bitPadded.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/512bitPadded.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/sha256/512bitPadded.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/embed/1024bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/embed/1024bitPadded.json index 1dfd086b0..6b61c3cd8 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/embed/1024bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/embed/1024bitPadded.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/embed/256bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/embed/256bitPadded.json index e8f2a0200..b545b4330 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/embed/256bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/embed/256bitPadded.json @@ -1,14 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/embed/256bitPadded.zok", - "curves": ["Bn128"], - "tests": [{ - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } + "entry_point": "./tests/tests/hashes/sha256/embed/256bitPadded.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - }] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bit.json b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bit.json index e813eafdd..b6ad807a0 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bit.json @@ -13,4 +13,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.json b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.json index 28353b782..59a1d87b6 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.json @@ -13,4 +13,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPadded.json b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPadded.json index 04bf93ea2..e0b064d46 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPadded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPadded.json @@ -13,4 +13,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha256/sha256Padded.json b/zokrates_stdlib/tests/tests/hashes/sha256/sha256Padded.json index 7c1a6b1b2..aee827d32 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha256/sha256Padded.json +++ b/zokrates_stdlib/tests/tests/hashes/sha256/sha256Padded.json @@ -1,14 +1,16 @@ { - "entry_point": "./tests/tests/hashes/sha256/sha256Padded.zok", - "curves": ["Bn128"], - "tests": [{ - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } + "entry_point": "./tests/tests/hashes/sha256/sha256Padded.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] } - }] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha3/224bit.json b/zokrates_stdlib/tests/tests/hashes/sha3/224bit.json index 741e432cd..bd7172c60 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha3/224bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha3/224bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha3/256bit.json b/zokrates_stdlib/tests/tests/hashes/sha3/256bit.json index b47f17026..f600266be 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha3/256bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha3/256bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha3/384bit.json b/zokrates_stdlib/tests/tests/hashes/sha3/384bit.json index 2ed4e95b5..1b700d7a8 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha3/384bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha3/384bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/sha3/512bit.json b/zokrates_stdlib/tests/tests/hashes/sha3/512bit.json index d7984bee6..ee03b48ef 100644 --- a/zokrates_stdlib/tests/tests/hashes/sha3/512bit.json +++ b/zokrates_stdlib/tests/tests/hashes/sha3/512bit.json @@ -12,4 +12,4 @@ } } ] -} \ No newline at end of file +} diff --git a/zokrates_stdlib/tests/tests/hashes/utils/256bitsDirectionHelper.json b/zokrates_stdlib/tests/tests/hashes/utils/256bitsDirectionHelper.json index c5a345c84..a6578d5c0 100644 --- a/zokrates_stdlib/tests/tests/hashes/utils/256bitsDirectionHelper.json +++ b/zokrates_stdlib/tests/tests/hashes/utils/256bitsDirectionHelper.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/hashes/utils/256bitsDirectionHelper.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/hashes/utils/256bitsDirectionHelper.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/signatures/verifyEddsa.json b/zokrates_stdlib/tests/tests/signatures/verifyEddsa.json index f20e32944..bea9daf72 100644 --- a/zokrates_stdlib/tests/tests/signatures/verifyEddsa.json +++ b/zokrates_stdlib/tests/tests/signatures/verifyEddsa.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/signatures/verifyEddsa.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/signatures/verifyEddsa.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/snark/gm17.json b/zokrates_stdlib/tests/tests/snark/gm17.json index 2645c1618..c3f7a2dd0 100644 --- a/zokrates_stdlib/tests/tests/snark/gm17.json +++ b/zokrates_stdlib/tests/tests/snark/gm17.json @@ -1,7 +1,7 @@ { "entry_point": "./tests/tests/snark/gm17.zok", "curves": ["Bw6_761"], - "tests": [ + "tests": [ { "input": { "values": [ diff --git a/zokrates_stdlib/tests/tests/utils/casts/bool.json b/zokrates_stdlib/tests/tests/utils/casts/bool.json new file mode 100644 index 000000000..c325f9c38 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/bool.json @@ -0,0 +1,17 @@ +{ + "entry_point": "./tests/tests/utils/casts/bool.zok", + "max_constraint_count": 0, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/bool.zok b/zokrates_stdlib/tests/tests/utils/casts/bool.zok new file mode 100644 index 000000000..102d90535 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/bool.zok @@ -0,0 +1,47 @@ +from "utils/casts.zok" import cast; + +// bool[8] -> u8 +// bool[N] -> u8[P] +// bool[16] -> u16 +// bool[N] -> u16[P] +// bool[32] -> u32 +// bool[N] -> u32[P] +// bool[64] -> u64 +// bool[N] -> u64[P] + +def main() { + bool[8] bits = [true, false, true, false, true, false, true, false]; + + // bool[8] -> u8 + u8 v0 = cast(bits); + assert(v0 == 0xAA); + + // bool[16] -> u8[2] + u8[2] v1 = cast([...bits, ...[true; 8]]); + assert(v1 == [0xAA, 0xFF]); + + // bool[16] -> u16 + u16 v2 = cast([...bits, ...[true; 8]]); + assert(v2 == 0xAAFF); + + // bool[32] -> u16[2] + u16[2] v3 = cast([...bits, ...[true; 8], ...[false; 8], ...[true; 8]]); + assert(v3 == [0xAAFF, 0x00FF]); + + // bool[32] -> u32 + u32 v4 = cast([...bits, ...[true; 8], ...[false; 8], ...[true; 8]]); + assert(v4 == 0xAAFF00FF); + + // bool[64] -> u32[2] + u32[2] v5 = cast([...bits, ...[false; 16], ...[true; 8], ...[true; 24], ...[false; 8]]); + assert(v5 == [0xAA0000FF, 0xFFFFFF00]); + + // bool[64] -> u64 + u64 v6 = cast([...bits, ...[false; 24], ...[true; 8], ...[false; 24]]); + assert(v6 == 0xAA000000FF000000); + + // bool[128] -> u64[2] + u64[2] v7 = cast([...bits, ...[false; 56], ...[true; 56], ...[false; 8]]); + assert(v7 == [0xAA00000000000000, 0xFFFFFFFFFFFFFF00]); + return; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/field_to_uint.json b/zokrates_stdlib/tests/tests/utils/casts/field_to_uint.json index 7531b35ce..e5225799d 100644 --- a/zokrates_stdlib/tests/tests/utils/casts/field_to_uint.json +++ b/zokrates_stdlib/tests/tests/utils/casts/field_to_uint.json @@ -1,17 +1,59 @@ { - "entry_point": "./tests/tests/utils/casts/field_to_uint.zok", - "curves": ["Bn128"], - "abi": false, - "tests": [ - { - "input": { - "values": ["0", "1", "18446744073709551615", "18446744073709551616", "18446744073709551658", "0", "1", "4294967295", "4294967296", "4294967338", "0", "1", "65535", "65536", "65578", "0", "1", "255", "256", "298"] - }, - "output": { - "Ok": { - "value": ["0", "1", "18446744073709551615", "0", "42", "0", "1", "4294967295", "0", "42", "0", "1", "65535", "0", "42", "0", "1", "255", "0", "42"] - } - } + "entry_point": "./tests/tests/utils/casts/field_to_uint.zok", + "curves": ["Bn128"], + "abi": false, + "tests": [ + { + "input": { + "values": [ + "0", + "1", + "18446744073709551615", + "18446744073709551616", + "18446744073709551658", + "0", + "1", + "4294967295", + "4294967296", + "4294967338", + "0", + "1", + "65535", + "65536", + "65578", + "0", + "1", + "255", + "256", + "298" + ] + }, + "output": { + "Ok": { + "value": [ + "0", + "1", + "18446744073709551615", + "0", + "42", + "0", + "1", + "4294967295", + "0", + "42", + "0", + "1", + "65535", + "0", + "42", + "0", + "1", + "255", + "0", + "42" + ] } - ] -} \ No newline at end of file + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/to_bits.json b/zokrates_stdlib/tests/tests/utils/casts/to_bits.json deleted file mode 100644 index dbd83b743..000000000 --- a/zokrates_stdlib/tests/tests/utils/casts/to_bits.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "entry_point": "./tests/tests/utils/casts/to_bits.zok", - "curves": ["Bn128"], - "abi": false, - "tests": [ - { - "input": { - "values": ["0", "1", "18446744073709551615", "42", "0", "1", "4294967295", "42", "0", "1", "65535", "42", "0", "1", "255", "42"] - }, - "output": { - "Ok": { - "value": [ - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", - "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "1", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", - "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "1", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", - "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", - "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "1", "0", "1", "0", - "0", "0", "0", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0", "1", - "1", "1", "1", "1", "1", "1", "1", "1", - "0", "0", "1", "0", "1", "0", "1", "0" - ] - } - } - } - ] -} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/to_field.json b/zokrates_stdlib/tests/tests/utils/casts/to_field.json deleted file mode 100644 index 49caa9957..000000000 --- a/zokrates_stdlib/tests/tests/utils/casts/to_field.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "entry_point": "./tests/tests/utils/casts/to_field.zok", - "curves": ["Bn128"], - "abi": false, - "tests": [ - { - "input": { - "values": ["0", "1", "18446744073709551615", "42", "0", "1", "4294967295", "42", "0", "1", "65535", "42", "0", "1", "255", "42"] - }, - "output": { - "Ok": { - "value": ["0", "1", "18446744073709551615", "42", "0", "1", "4294967295", "42", "0", "1", "65535", "42", "0", "1", "255", "42"] - } - } - } - ] -} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/u16.json b/zokrates_stdlib/tests/tests/utils/casts/u16.json new file mode 100644 index 000000000..af8c3b321 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u16.json @@ -0,0 +1,17 @@ +{ + "entry_point": "./tests/tests/utils/casts/u16.zok", + "max_constraint_count": 0, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/u16.zok b/zokrates_stdlib/tests/tests/utils/casts/u16.zok new file mode 100644 index 000000000..6e11659d3 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u16.zok @@ -0,0 +1,64 @@ +from "utils/casts.zok" import cast; + +// u16 -> bool[16] +// u16[N] -> bool[P] +// u16 -> field +// u16[N] -> field[N] +// u16 -> u8[2] +// u16[N] -> u8[P] +// u16 -> u32 +// u16[2] -> u32 +// u16[N] -> u32[P] +// u16 -> u64 +// u16[4] -> u64 +// u16[N] -> u64[P] + +def main() { + // u16 -> bool[16] + bool[16] v0 = cast(0xFFFF); + assert(v0 == [true; 16]); + + // u16[N] -> bool[P] + bool[32] v1 = cast([0xFFFF, 0x00FF]); + assert(v1 == [...[true; 16], ...[false; 8], ...[true; 8]]); + + // u16 -> field + field v2 = cast(0x1234); + assert(v2 == 4660); + + field[2] v3 = cast([0x1234, 0x5678]); + assert(v3 == [4660, 22136]); + + // u16 -> u8[2] + u8[2] v4 = cast(0x1234); + assert(v4 == [0x12, 0x34]); + + // u16[N] -> u8[P] + u8[4] v5 = cast([0x1234, 0x5678]); + assert(v5 == [0x12, 0x34, 0x56, 0x78]); + + // u16 -> u32 + u32 v6 = cast(0xFFFF); + assert(v6 == 0x0000FFFF); + + // u16[2] -> u32 + u32 v7 = cast([0x1234, 0x5678]); + assert(v7 == 0x12345678); + + // u16[4] -> u32[2] + u32[2] v8 = cast([0x1234, 0x5678, 0x8765, 0x4321]); + assert(v8 == [0x12345678, 0x87654321]); + + // u16 -> u64 + u64 v9 = cast(0xFFFF); + assert(v9 == 0x000000000000FFFF); + + // u16[4] -> u64 + u64 v10 = cast([0x1234, 0x5678, 0x8765, 0x4321]); + assert(v10 == 0x1234567887654321); + + // u16[8] -> u64[2] + u64[2] v11 = cast([0xFFFF; 8]); + assert(v11 == [0xFFFFFFFFFFFFFFFF; 2]); + return; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/u32.json b/zokrates_stdlib/tests/tests/utils/casts/u32.json new file mode 100644 index 000000000..56ba8e2c3 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u32.json @@ -0,0 +1,17 @@ +{ + "entry_point": "./tests/tests/utils/casts/u32.zok", + "max_constraint_count": 0, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/u32.zok b/zokrates_stdlib/tests/tests/utils/casts/u32.zok new file mode 100644 index 000000000..66bb72ddc --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u32.zok @@ -0,0 +1,61 @@ +from "utils/casts.zok" import cast; + +// u32 -> bool[32] +// u32[N] -> bool[P] +// u32 -> field +// u32[N] -> field[N] +// u32 -> u8[4] +// u32[N] -> u8[P] +// u32 -> u16[2] +// u32[N] -> u16[P] +// u32 -> u64 +// u32[2] -> u64 +// u32[N] -> u64[P] + +def main() { + // u32 -> bool[32] + bool[32] v0 = cast(0x0000FFFF); + assert(v0 == [...[false; 16], ...[true; 16]]); + + // u32[2] -> bool[64] + bool[64] v1 = cast([0x0000FFFF, 0xFFFFFFFF]); + assert(v1 == [...[false; 16], ...[true; 16], ...[true; 32]]); + + // u32 -> field + field v2 = cast(0x12345678); + assert(v2 == 305419896); + + // u32[2] -> field[2] + field[2] v3 = cast([0x12345678, 0x87654321]); + assert(v3 == [305419896, 2271560481]); + + // u32 -> u8[4] + u8[4] v4 = cast(0x12345678); + assert(v4 == [0x12, 0x34, 0x56, 0x78]); + + // u32[2] -> u8[8] + u8[8] v5 = cast([0x12345678, 0x87654321]); + assert(v5 == [0x12, 0x34, 0x56, 0x78, 0x87, 0x65, 0x43, 0x21]); + + // u32 -> u16[2] + u16[2] v6 = cast(0x12345678); + assert(v6 == [0x1234, 0x5678]); + + // u32[2] -> u16[4] + u16[4] v7 = cast([0x12345678, 0x87654321]); + assert(v7 == [0x1234, 0x5678, 0x8765, 0x4321]); + + // u32 -> u64 + u64 v8 = cast(0x12345678); + assert(v8 == 0x0000000012345678); + + // u32[2] -> u64 + u64 v9 = cast([0x12345678, 0x87654321]); + assert(v9 == 0x1234567887654321); + + // u32[4] -> u64[2] + u64[2] v10 = cast([0x12345678, 0x00000000, 0x00000000, 0x87654321]); + assert(v10 == [0x1234567800000000, 0x0000000087654321]); + + return; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/u64.json b/zokrates_stdlib/tests/tests/utils/casts/u64.json new file mode 100644 index 000000000..230850b2e --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u64.json @@ -0,0 +1,17 @@ +{ + "entry_point": "./tests/tests/utils/casts/u64.zok", + "max_constraint_count": 0, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/u64.zok b/zokrates_stdlib/tests/tests/utils/casts/u64.zok new file mode 100644 index 000000000..f32c3586c --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u64.zok @@ -0,0 +1,58 @@ +from "utils/casts.zok" import cast; + +// u64 -> bool[64] +// u64[N] -> bool[P] +// u64 -> field +// u64[N] -> field[N] +// u64 -> u8[8] +// u64[N] -> u8[P] +// u64 -> u16[4] +// u64[N] -> u16[P] +// u64 -> u32[2] +// u64[N] -> u32[P] + +def main() { + // u64 -> bool[64] + bool[64] v0 = cast(0x0000FFFF0000FFFF); + assert(v0 == [...[false; 16], ...[true; 16], ...[false; 16], ...[true; 16]]); + + // u64[2] -> bool[128] + bool[128] v1 = cast([0x0000000000000000, 0xFFFFFFFFFFFFFFFF]); + assert(v1 == [...[false; 64], ...[true; 64]]); + + // u64 -> field + field v2 = cast(0x0000FFFF0000FFFF); + assert(v2 == 281470681808895); + + // u64[2] -> field[2] + field[2] v3 = cast([0x0000FFFF0000FFFF, 0xFFFF0000FFFF0000]); + assert(v3 == [281470681808895, 18446462603027742720]); + + // u64 -> u8[8] + u8[8] v4 = cast(0x0000FFFF0000FFFF); + assert(v4 == [0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF]); + + // u64[2] -> u8[16] + u8[16] v5 = cast([0x0000FFFF0000FFFF, 0xFFFF0000FFFF0000]); + assert(v5 == [ + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 + ]); + + // u64 -> u16[4] + u16[4] v6 = cast(0x0000FFFF0000FFFF); + assert(v6 == [0x0000, 0xFFFF, 0x0000, 0xFFFF]); + + // u64[2] -> u16[8] + u16[8] v7 = cast([0x0000FFFF0000FFFF, 0xFFFF0000FFFF0000]); + assert(v7 == [0x0000, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0x0000]); + + // u64 -> u32[2] + u32[2] v8 = cast(0x0000FFFF0000FFFF); + assert(v8 == [0x0000FFFF, 0x0000FFFF]); + + // u64[2] -> u32[4] + u32[4] v9 = cast([0x0000FFFF0000FFFF, 0xFFFF0000FFFF0000]); + assert(v9 == [0x0000FFFF, 0x0000FFFF, 0xFFFF0000, 0xFFFF0000]); + return; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/u8.json b/zokrates_stdlib/tests/tests/utils/casts/u8.json new file mode 100644 index 000000000..66eddd8b9 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u8.json @@ -0,0 +1,17 @@ +{ + "entry_point": "./tests/tests/utils/casts/u8.zok", + "max_constraint_count": 0, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/u8.zok b/zokrates_stdlib/tests/tests/utils/casts/u8.zok new file mode 100644 index 000000000..2b72beaec --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/u8.zok @@ -0,0 +1,70 @@ +from "utils/casts.zok" import cast; + +// u8 -> bool[8] +// u8[N] -> bool[P] +// u8 -> field +// u8[N] -> field[N] +// u8 -> u16 +// u8[2] -> u16 +// u8[N] -> u16[P] +// u8 -> u32 +// u8[4] -> u32 +// u8[N] -> u32[P] +// u8 -> u64 +// u8[8] -> u64 +// u8[N] -> u64[P] + +def main() { + // u8 -> bool[8] + bool[8] v0 = cast(0xFF); + assert(v0 == [true; 8]); + + // u8[2] -> bool[16] + bool[16] v1 = cast([0xFF, 0x00]); + assert(v1 == [...[true; 8], ...[false; 8]]); + + // u8 -> field + field v2 = cast(0xFF); + assert(v2 == 255f); + + // u8[2] -> field[2] + field[2] v3 = cast([0x2A, 0xFF]); + assert(v3 == [42f, 255f]); + + // u8 -> u16 + u16 v4 = cast(0xFF); + assert(v4 == 0x00FF); + + // u8[2] -> u16 + u16 v5 = cast([0x2A, 0xFF]); + assert(v5 == 0x2AFF); + + // u8[4] -> u16[2] + u16[2] v6 = cast([0x2A, 0xFF, 0xFF, 0xFE]); + assert(v6 == [0x2AFF, 0xFFFE]); + + // u8 -> u32 + u32 v7 = cast(0xFF); + assert(v7 == 0x000000FF); + + // u8[4] -> u32 + u32 v8 = cast([0x2A, 0xFF, 0xFF, 0xFE]); + assert(v8 == 0x2AFFFFFE); + + // u8[8] -> u32[2] + u32[2] v9 = cast([0x2A, 0xFF, 0xFF, 0xFE, 0x00, 0xFF, 0xFF, 0xFE]); + assert(v9 == [0x2AFFFFFE, 0x00FFFFFE]); + + // u8 -> u64 + u64 v10 = cast(0xFF); + assert(v10 == 0x00000000000000FF); + + // u8[8] -> u64 + u64 v11 = cast([0x2A, 0xFF, 0xFF, 0xFE, 0x00, 0xFF, 0xFF, 0xFE]); + assert(v11 == 0x2AFFFFFE00FFFFFE); + + // u8[16] -> u64[2] + u64[2] v12 = cast([...[0x00; 7], 0xFF, ...[0xFF; 8]]); + assert(v12 == [0x00000000000000FF, 0xFFFFFFFFFFFFFFFF]); + return; +} \ No newline at end of file diff --git a/zokrates_stdlib/tests/tests/utils/casts/uint_to_bits.json b/zokrates_stdlib/tests/tests/utils/casts/uint_to_bits.json new file mode 100644 index 000000000..e2cf3f3ec --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/uint_to_bits.json @@ -0,0 +1,515 @@ +{ + "entry_point": "./tests/tests/utils/casts/uint_to_bits.zok", + "curves": ["Bn128"], + "abi": false, + "tests": [ + { + "input": { + "values": [ + "0", + "1", + "18446744073709551615", + "42", + "0", + "1", + "4294967295", + "42", + "0", + "1", + "65535", + "42", + "0", + "1", + "255", + "42" + ] + }, + "output": { + "Ok": { + "value": [ + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "0", + "1", + "0", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "0", + "1", + "0", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "0", + "1", + "0", + "1", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "0", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "1", + "0", + "0", + "1", + "0", + "1", + "0", + "1", + "0" + ] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/to_bits.zok b/zokrates_stdlib/tests/tests/utils/casts/uint_to_bits.zok similarity index 100% rename from zokrates_stdlib/tests/tests/utils/casts/to_bits.zok rename to zokrates_stdlib/tests/tests/utils/casts/uint_to_bits.zok diff --git a/zokrates_stdlib/tests/tests/utils/casts/uint_to_field.json b/zokrates_stdlib/tests/tests/utils/casts/uint_to_field.json new file mode 100644 index 000000000..62028faa1 --- /dev/null +++ b/zokrates_stdlib/tests/tests/utils/casts/uint_to_field.json @@ -0,0 +1,51 @@ +{ + "entry_point": "./tests/tests/utils/casts/uint_to_field.zok", + "curves": ["Bn128"], + "abi": false, + "tests": [ + { + "input": { + "values": [ + "0", + "1", + "18446744073709551615", + "42", + "0", + "1", + "4294967295", + "42", + "0", + "1", + "65535", + "42", + "0", + "1", + "255", + "42" + ] + }, + "output": { + "Ok": { + "value": [ + "0", + "1", + "18446744073709551615", + "42", + "0", + "1", + "4294967295", + "42", + "0", + "1", + "65535", + "42", + "0", + "1", + "255", + "42" + ] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/casts/to_field.zok b/zokrates_stdlib/tests/tests/utils/casts/uint_to_field.zok similarity index 100% rename from zokrates_stdlib/tests/tests/utils/casts/to_field.zok rename to zokrates_stdlib/tests/tests/utils/casts/uint_to_field.zok diff --git a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.json b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.json index efc9bcfde..4e6856d45 100644 --- a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.json +++ b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/multiplexer/lookup1bit.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/multiplexer/lookup1bit.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup2bit.json b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup2bit.json index 6ad7760ed..aa0fc9c83 100644 --- a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup2bit.json +++ b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup2bit.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/multiplexer/lookup2bit.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/multiplexer/lookup2bit.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup3bitSigned.json b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup3bitSigned.json index 343e019c2..5710ba935 100644 --- a/zokrates_stdlib/tests/tests/utils/multiplexer/lookup3bitSigned.json +++ b/zokrates_stdlib/tests/tests/utils/multiplexer/lookup3bitSigned.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/multiplexer/lookup3bitSigned.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/multiplexer/lookup3bitSigned.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/bool/nonStrictUnpack256.json b/zokrates_stdlib/tests/tests/utils/pack/bool/nonStrictUnpack256.json index d89bd658c..dc6f88bd7 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/bool/nonStrictUnpack256.json +++ b/zokrates_stdlib/tests/tests/utils/pack/bool/nonStrictUnpack256.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/bool/nonStrictUnpack256.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/bool/nonStrictUnpack256.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/bool/pack128.json b/zokrates_stdlib/tests/tests/utils/pack/bool/pack128.json index 98ca5e223..3ed3b7352 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/bool/pack128.json +++ b/zokrates_stdlib/tests/tests/utils/pack/bool/pack128.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/bool/pack128.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/bool/pack128.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/bool/unpack128.json b/zokrates_stdlib/tests/tests/utils/pack/bool/unpack128.json index d82476724..90a23c09a 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/bool/unpack128.json +++ b/zokrates_stdlib/tests/tests/utils/pack/bool/unpack128.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/bool/unpack128.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/bool/unpack128.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.json b/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.json index 04dd70136..b28e20e53 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.json +++ b/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/bool/unpack256.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/bool/unpack256.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/u32/nonStrictUnpack256.json b/zokrates_stdlib/tests/tests/utils/pack/u32/nonStrictUnpack256.json index 59c0de976..00815fc75 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/u32/nonStrictUnpack256.json +++ b/zokrates_stdlib/tests/tests/utils/pack/u32/nonStrictUnpack256.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/u32/nonStrictUnpack256.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/u32/nonStrictUnpack256.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/u32/pack128.json b/zokrates_stdlib/tests/tests/utils/pack/u32/pack128.json index 721f8ab9f..d1ff17c73 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/u32/pack128.json +++ b/zokrates_stdlib/tests/tests/utils/pack/u32/pack128.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/u32/pack128.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/u32/pack128.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_stdlib/tests/tests/utils/pack/u32/unpack128.json b/zokrates_stdlib/tests/tests/utils/pack/u32/unpack128.json index d4f7c9cd3..3203010b9 100644 --- a/zokrates_stdlib/tests/tests/utils/pack/u32/unpack128.json +++ b/zokrates_stdlib/tests/tests/utils/pack/u32/unpack128.json @@ -1,16 +1,16 @@ { - "entry_point": "./tests/tests/utils/pack/u32/unpack128.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [] - }, - "output": { - "Ok": { - "value": [] - } - } - } - ] -} \ No newline at end of file + "entry_point": "./tests/tests/utils/pack/u32/unpack128.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +}