├── .dockerignore
├── .codecov.yml
├── changelogs
└── unreleased
│ ├── .gitkeep
│ ├── 34-zhfnjust
│ └── 29-zhfnjust
├── clippy.toml
├── zokrates_stdlib
├── src
│ └── lib.rs
├── tests
│ ├── integration.rs
│ └── tests
│ │ ├── field.zok
│ │ ├── hashes
│ │ ├── poseidon
│ │ │ ├── poseidon_1.zok
│ │ │ ├── poseidon_2.zok
│ │ │ ├── poseidon_3.zok
│ │ │ ├── poseidon_4.zok
│ │ │ ├── poseidon_5.zok
│ │ │ ├── poseidon_6.zok
│ │ │ ├── poseidon_2.json
│ │ │ ├── poseidon_3.json
│ │ │ └── poseidon_4.json
│ │ ├── mimcSponge
│ │ │ ├── mimcFeistel.zok
│ │ │ └── mimcSponge.json
│ │ ├── mimc7
│ │ │ └── mimc7.json
│ │ ├── sha3
│ │ │ ├── 224bit.json
│ │ │ ├── 256bit.json
│ │ │ ├── 384bit.json
│ │ │ └── 512bit.json
│ │ ├── keccak
│ │ │ ├── 224bit.json
│ │ │ ├── 256bit.json
│ │ │ ├── 384bit.json
│ │ │ ├── 512bit.json
│ │ │ └── keccak.json
│ │ ├── blake2
│ │ │ ├── blake2s_p.json
│ │ │ ├── blake2s_512bit.json
│ │ │ ├── blake2s_1024bit.json
│ │ │ ├── blake2s_1536bit.json
│ │ │ └── blake2s_8192bit.json
│ │ ├── sha256
│ │ │ ├── 1024bitPadded.json
│ │ │ ├── embed
│ │ │ │ ├── 1024bitPadded.json
│ │ │ │ ├── 512bit.json
│ │ │ │ ├── 256bitPadded.json
│ │ │ │ ├── 512bitPacked.json
│ │ │ │ ├── 512bitPadded.json
│ │ │ │ └── 512bitPacked.zok
│ │ │ ├── 512bit.json
│ │ │ ├── 256bitPadded.json
│ │ │ ├── 512bitPacked2.json
│ │ │ ├── 512bitPadded.json
│ │ │ ├── sha256Padded.json
│ │ │ └── 256bitPadded.zok
│ │ ├── pedersen
│ │ │ ├── 512bit.json
│ │ │ └── 512bitBool.json
│ │ └── utils
│ │ │ └── 256bitsDirectionHelper.json
│ │ ├── ecc
│ │ ├── edwardsAdd.json
│ │ ├── edwardsCompress.json
│ │ ├── edwardsOnCurve.json
│ │ ├── edwardsOrderCheck.json
│ │ ├── edwardsScalarMult.json
│ │ └── proofOfOwnership.json
│ │ ├── signatures
│ │ └── verifyEddsa.json
│ │ └── utils
│ │ ├── pack
│ │ ├── bool
│ │ │ ├── pack128.json
│ │ │ ├── unpack128.json
│ │ │ ├── unpack256.json
│ │ │ ├── nonStrictUnpack256.json
│ │ │ └── unpack256.zok
│ │ └── u32
│ │ │ ├── pack128.json
│ │ │ ├── unpack128.json
│ │ │ └── nonStrictUnpack256.json
│ │ ├── multiplexer
│ │ ├── lookup1bit.json
│ │ ├── lookup2bit.json
│ │ ├── lookup3bitSigned.json
│ │ └── lookup1bit.zok
│ │ └── casts
│ │ ├── u8.json
│ │ ├── bool.json
│ │ ├── u16.json
│ │ ├── u32.json
│ │ └── u64.json
├── stdlib
│ ├── field.zok
│ ├── utils
│ │ ├── casts
│ │ │ ├── u8_to_bits.zok
│ │ │ ├── u16_to_bits.zok
│ │ │ ├── u32_to_bits.zok
│ │ │ ├── u64_to_bits.zok
│ │ │ ├── u8_from_bits.zok
│ │ │ ├── u16_from_bits.zok
│ │ │ ├── u32_from_bits.zok
│ │ │ ├── u64_from_bits.zok
│ │ │ ├── bool_128_to_u32_4.zok
│ │ │ ├── bool_256_to_u32_8.zok
│ │ │ ├── u32_4_to_bool_128.zok
│ │ │ ├── u32_8_to_bool_256.zok
│ │ │ ├── field_to_u8.zok
│ │ │ ├── field_to_u16.zok
│ │ │ ├── field_to_u32.zok
│ │ │ ├── field_to_u64.zok
│ │ │ ├── u8_to_field.zok
│ │ │ ├── u16_to_field.zok
│ │ │ ├── u32_to_field.zok
│ │ │ ├── u64_to_field.zok
│ │ │ ├── u32_array_to_bool_array.zok
│ │ │ └── bool_array_to_u32_array.zok
│ │ ├── pack
│ │ │ ├── u32
│ │ │ │ ├── pack128.zok
│ │ │ │ ├── pack.zok
│ │ │ │ ├── unpack128.zok
│ │ │ │ └── nonStrictUnpack256.zok
│ │ │ └── bool
│ │ │ │ ├── pack128.zok
│ │ │ │ ├── pack.zok
│ │ │ │ ├── unpack128.zok
│ │ │ │ ├── unpack256.zok
│ │ │ │ ├── unpack_unchecked.zok
│ │ │ │ ├── pack256.zok
│ │ │ │ └── nonStrictUnpack256.zok
│ │ └── multiplexer
│ │ │ ├── lookup1bit.zok
│ │ │ ├── lookup2bit.zok
│ │ │ └── lookup3bitSigned.zok
│ ├── hashes
│ │ ├── blake2
│ │ │ └── blake2s.zok
│ │ ├── sha3
│ │ │ ├── 224bit.zok
│ │ │ ├── 256bit.zok
│ │ │ ├── 384bit.zok
│ │ │ └── 512bit.zok
│ │ ├── keccak
│ │ │ ├── 224bit.zok
│ │ │ ├── 256bit.zok
│ │ │ ├── 384bit.zok
│ │ │ └── 512bit.zok
│ │ ├── utils
│ │ │ └── 256bitsDirectionHelper.zok
│ │ └── sha256
│ │ │ ├── 512bit.zok
│ │ │ ├── embed
│ │ │ ├── shaRoundNoBoolCheck.zok
│ │ │ └── 512bit.zok
│ │ │ ├── 1024bit.zok
│ │ │ └── 1536bit.zok
│ └── ecc
│ │ └── edwardsNegate.zok
└── Cargo.toml
├── zokrates_book
├── src
│ ├── concepts
│ │ └── stdlib.md
│ ├── language
│ │ ├── index.md
│ │ ├── macros.md
│ │ ├── generics.md
│ │ └── logging.md
│ ├── toolbox
│ │ ├── index.md
│ │ └── cli.md
│ └── examples
│ │ ├── index.md
│ │ └── magic_square.md
├── .gitignore
└── book.toml
├── zokrates_core_test
├── src
│ └── lib.rs
├── tests
│ ├── integration.rs
│ └── tests
│ │ ├── uint
│ │ ├── u8
│ │ │ ├── not.zok
│ │ │ ├── add.zok
│ │ │ ├── and.zok
│ │ │ ├── div.zok
│ │ │ ├── gt.zok
│ │ │ ├── lshift.zok
│ │ │ ├── lt.zok
│ │ │ ├── mul.zok
│ │ │ ├── or.zok
│ │ │ ├── rem.zok
│ │ │ ├── rshift.zok
│ │ │ ├── xor.zok
│ │ │ ├── eq.zok
│ │ │ ├── gte.zok
│ │ │ ├── lte.zok
│ │ │ ├── neq.zok
│ │ │ └── sub.zok
│ │ ├── u16
│ │ │ ├── not.zok
│ │ │ ├── lshift.zok
│ │ │ ├── rshift.zok
│ │ │ ├── add.zok
│ │ │ ├── and.zok
│ │ │ ├── div.zok
│ │ │ ├── eq.zok
│ │ │ ├── gt.zok
│ │ │ ├── gte.zok
│ │ │ ├── lt.zok
│ │ │ ├── lte.zok
│ │ │ ├── mul.zok
│ │ │ ├── neq.zok
│ │ │ ├── or.zok
│ │ │ ├── rem.zok
│ │ │ ├── xor.zok
│ │ │ └── sub.zok
│ │ ├── u32
│ │ │ ├── not.zok
│ │ │ ├── lshift.zok
│ │ │ ├── rshift.zok
│ │ │ ├── add.zok
│ │ │ ├── and.zok
│ │ │ ├── div.zok
│ │ │ ├── eq.zok
│ │ │ ├── gt.zok
│ │ │ ├── gte.zok
│ │ │ ├── lt.zok
│ │ │ ├── lte.zok
│ │ │ ├── mul.zok
│ │ │ ├── neq.zok
│ │ │ ├── or.zok
│ │ │ ├── rem.zok
│ │ │ ├── xor.zok
│ │ │ └── sub.zok
│ │ ├── u64
│ │ │ ├── not.zok
│ │ │ ├── lshift.zok
│ │ │ ├── rshift.zok
│ │ │ ├── add.zok
│ │ │ ├── and.zok
│ │ │ ├── div.zok
│ │ │ ├── eq.zok
│ │ │ ├── gt.zok
│ │ │ ├── gte.zok
│ │ │ ├── lt.zok
│ │ │ ├── lte.zok
│ │ │ ├── mul.zok
│ │ │ ├── neq.zok
│ │ │ ├── or.zok
│ │ │ ├── rem.zok
│ │ │ ├── xor.zok
│ │ │ └── sub.zok
│ │ ├── constant.zok
│ │ ├── ch.zok
│ │ ├── eq.json
│ │ ├── maj.zok
│ │ ├── eq.zok
│ │ ├── extend.json
│ │ ├── temp1.json
│ │ ├── temp2.json
│ │ ├── add_loop.json
│ │ ├── conditional.zok
│ │ ├── add_loop.zok
│ │ ├── constant.json
│ │ ├── rotate.zok
│ │ ├── propagation
│ │ │ └── rotate.json
│ │ ├── ch.json
│ │ └── operations.json
│ │ ├── le.zok
│ │ ├── add.zok
│ │ ├── constants
│ │ ├── issue_1047
│ │ │ ├── b.zok
│ │ │ ├── reversed
│ │ │ │ ├── a.zok
│ │ │ │ ├── b.zok
│ │ │ │ └── b.json
│ │ │ ├── a.zok
│ │ │ └── a.json
│ │ ├── field.zok
│ │ ├── issue_1038
│ │ │ ├── b.zok
│ │ │ ├── reversed
│ │ │ │ ├── a.zok
│ │ │ │ ├── b.json
│ │ │ │ └── b.zok
│ │ │ ├── a.json
│ │ │ └── a.zok
│ │ ├── uint.zok
│ │ ├── bool.zok
│ │ ├── import
│ │ │ ├── origin.zok
│ │ │ ├── destination.json
│ │ │ └── destination.zok
│ │ ├── array.zok
│ │ ├── array_size.zok
│ │ ├── propagate.zok
│ │ ├── tuple.zok
│ │ ├── nested.zok
│ │ ├── struct.zok
│ │ ├── mixed.zok
│ │ ├── bool.json
│ │ ├── field.json
│ │ ├── nested.json
│ │ ├── array.json
│ │ ├── uint.json
│ │ ├── tuple.json
│ │ ├── array_size.json
│ │ └── propagate.json
│ │ ├── div.zok
│ │ ├── import
│ │ ├── dep
│ │ │ ├── dep
│ │ │ │ └── foo.zok
│ │ │ └── foo.zok
│ │ ├── import.zok
│ │ └── import.json
│ │ ├── assert_one.zok
│ │ ├── arrays
│ │ ├── identity.zok
│ │ ├── select.zok
│ │ ├── fun_spread.json
│ │ └── fun_spread.zok
│ │ ├── bool_compare.zok
│ │ ├── tuples
│ │ ├── identity.zok
│ │ ├── empty.zok
│ │ ├── constant.zok
│ │ ├── conditional.zok
│ │ ├── element_order.zok
│ │ ├── constant.json
│ │ ├── empty.json
│ │ └── element_order.json
│ │ ├── generics
│ │ ├── call.json
│ │ ├── embed.json
│ │ ├── embed.zok
│ │ ├── cache.zok
│ │ ├── multidef.zok
│ │ ├── return_inference.zok
│ │ ├── call.zok
│ │ ├── cache.json
│ │ ├── return_inference.json
│ │ ├── same_parameter_name.zok
│ │ ├── multidef.json
│ │ └── same_parameter_name.json
│ │ ├── panics
│ │ ├── internal_panic.zok
│ │ ├── loop_bound.zok
│ │ └── conditional_bound_throw.zok
│ │ ├── range_check
│ │ ├── assert_ge.zok
│ │ ├── assert_gt.zok
│ │ ├── assert_le.zok
│ │ ├── assert_lt.zok
│ │ ├── assert_lt_u8.zok
│ │ ├── assert_gt_big_constant.zok
│ │ └── assert_lt_big_constant.zok
│ │ ├── no_return.json
│ │ ├── assert_array_equality.zok
│ │ ├── single_return.json
│ │ ├── range.zok
│ │ ├── no_return.zok
│ │ ├── structs
│ │ ├── identity.zok
│ │ ├── constant.zok
│ │ ├── constant.json
│ │ ├── member_order.zok
│ │ └── member_order.json
│ │ ├── array_conditional.zok
│ │ ├── single_return.zok
│ │ ├── ternary.zok
│ │ ├── memoize
│ │ ├── dep.zok
│ │ ├── no_array_memoization.zok
│ │ ├── no_array_memoization.json
│ │ └── memoize.json
│ │ ├── spread_slice.zok
│ │ ├── cached_condition.json
│ │ ├── right_rotation.zok
│ │ ├── left_rotation.zok
│ │ ├── split.zok
│ │ ├── cached_condition.zok
│ │ ├── shadowing.zok
│ │ ├── shadowing.json
│ │ ├── left_rotation_bits.zok
│ │ ├── right_rotation_bits.zok
│ │ ├── fact_up_to_4.zok
│ │ ├── compare_min_to_max.zok
│ │ ├── precedence.json
│ │ ├── complex_call.zok
│ │ ├── compare_min_to_max.json
│ │ ├── complex_call.json
│ │ ├── pass_by_value.json
│ │ └── spread_slice.json
├── build.rs
└── Cargo.toml
├── zokrates_cli
├── examples
│ ├── book
│ │ ├── no_return.zok
│ │ ├── assert.zok
│ │ ├── not_equal.zok
│ │ ├── factorize.zok
│ │ ├── constant_definition.zok
│ │ ├── mpc_tutorial
│ │ │ ├── circuit.zok
│ │ │ └── phase1radix2m2
│ │ ├── conditional_ternary.zok
│ │ ├── conditional.zok
│ │ ├── tuples.zok
│ │ ├── constant_reference.zok
│ │ ├── function_declaration.zok
│ │ ├── comments.zok
│ │ ├── logging.zok
│ │ ├── multiline_comments.zok
│ │ ├── mutable.zok
│ │ ├── for_scope.zok
│ │ ├── struct_init.zok
│ │ ├── generic_function_declaration.zok
│ │ ├── declaration.zok
│ │ ├── for.zok
│ │ ├── rng_tutorial
│ │ │ └── get_hash.zok
│ │ ├── field_overflow.zok
│ │ ├── abi.zok
│ │ ├── conditional_panic.zok
│ │ ├── function_scope.zok
│ │ ├── struct_assign.zok
│ │ ├── side_effects.zok
│ │ ├── generics.zok
│ │ ├── sha256_tutorial
│ │ │ ├── hashexample.zok
│ │ │ ├── hashexample_updated.zok
│ │ │ └── test.sh
│ │ ├── type_annotations.zok
│ │ ├── shadowing.zok
│ │ ├── generic_call.zok
│ │ ├── type_aliases.zok
│ │ ├── multidim_array.zok
│ │ ├── conditional_expensive.zok
│ │ ├── numeric_inference.zok
│ │ ├── structs.zok
│ │ └── explicit_generic_parameters.zok
│ ├── compile_errors
│ │ ├── no_return.zok
│ │ ├── empty-error.zok
│ │ ├── too_many_return.zok
│ │ ├── generics
│ │ │ ├── generic_in_main.zok
│ │ │ ├── generics_in_main.zok
│ │ │ ├── no_weak_eq.zok
│ │ │ ├── unused_struct_generic.zok
│ │ │ ├── concrete_length_mismatch.zok
│ │ │ ├── numerical_struct_generic.zok
│ │ │ ├── undeclared_struct_generic.zok
│ │ │ ├── duplicate_struct_generic.zok
│ │ │ ├── generic_inference.zok
│ │ │ ├── struct_generic_mismatch.zok
│ │ │ ├── incompatible.zok
│ │ │ ├── conflicting_constant.zok
│ │ │ ├── assign_size_mismatch.zok
│ │ │ ├── assertion.zok
│ │ │ ├── conflicting_functions.zok
│ │ │ ├── return_generic_call_mismatch.zok
│ │ │ └── conflicting_call.zok
│ │ ├── two_return.zok
│ │ ├── assertion.zok
│ │ ├── log_wrong_count.zok
│ │ ├── double_negation.zok
│ │ ├── loop_too_large.zok
│ │ ├── variable_shift.zok
│ │ ├── mutability
│ │ │ ├── assign_to_non_mutable.zok
│ │ │ └── multi_assign_to_non_mutable.zok
│ │ ├── assertion_unequal_arrays.zok
│ │ ├── keyword_as_identifier.zok
│ │ ├── out_of_for_scope.zok
│ │ ├── constant_type_error.zok
│ │ ├── unassigned.zok
│ │ ├── double_power.zok
│ │ ├── log_integer_type.zok
│ │ ├── no_struct_equivalence.zok
│ │ ├── reserved_log.zok
│ │ ├── constant_array_size_type_mismatch_field.zok
│ │ ├── constant_array_size_type_mismatch_u8.zok
│ │ ├── constant_assignment.zok
│ │ ├── too_many_arguments.zok
│ │ ├── too_many_generics.zok
│ │ ├── div_by_zero.zok
│ │ ├── unpack_value_too_large.zok
│ │ ├── out_of_bounds.zok
│ │ ├── constant_reduction_fail.zok
│ │ ├── declare_non_identifier.zok
│ │ ├── out_of_bounds_write.zok
│ │ ├── embed_type_mismatch.zok
│ │ ├── out_of_bounds_read.zok
│ │ ├── ifelse_statements.zok
│ │ ├── wrong_member_type.zok
│ │ ├── variable_constant_lt.zok
│ │ ├── ternary_precedence.zok
│ │ ├── const_complex_type_mismatch.zok
│ │ ├── struct_member_type_mismatch_field.zok
│ │ ├── ambiguous_generic_call.zok
│ │ ├── ambiguous_generic_call_too_strict.zok
│ │ └── struct_member_type_mismatch_u8.zok
│ ├── pragma.zok
│ ├── boolean_literal.zok
│ ├── runtime_errors
│ │ ├── div_zero_uint.zok
│ │ └── div_zero_field.zok
│ ├── simple_mul.zok
│ ├── tuples
│ │ ├── nested_access.zok
│ │ ├── constant_in_member.zok
│ │ ├── add.zok
│ │ ├── generic.zok
│ │ └── set_member.zok
│ ├── arrays
│ │ ├── array_argument.zok
│ │ ├── lookup.zok
│ │ ├── init_with_value.zok
│ │ ├── constant_array.zok
│ │ ├── if_eq.zok
│ │ ├── return_variable_array.zok
│ │ ├── repeat.zok
│ │ ├── return_array.zok
│ │ ├── large_equality.zok
│ │ ├── multi_init.zok
│ │ ├── array_loop.zok
│ │ ├── multidim_update.zok
│ │ ├── array_loop_update.zok
│ │ ├── update.zok
│ │ ├── update_with_call.zok
│ │ ├── value.zok
│ │ ├── boolean_array.zok
│ │ ├── cube.zok
│ │ └── wrap_select.zok
│ ├── reduceable_exponent.zok
│ ├── functions_equivalent.zok
│ ├── bool_not.zok
│ ├── constant_index_on_spread_inline.zok
│ ├── imports
│ │ ├── baz.zok
│ │ ├── import_multiple.zok
│ │ ├── bar.zok
│ │ ├── import_functions.zok
│ │ ├── import_constants.zok
│ │ ├── inliner_state_aux.zok
│ │ ├── import_structs.zok
│ │ ├── import_with_alias.zok
│ │ ├── foo.zok
│ │ └── inliner_state.zok
│ ├── simple_add.zok
│ ├── brackets.zok
│ ├── argument_reassign.zok
│ ├── call_in_constant.zok
│ ├── shadowing.zok
│ ├── decimal_literal.zok
│ ├── left_side_call.zok
│ ├── synonyms.zok
│ ├── explicit_generic.zok
│ ├── assign_to_element.zok
│ ├── factorization.zok
│ ├── multiple_witnesses.zok
│ ├── reassignment.zok
│ ├── functions
│ │ ├── shadowing.zok
│ │ ├── functions.zok
│ │ ├── no_args_multiple.zok
│ │ ├── multi_shadowing.zok
│ │ ├── expressions.zok
│ │ └── multi_functions.zok
│ ├── constant_in_sig.zok
│ ├── structs
│ │ ├── nested_access.zok
│ │ ├── constant_in_member.zok
│ │ ├── generic.zok
│ │ └── add.zok
│ ├── add.zok
│ ├── flatten.zok
│ ├── call_in_const_aux.zok
│ ├── array_overload.zok
│ ├── propagate_call.zok
│ ├── sub.zok
│ ├── bool_or.zok
│ ├── bool_and.zok
│ ├── propagate.zok
│ ├── simple_conditional.zok
│ ├── for.zok
│ ├── taxation.zok
│ ├── ternary_eq.zok
│ ├── call_in_const.zok
│ ├── comparison_operators.zok
│ ├── comments.zok
│ ├── array_generic_inference.zok
│ ├── no_flatten.zok
│ ├── spaces_tabs_comments.zok
│ ├── empty_spread_propagation.zok
│ ├── complex_call_in_constant.zok
│ ├── test1.zok
│ ├── test_lt_max_value.zok
│ ├── pow.zok
│ ├── struct_generic_inference.zok
│ ├── alias
│ │ ├── struct_aliasing.zok
│ │ ├── basic_aliasing.zok
│ │ └── import_alias.zok
│ └── n_choose_k.zok
├── tests
│ └── code
│ │ ├── no_return.expected.witness
│ │ ├── taxation.expected.witness
│ │ ├── n_choose_k.expected.witness
│ │ ├── no_return.arguments.json
│ │ ├── simple_mul.expected.witness
│ │ ├── arithmetics.arguments.json
│ │ ├── arithmetics.expected.witness
│ │ ├── conditional_false.arguments.json
│ │ ├── conditional_false.expected.witness
│ │ ├── conditional_true.arguments.json
│ │ ├── conditional_true.expected.witness
│ │ ├── n_choose_k.arguments.json
│ │ ├── simple_add.arguments.json
│ │ ├── simple_add.expected.witness
│ │ ├── taxation.arguments.json
│ │ ├── simple_mul.arguments.json
│ │ ├── return_array.arguments.json
│ │ ├── conditional_true.zok
│ │ ├── multidim_update.expected.witness
│ │ ├── conditional_false.zok
│ │ ├── no_return.zok
│ │ ├── arithmetics.zok
│ │ ├── multidim_update.arguments.json
│ │ ├── simple_mul.zok
│ │ ├── multidim_update.zok
│ │ ├── return_array.expected.witness
│ │ ├── simple_add.zok
│ │ ├── return_array.zok
│ │ ├── taxation.zok
│ │ ├── no_return.smt2
│ │ └── n_choose_k.zok
└── scrypt_proj_template
│ ├── .husky
│ └── pre-commit
│ ├── .gitignore
│ ├── .npmignore
│ ├── .eslintignore
│ ├── .prettierignore
│ ├── .eslintrc
│ ├── README.md
│ ├── .prettierrc
│ └── optimizations
│ └── apply_asm_optim.sh
├── zokrates_parser
├── src
│ └── textmate
│ │ ├── .gitignore
│ │ ├── .vscodeignore
│ │ └── CHANGELOG.md
├── README.md
└── Cargo.toml
├── rust-toolchain.toml
├── zokrates_pest_ast
├── README.md
└── Cargo.toml
├── test.sh
├── zokrates_js
├── build.sh
├── .dockerignore
├── .gitignore
├── .cargo
│ └── config
├── tests
│ └── powersOfTau5_0000.ptau
├── Dockerfile
├── node
│ └── index.js
├── index.js
└── README.md
├── examples
└── root.zok
├── integration_test.sh
├── zokrates_field
└── src
│ ├── bw6_761.rs
│ ├── bls12_377.rs
│ └── bls12_381.rs
├── scripts
├── install_wasm_testing.sh
├── install_solcjs_deb.sh
└── benchmark.sh
├── zokrates_test_derive
├── test_template
└── Cargo.toml
├── zokrates_core
└── src
│ ├── lib.rs
│ └── optimizer
│ └── canonicalizer.rs
├── zokrates_ast
└── src
│ ├── lib.rs
│ └── common
│ └── mod.rs
├── zokrates_common
├── src
│ ├── lib.rs
│ └── constants.rs
└── Cargo.toml
├── .github
└── workflows
│ ├── docs-check.yml
│ └── js-format-check.yml
├── zokrates_fs_resolver
└── Cargo.toml
├── dev.Dockerfile
└── CHANGELOG-scrypt.md
/.dockerignore:
--------------------------------------------------------------------------------
1 | target/
2 |
--------------------------------------------------------------------------------
/.codecov.yml:
--------------------------------------------------------------------------------
1 | comment: off
2 |
--------------------------------------------------------------------------------
/changelogs/unreleased/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/clippy.toml:
--------------------------------------------------------------------------------
1 | blacklisted-names = []
--------------------------------------------------------------------------------
/zokrates_stdlib/src/lib.rs:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/zokrates_book/src/concepts/stdlib.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/zokrates_core_test/src/lib.rs:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/zokrates_book/.gitignore:
--------------------------------------------------------------------------------
1 | book
2 | mdbook
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/no_return.zok:
--------------------------------------------------------------------------------
1 | def main() {}
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/no_return.expected.witness:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/zokrates_book/src/language/index.md:
--------------------------------------------------------------------------------
1 | # Programming Concepts
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/taxation.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 0
--------------------------------------------------------------------------------
/zokrates_parser/src/textmate/.gitignore:
--------------------------------------------------------------------------------
1 | *.tmLanguage.json
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/n_choose_k.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 5
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/no_return.arguments.json:
--------------------------------------------------------------------------------
1 | ["1", "1"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_mul.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 24
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/arithmetics.arguments.json:
--------------------------------------------------------------------------------
1 | ["1", "2"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/arithmetics.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 12
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_false.arguments.json:
--------------------------------------------------------------------------------
1 | ["0"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_false.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 0
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_true.arguments.json:
--------------------------------------------------------------------------------
1 | ["1"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_true.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 1
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/n_choose_k.arguments.json:
--------------------------------------------------------------------------------
1 | ["5", "1"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_add.arguments.json:
--------------------------------------------------------------------------------
1 | ["1", "2"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_add.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 3
2 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/taxation.arguments.json:
--------------------------------------------------------------------------------
1 | ["15", "12"]
2 |
--------------------------------------------------------------------------------
/rust-toolchain.toml:
--------------------------------------------------------------------------------
1 | [toolchain]
2 | channel = "nightly-2022-07-01"
3 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/no_return.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {}
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_mul.arguments.json:
--------------------------------------------------------------------------------
1 | ["2", "3", "4"]
2 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/empty-error.zok:
--------------------------------------------------------------------------------
1 | // no source code here
2 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/integration.rs:
--------------------------------------------------------------------------------
1 | include!(concat!(env!("OUT_DIR"), "/tests.rs"));
2 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/not.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a) -> u8 {
2 | return !a;
3 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/integration.rs:
--------------------------------------------------------------------------------
1 | include!(concat!(env!("OUT_DIR"), "/tests.rs"));
2 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/too_many_return.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | return 1;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/pragma.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | def main() {
4 | return;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/le.zok:
--------------------------------------------------------------------------------
1 | def main(field e) -> bool {
2 | return e <= 42;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/not.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a) -> u16 {
2 | return !a;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/not.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a) -> u32 {
2 | return !a;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/not.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a) -> u64 {
2 | return !a;
3 | }
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/return_array.arguments.json:
--------------------------------------------------------------------------------
1 | [["1", "1", "1"], "2", ["3", "3", "3", "3"]]
2 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/add.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) -> field {
2 | return a + b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/b.zok:
--------------------------------------------------------------------------------
1 | const field A = 1;
2 | const field B = A + 1;
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/div.zok:
--------------------------------------------------------------------------------
1 | def main(field x, field y) -> field {
2 | return x / y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/import/dep/dep/foo.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 1;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/constant.zok:
--------------------------------------------------------------------------------
1 | def main() -> u32 {
2 | return 0x01234567;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/lshift.zok:
--------------------------------------------------------------------------------
1 | def main(u16 x) -> u16 {
2 | return x << 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/rshift.zok:
--------------------------------------------------------------------------------
1 | def main(u16 x) -> u16 {
2 | return x >> 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/lshift.zok:
--------------------------------------------------------------------------------
1 | def main(u32 x) -> u32 {
2 | return x << 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/rshift.zok:
--------------------------------------------------------------------------------
1 | def main(u32 x) -> u32 {
2 | return x >> 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/lshift.zok:
--------------------------------------------------------------------------------
1 | def main(u64 x) -> u64 {
2 | return x << 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/rshift.zok:
--------------------------------------------------------------------------------
1 | def main(u64 x) -> u64 {
2 | return x >> 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/add.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> u8 {
2 | return a + b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/and.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> u8 {
2 | return a & b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/div.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x, u8 y) -> u8 {
2 | return x / y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/gt.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a > b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/lshift.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x) -> u8 {
2 | return x << 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/lt.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a < b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/mul.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> u8 {
2 | return a * b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/or.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x, u8 y) -> u8 {
2 | return x | y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/rem.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x, u8 y) -> u8 {
2 | return x % y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/rshift.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x) -> u8 {
2 | return x >> 1;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/xor.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> u8 {
2 | return a ^ b;
3 | }
--------------------------------------------------------------------------------
/zokrates_pest_ast/README.md:
--------------------------------------------------------------------------------
1 | # zokrates_pest_ast
2 |
3 | ZoKrates AST generation based on pest output.
--------------------------------------------------------------------------------
/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit if any subcommand fails
4 | set -e
5 |
6 | cargo test -j 4 --release
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/assert.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | assert(1f + 1f == 2f);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/not_equal.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) -> bool {
2 | return !(a == b);
3 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/generic_in_main.zok:
--------------------------------------------------------------------------------
1 | def main
() {
2 | return;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/two_return.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | return;
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_true.zok:
--------------------------------------------------------------------------------
1 | def main(field a) -> field {
2 | return a == 1 ? 1 : 0;
3 | }
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/multidim_update.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 0
2 | ~out_1 0
3 | ~out_2 0
4 | ~out_3 42
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/assert_one.zok:
--------------------------------------------------------------------------------
1 | def main(field a) {
2 | assert(a == 1);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/add.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> u16 {
2 | return a + b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/and.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> u16 {
2 | return a & b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/div.zok:
--------------------------------------------------------------------------------
1 | def main(u16 x, u16 y) -> u16 {
2 | return x / y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/eq.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a == b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/gt.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a > b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/gte.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a >= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/lt.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a < b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/lte.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a <= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/mul.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> u16 {
2 | return a * b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/neq.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> bool {
2 | return a != b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/or.zok:
--------------------------------------------------------------------------------
1 | def main(u16 x, u16 y) -> u16 {
2 | return x | y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/rem.zok:
--------------------------------------------------------------------------------
1 | def main(u16 x, u16 y) -> u16 {
2 | return x % y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/xor.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> u16 {
2 | return a ^ b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/add.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> u32 {
2 | return a + b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/and.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> u32 {
2 | return a & b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/div.zok:
--------------------------------------------------------------------------------
1 | def main(u32 x, u32 y) -> u32 {
2 | return x / y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/eq.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a == b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/gt.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a > b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/gte.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a >= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/lt.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a < b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/lte.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a <= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/mul.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> u32 {
2 | return a * b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/neq.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> bool {
2 | return a != b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/or.zok:
--------------------------------------------------------------------------------
1 | def main(u32 x, u32 y) -> u32 {
2 | return x | y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/rem.zok:
--------------------------------------------------------------------------------
1 | def main(u32 x, u32 y) -> u32 {
2 | return x % y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/xor.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> u32 {
2 | return a ^ b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/add.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> u64 {
2 | return a + b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/and.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> u64 {
2 | return a & b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/div.zok:
--------------------------------------------------------------------------------
1 | def main(u64 x, u64 y) -> u64 {
2 | return x / y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/eq.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a == b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/gt.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a > b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/gte.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a >= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/lt.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a < b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/lte.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a <= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/mul.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> u64 {
2 | return a * b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/neq.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> bool {
2 | return a != b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/or.zok:
--------------------------------------------------------------------------------
1 | def main(u64 x, u64 y) -> u64 {
2 | return x | y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/rem.zok:
--------------------------------------------------------------------------------
1 | def main(u64 x, u64 y) -> u64 {
2 | return x % y;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/xor.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> u64 {
2 | return a ^ b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/eq.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a == b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/gte.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a >= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/lte.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a <= b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/neq.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> bool {
2 | return a != b;
3 | }
--------------------------------------------------------------------------------
/zokrates_js/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | docker build -t zokrates_js -f zokrates_js/Dockerfile .
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/conditional_false.zok:
--------------------------------------------------------------------------------
1 | def main(field a) -> field {
2 | return a == 1 ? 1 : 0;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/no_return.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) {
2 | assert(a == b);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/arrays/identity.zok:
--------------------------------------------------------------------------------
1 | def main(bool[3] a) -> bool[3] {
2 | return a;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/reversed/a.zok:
--------------------------------------------------------------------------------
1 | const field A = 1;
2 | const field B = A + 1;
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/assertion.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | assert(1f == 2f);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/generics_in_main.zok:
--------------------------------------------------------------------------------
1 | def main
(field[P] a) {
2 | return;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/log_wrong_count.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | log("{} {}", 1f);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/arithmetics.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) -> field {
2 | return 3*a+(b+a)**2;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/bool_compare.zok:
--------------------------------------------------------------------------------
1 | def main(bool a, bool b) -> bool {
2 | return a == b;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/identity.zok:
--------------------------------------------------------------------------------
1 | def main((field, bool) a) -> (field, bool) {
2 | return a;
3 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/boolean_literal.zok:
--------------------------------------------------------------------------------
1 | def main(bool a) -> bool {
2 | return (false || true) && false;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/double_negation.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field a = - - 1;
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/runtime_errors/div_zero_uint.zok:
--------------------------------------------------------------------------------
1 | def main(u8 x) {
2 | u8 y = 0x01 / x;
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/simple_mul.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b, field c) -> field {
2 | return a * b * c;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/tuples/nested_access.zok:
--------------------------------------------------------------------------------
1 | def main(((field,),) b) {
2 | field a = b.0.0;
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/multidim_update.arguments.json:
--------------------------------------------------------------------------------
1 | [
2 | [
3 | ["0", "0"],
4 | ["0", "0"]
5 | ]
6 | ]
7 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_mul.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b, field c) -> field {
2 | return a * b * c;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/a.zok:
--------------------------------------------------------------------------------
1 | from "./b" import B;
2 |
3 | def main() {
4 | return;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/call.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128", "Bls12_381"],
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/embed.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128", "Bls12_381"],
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/panics/internal_panic.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> field {
2 | return x == 0 ? 0 : 1/x;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_ge.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | assert(x >= 2);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_gt.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | assert(x > 2);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_le.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | assert(x <= 2);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_lt.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | assert(x < 2);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_lt_u8.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | assert(x < 2);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/ch.zok:
--------------------------------------------------------------------------------
1 | def main(u32 e, u32 f, u32 g) -> u32 {
2 | return (e & f) ^ (!e & g);
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/eq.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/eq.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_js/.dockerignore:
--------------------------------------------------------------------------------
1 | pkg/
2 | node_modules/
3 | target/
4 | npm-debug.log
5 | .git
6 | .gitignore
7 | .vscode
8 | .idea
--------------------------------------------------------------------------------
/zokrates_js/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | target
4 | pkg
5 | wasm-pack.log
6 | stdlib
7 | stdlib.js
8 | metadata.js
--------------------------------------------------------------------------------
/zokrates_parser/README.md:
--------------------------------------------------------------------------------
1 | # zokrates_parser
2 |
3 | Formal grammar specification of the ZoKrates DSL in PEG (Pest).
4 |
--------------------------------------------------------------------------------
/zokrates_book/book.toml:
--------------------------------------------------------------------------------
1 | [book]
2 | authors = ["schaeff"]
3 | multilingual = false
4 | src = "src"
5 | title = "ZoKrates"
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/array_argument.zok:
--------------------------------------------------------------------------------
1 | def main(field[3] a) -> field {
2 | return a[0] + a[1] + a[2];
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/lookup.zok:
--------------------------------------------------------------------------------
1 | def main(u32 index, field[5] array) -> field {
2 | return array[index];
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/loop_too_large.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | for u32 i in 0..-1 {}
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/variable_shift.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> u32 {
2 | return a >> b;
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/reduceable_exponent.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | u32 a = 2;
3 | return 2**(a * 2 + 2);
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/runtime_errors/div_zero_field.zok:
--------------------------------------------------------------------------------
1 | def main(field x) {
2 | field y = 1 / x;
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/multidim_update.zok:
--------------------------------------------------------------------------------
1 | def main(field[2][2] mut a) -> field[2][2] {
2 | a[1][1] = 42;
3 | return a;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/field.zok:
--------------------------------------------------------------------------------
1 | const field ONE = 1;
2 |
3 | def main() -> field {
4 | return ONE;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/b.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE_BYTES = 136;
2 | const u32 SIZE_WORDS = SIZE_BYTES / 8;
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/no_return.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/no_return.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u8/sub.zok:
--------------------------------------------------------------------------------
1 | def main(u8 a, u8 b) -> (u8, u8, u8) {
2 | return (a - b, a - 1, 1 - a);
3 | }
--------------------------------------------------------------------------------
/zokrates_parser/src/textmate/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | .gitignore
4 | vsc-extension-quickstart.md
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/init_with_value.zok:
--------------------------------------------------------------------------------
1 | def main(field value) -> field[3] {
2 | return [value, value, value];
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/factorize.zok:
--------------------------------------------------------------------------------
1 | def main(private field a, field b) {
2 | assert(a * a == b);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/no_weak_eq.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | assert([[1]] == [1, 2]);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/mutability/assign_to_non_mutable.zok:
--------------------------------------------------------------------------------
1 | def main():
2 | field a = 2
3 | a = 3
4 | return
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/arrays/select.zok:
--------------------------------------------------------------------------------
1 | def main(field[3] array, u32 index) -> field {
2 | return array[index];
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/assert_array_equality.zok:
--------------------------------------------------------------------------------
1 | def main(field[2] a) {
2 | assert(a == [1, 2]);
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.zok:
--------------------------------------------------------------------------------
1 | from "./a" import B;
2 |
3 | def main() {
4 | return;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/uint.zok:
--------------------------------------------------------------------------------
1 | const u32 ONE = 0x00000001;
2 |
3 | def main() -> u32 {
4 | return ONE;
5 | }
--------------------------------------------------------------------------------
/zokrates_js/.cargo/config:
--------------------------------------------------------------------------------
1 | [target.wasm32-unknown-unknown]
2 | rustflags = [
3 | "-C", "link-args=-z stack-size=8388608",
4 | ]
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/constant_array.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field[4] a = [1, 2, 42, 55];
3 | return a[2];
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/constant_definition.zok:
--------------------------------------------------------------------------------
1 | const field PRIME = 31;
2 |
3 | def main() -> field {
4 | return PRIME;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/mpc_tutorial/circuit.zok:
--------------------------------------------------------------------------------
1 | def main(private field a, private field b) -> field {
2 | return a * b;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/assertion_unequal_arrays.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | assert([1f] == [2f]);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/unused_struct_generic.zok:
--------------------------------------------------------------------------------
1 | struct A {}
2 |
3 | def main() {
4 | return;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/keyword_as_identifier.zok:
--------------------------------------------------------------------------------
1 | def assert() {
2 | return;
3 | }
4 |
5 | def main():
6 | return
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/out_of_for_scope.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | for u32 i in 0..5 {}
3 | return i;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions_equivalent.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) -> field {
2 | field c = a + b;
3 | return c;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/bool.zok:
--------------------------------------------------------------------------------
1 | const bool BOOLEAN = true;
2 |
3 | def main() -> bool {
4 | return BOOLEAN;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/reversed/a.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE_BYTES = 136;
2 | const u32 SIZE_WORDS = SIZE_BYTES / 8;
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/single_return.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/single_return.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/empty.zok:
--------------------------------------------------------------------------------
1 | def main(() a) -> () {
2 | () b = ();
3 | assert(a == b);
4 | return a;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u16/sub.zok:
--------------------------------------------------------------------------------
1 | def main(u16 a, u16 b) -> (u16, u16, u16) {
2 | return (a - b, a - 1, 1 - a);
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u32/sub.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 b) -> (u32, u32, u32) {
2 | return (a - b, a - 1, 1 - a);
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/u64/sub.zok:
--------------------------------------------------------------------------------
1 | def main(u64 a, u64 b) -> (u64, u64, u64) {
2 | return (a - b, a - 1, 1 - a);
3 | }
--------------------------------------------------------------------------------
/zokrates_js/tests/powersOfTau5_0000.ptau:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sCrypt-Inc/zokrates/HEAD/zokrates_js/tests/powersOfTau5_0000.ptau
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/conditional_ternary.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> field {
2 | field y = x + 2 == 3 ? 1 : 5;
3 | return y;
4 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/constant_type_error.zok:
--------------------------------------------------------------------------------
1 | const u32[2] A = [1];
2 |
3 | def main() -> u32[2] {
4 | return A;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/unassigned.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a;
3 | field b = a + 1;
4 | return b;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/import/import.zok:
--------------------------------------------------------------------------------
1 | from "./dep/foo" import foo;
2 |
3 | def main() -> field {
4 | return foo();
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> bool[5] {
2 | return [x < 0, x < 1, x < 255, x < 0 - 1, x - 2 > 0 - 2];
3 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/field.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import FIELD_SIZE_IN_BITS;
2 |
3 | const field FIELD_MIN = 0;
4 | const field FIELD_MAX = -1;
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/conditional.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> field {
2 | field y = if x + 2 == 3 { 1 } else { 5 };
3 | return y;
4 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/bool_not.zok:
--------------------------------------------------------------------------------
1 | def main(field a) -> field {
2 | field x = !(!(a < 5) && !(a > 1) || a < 4) ? 3 : 4;
3 | return x;
4 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/concrete_length_mismatch.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | assert([1] == [1, 2]);
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/constant_index_on_spread_inline.zok:
--------------------------------------------------------------------------------
1 | def main(field[3] a) -> field {
2 | return [...a][0] + [a[0]][0] + [a[0]; 1][0];
3 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/baz.zok:
--------------------------------------------------------------------------------
1 | struct Baz {}
2 |
3 | const field BAZ = 123;
4 |
5 | def main() -> field {
6 | return BAZ;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/simple_add.zok:
--------------------------------------------------------------------------------
1 | // only using add, no need to flatten
2 | def main(field a, field b) -> field {
3 | return a + b;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/import/origin.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 1 + 1;
2 |
3 | def foo(field[N] a) -> bool {
4 | return true;
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/maj.zok:
--------------------------------------------------------------------------------
1 | def main(u32 a, u32 c) -> u32 {
2 | u32 b = 0x12345678;
3 | return (a & b) ^ (a & c) ^ (b & c);
4 | }
--------------------------------------------------------------------------------
/zokrates_book/src/toolbox/index.md:
--------------------------------------------------------------------------------
1 | # ZoKrates Reference
2 |
3 | The reference covers the details of the ZoKrates toolbox beyond the ZoKrates language.
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/if_eq.zok:
--------------------------------------------------------------------------------
1 | def main(field[2] a, field[2] b, field condition) -> field[2] {
2 | return condition == 1 ? a : b;
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/double_power.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field a = 1**2**3; // parentheses are required here
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/log_integer_type.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | log("{}", 1 + 1); // 1 is of internal type {integer}
3 | return;
4 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/no_struct_equivalence.zok:
--------------------------------------------------------------------------------
1 | struct Foo {}
2 | struct Bar {}
3 |
4 | def main() -> Foo {
5 | return Bar {};
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/return_array.expected.witness:
--------------------------------------------------------------------------------
1 | ~out_0 2
2 | ~out_1 1
3 | ~out_2 1
4 | ~out_3 1
5 | ~out_4 3
6 | ~out_5 3
7 | ~out_6 3
8 | ~out_7 3
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/simple_add.zok:
--------------------------------------------------------------------------------
1 | // only using add, no need to flatten
2 | def main(field a, field b) -> field {
3 | return a + b;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/a.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/issue_1038/a.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/a.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/issue_1047/a.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/import/dep/foo.zok:
--------------------------------------------------------------------------------
1 | from "./dep/foo" import foo as bar;
2 |
3 | def foo() -> field {
4 | return 2 + bar();
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/no_return.zok:
--------------------------------------------------------------------------------
1 | def foo() {
2 | return;
3 | }
4 |
5 | def bar() {
6 | return foo();
7 | }
8 |
9 | def main() {}
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/constant.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | (u32[16],) mut s = ([0; 16],);
3 | s.0[0] = 0x00000001;
4 | return;
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u8_to_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u8_to_bits;
2 |
3 | def main(u8 a) -> bool[8] {
4 | return u8_to_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/return_variable_array.zok:
--------------------------------------------------------------------------------
1 | def main(field[2] a, field[2] b) -> field[2] {
2 | return [a[0] + b[0], a[1] + b[1]];
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/brackets.zok:
--------------------------------------------------------------------------------
1 | def main(field a) -> field {
2 | field b = (a + 5) * 6;
3 | field c = 7 * (b + a);
4 | return b + c;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/reserved_log.zok:
--------------------------------------------------------------------------------
1 | // "log" is reserved
2 | def log() {
3 | return;
4 | }
5 |
6 | def main() {
7 | return;
8 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/structs/identity.zok:
--------------------------------------------------------------------------------
1 | struct A {
2 | field a;
3 | bool b;
4 | }
5 |
6 | def main(A a) -> A {
7 | return a;
8 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/eq.zok:
--------------------------------------------------------------------------------
1 | def main(private u32 a, u32 b) -> field {
2 | field result = a * a == b ? 1 : 0;
3 | return result;
4 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u16_to_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u16_to_bits;
2 |
3 | def main(u16 a) -> bool[16] {
4 | return u16_to_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_to_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u32_to_bits;
2 |
3 | def main(u32 a) -> bool[32] {
4 | return u32_to_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u64_to_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u64_to_bits;
2 |
3 | def main(u64 a) -> bool[64] {
4 | return u64_to_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/repeat.zok:
--------------------------------------------------------------------------------
1 | def main(field a) -> field[4] {
2 | u32 SIZE = 4;
3 | field[SIZE] res = [a; SIZE];
4 | return res;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/mpc_tutorial/phase1radix2m2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sCrypt-Inc/zokrates/HEAD/zokrates_cli/examples/book/mpc_tutorial/phase1radix2m2
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/tuples.zok:
--------------------------------------------------------------------------------
1 | def main() -> bool {
2 | (field[2], bool) mut v = ([1, 2], true);
3 | v.0 = [42, 43];
4 | return v.1;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/constant_array_size_type_mismatch_field.zok:
--------------------------------------------------------------------------------
1 | const field SIZE = 2;
2 |
3 | def main(field[SIZE] n) {
4 | return;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/constant_array_size_type_mismatch_u8.zok:
--------------------------------------------------------------------------------
1 | const u8 SIZE = 0x02;
2 |
3 | def main(field[SIZE] n) {
4 | return;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/numerical_struct_generic.zok:
--------------------------------------------------------------------------------
1 | struct A<1> {
2 | field[1] a;
3 | }
4 |
5 | def main() {
6 | return;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/undeclared_struct_generic.zok:
--------------------------------------------------------------------------------
1 | struct A {
2 | field[N] a;
3 | }
4 |
5 | def main() {
6 | return;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/tuples/constant_in_member.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE = 42;
2 |
3 | def main() {
4 | (field[SIZE],) f = ([42; SIZE],);
5 | return;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | scrypts/
4 | scrypt.index.json
5 | tests/out
6 | **/scrypt.index.json
7 | .eslintcache
8 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | tests
3 | .gitignore
4 | node_modules
5 | scrypts/**/*
6 | !scrypts/**/*.scrypt
7 | !scrypt.index.json
8 |
--------------------------------------------------------------------------------
/zokrates_core_test/build.rs:
--------------------------------------------------------------------------------
1 | use zokrates_test_derive::write_tests;
2 |
3 | fn main() {
4 | // generate tests
5 | write_tests("./tests/tests/");
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/array_conditional.zok:
--------------------------------------------------------------------------------
1 | def main(field[2] a, field[2] b, field condition) -> field[2] {
2 | return condition == 1 ? a : b;
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/array.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 2;
2 | const field[N] ARRAY = [1, 2];
3 |
4 | def main() -> field[N] {
5 | return ARRAY;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/single_return.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 42;
3 | }
4 |
5 | def main() {
6 | field a = foo();
7 | return;
8 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/ternary.zok:
--------------------------------------------------------------------------------
1 | def main(bool a, bool b) -> field {
2 | field x = a ? 1 : b ? 2 : 3; // (a ? 1 : (b ? 2 : 3))
3 | return x;
4 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u8_from_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u8_from_bits;
2 |
3 | def main(bool[8] a) -> u8 {
4 | return u8_from_bits(a);
5 | }
--------------------------------------------------------------------------------
/examples/root.zok:
--------------------------------------------------------------------------------
1 | def main(private field p, private field q, field n) {
2 | assert(p * q == n);
3 | assert(p > 1);
4 | assert(q > 1);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/return_array.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field[2] {
2 | return [1, 2];
3 | }
4 |
5 | def main() -> field[2] {
6 | return foo();
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/constant_reference.zok:
--------------------------------------------------------------------------------
1 | const field ONE = 1;
2 | const field TWO = ONE + ONE;
3 |
4 | def main() -> field {
5 | return TWO;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/constant_assignment.zok:
--------------------------------------------------------------------------------
1 | const field a = 1;
2 |
3 | def main() -> field {
4 | a = 2; // not allowed
5 | return a;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/duplicate_struct_generic.zok:
--------------------------------------------------------------------------------
1 | struct A {
2 | field[N] a;
3 | }
4 |
5 | def main() {
6 | return;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/import/destination.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/import/destination.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/import/destination.zok:
--------------------------------------------------------------------------------
1 | from "./origin.zok" import foo;
2 |
3 | def main() {
4 | assert(foo([1, 1]));
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/embed.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import unpack;
2 |
3 | def main(field x) {
4 | bool[1] bits = unpack(x);
5 | return;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/memoize/dep.zok:
--------------------------------------------------------------------------------
1 | def dep(field a) -> field { // this costs 2 constraints per call
2 | field res = a ** 4;
3 | return res;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/extend.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/extend.zok",
3 | "max_constraint_count": 2280,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/temp1.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/temp1.zok",
3 | "max_constraint_count": 398,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/temp2.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/temp2.zok",
3 | "max_constraint_count": 364,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u16_from_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u16_from_bits;
2 |
3 | def main(bool[16] a) -> u16 {
4 | return u16_from_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_from_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u32_from_bits;
2 |
3 | def main(bool[32] a) -> u32 {
4 | return u32_from_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u64_from_bits.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u64_from_bits;
2 |
3 | def main(bool[64] a) -> u64 {
4 | return u64_from_bits(a);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/too_many_arguments.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 1;
3 | }
4 |
5 | def main() -> field {
6 | return foo(42);
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/too_many_generics.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 1;
3 | }
4 |
5 | def main() -> field {
6 | return foo::<42>();
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/import_multiple.zok:
--------------------------------------------------------------------------------
1 | from "./bar" import Bar, main as f;
2 |
3 | def main() -> field {
4 | Bar bar = Bar {};
5 | return f();
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/return_array.zok:
--------------------------------------------------------------------------------
1 | def main(private field[3] a, private field b, private field[4] c) -> (field, field[3], field[4]) {
2 | return (b, a, c);
3 | }
4 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/issue_1038/reversed/b.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1047/reversed/b.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/issue_1047/reversed/b.zok",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/spread_slice.zok:
--------------------------------------------------------------------------------
1 | def main(field[3] a, field[3] b, field c) -> field[9] {
2 | return [...a[..2], ...b[1..], ...a[..], ...b[1..2], c];
3 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/conditional.zok:
--------------------------------------------------------------------------------
1 | def main(bool flag) -> (field, field) {
2 | (field, field) a = flag ? (1f, 2f) : (2f, 1f);
3 | return a;
4 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/add_loop.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/add_loop.zok",
3 | "max_constraint_count": 76,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_parser/src/textmate/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.0.2] - 2021-03-01
2 |
3 | - Add new syntax for ZoKrates 0.7.1
4 |
5 | ## [0.0.1] - 2021-03-01
6 |
7 | - Initial release
--------------------------------------------------------------------------------
/integration_test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit if any subcommand fails
4 | set -e
5 |
6 | cargo test -j 4 --release --package zokrates_cli -- --ignored
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/bar.zok:
--------------------------------------------------------------------------------
1 | struct Bar {}
2 |
3 | const field ONE = 1;
4 | const field BAR = 21 * ONE;
5 |
6 | def main() -> field {
7 | return BAR;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/cached_condition.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/cached_condition.zok",
3 | "max_constraint_count": 2015,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/array_size.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE = 2;
2 |
3 | def main(field[SIZE] a) -> field[SIZE] {
4 | field[SIZE] b = a;
5 | return b;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/conditional.zok:
--------------------------------------------------------------------------------
1 | def main(bool condition, u8 consequence, u8 alternative) -> u8 {
2 | return condition ? consequence : alternative;
3 | }
--------------------------------------------------------------------------------
/zokrates_field/src/bw6_761.rs:
--------------------------------------------------------------------------------
1 | use ark_bw6_761::BW6_761;
2 |
3 | use crate::G2Type;
4 |
5 | prime_field!("bw6_761", BW6_761, G2Type::Fq);
6 |
7 | ark_extensions!(BW6_761);
8 |
--------------------------------------------------------------------------------
/scripts/install_wasm_testing.sh:
--------------------------------------------------------------------------------
1 | apt-get update && apt-get install curl firefox-esr -y --no-install-recommends
2 | curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
--------------------------------------------------------------------------------
/zokrates_cli/examples/argument_reassign.zok:
--------------------------------------------------------------------------------
1 | def sub(field mut a) -> field {
2 | a = a + 3;
3 | return a;
4 | }
5 |
6 | def main() -> field {
7 | return sub(4);
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/function_declaration.zok:
--------------------------------------------------------------------------------
1 | def foo(field a, field b) -> field {
2 | return a + b;
3 | }
4 |
5 | def main() -> field {
6 | return foo(1, 2);
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/call_in_constant.zok:
--------------------------------------------------------------------------------
1 | def yes() -> bool {
2 | return true;
3 | }
4 |
5 | const bool TRUE = yes();
6 |
7 | def main() {
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/arrays/fun_spread.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/arrays/fun_spread.zok",
3 | "max_constraint_count": 1050,
4 | "tests": []
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/propagate.zok:
--------------------------------------------------------------------------------
1 | const u32 TWO = 2;
2 | const u32 FOUR = TWO * TWO;
3 |
4 | def main() -> field[FOUR] {
5 | return [42; FOUR];
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/tuple.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 2;
2 | const (field[N], bool) A = ([1; N], true);
3 |
4 | def main() -> (field[N], bool) {
5 | return A;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/large_equality.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE = 100;
2 |
3 | def main(private field[SIZE][SIZE] a) {
4 | assert(a == [[0; SIZE]; SIZE]);
5 | return;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/comments.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a = 42; // this is an end of line comment
3 | // this is a full line comment
4 | return a;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/div_by_zero.zok:
--------------------------------------------------------------------------------
1 | def main(field input) -> field {
2 | field divisor = [input, 0] != [input, 1] ? 0 : 1;
3 | return input / divisor;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/generic_inference.zok:
--------------------------------------------------------------------------------
1 | struct A {
2 | field[N] a;
3 | }
4 |
5 | def main() {
6 | A<_> a = A { a: [1] };
7 | return;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/import_functions.zok:
--------------------------------------------------------------------------------
1 | import "./foo";
2 | import "./bar";
3 | import "./baz";
4 |
5 | def main() -> bool {
6 | return foo() == bar() + baz();
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/shadowing.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 1;
3 | }
4 |
5 | def main() {
6 | field a = 2;
7 | field a = foo();
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/a.zok:
--------------------------------------------------------------------------------
1 | from "./b" import SIZE_WORDS;
2 |
3 | def main(field[SIZE_WORDS] a) {
4 | assert(a == [0; SIZE_WORDS]);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_MAX;
2 |
3 | def main(field x) {
4 | assert(x > FIELD_MAX - 1);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_MAX;
2 |
3 | def main(field x) {
4 | assert(x < FIELD_MAX - 1);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/logging.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | field[3] a;
3 | bool b;
4 | }
5 |
6 | def main(Foo x, field y) {
7 | log("x is {}, y is {}", x, y);
8 | return;
9 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/struct_generic_mismatch.zok:
--------------------------------------------------------------------------------
1 | struct A {
2 | field[N] a;
3 | }
4 |
5 | def main(A<1> a, A<2> b) -> bool {
6 | return a == b;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/decimal_literal.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a = 1f;
3 | field b = 1_f; // allow underscore between the literal and the suffix
4 | return a + b;
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/left_side_call.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | return 1;
3 | }
4 |
5 | def main() {
6 | assert(foo() + (1 + 44*3) == 134);
7 | return;
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/synonyms.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a = 1;
3 | field b = a;
4 | field c = b;
5 | field d = c;
6 | field e = d;
7 | return e;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_field/src/bls12_377.rs:
--------------------------------------------------------------------------------
1 | use ark_bls12_377::Bls12_377;
2 |
3 | use crate::G2Type;
4 |
5 | prime_field!("bls12_377", Bls12_377, G2Type::Fq2);
6 |
7 | ark_extensions!(Bls12_377);
8 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/blake2/blake2s.zok:
--------------------------------------------------------------------------------
1 | import "hashes/blake2/blake2s_p" as blake2s_p;
2 |
3 | def main(u32[K][16] input) -> u32[8] {
4 | return blake2s_p(input, [0; 2]);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha3/224bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[28] {
4 | return keccak::<_, 28>(input, 0x06);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha3/256bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[32] {
4 | return keccak::<_, 32>(input, 0x06);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha3/384bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[48] {
4 | return keccak::<_, 48>(input, 0x06);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha3/512bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[64] {
4 | return keccak::<_, 64>(input, 0x06);
5 | }
--------------------------------------------------------------------------------
/zokrates_test_derive/test_template:
--------------------------------------------------------------------------------
1 | #[test]
2 | #[allow(non_snake_case)]
3 | fn {test_name}() {{
4 | use zokrates_test::test_inner;
5 |
6 | test_inner("{test_path}")
7 | }}
8 |
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/multi_init.zok:
--------------------------------------------------------------------------------
1 | def identity(field[N][N] t) -> field[N][N] {
2 | return t;
3 | }
4 |
5 | def main() -> field[1][1] {
6 | return identity([[0]; 1]);
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/multiline_comments.zok:
--------------------------------------------------------------------------------
1 | /*
2 | This is a multi-line comment
3 | written in more than just one line.
4 | */
5 | def main() -> field {
6 | return 42;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/mutable.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field a = 42;
3 | // a = 43; <- not allowed, as `a` is immutable
4 | field mut b = 42;
5 | b = 43; // ok
6 | return;
7 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/explicit_generic.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field[N] {
2 | return [42; N];
3 | }
4 |
5 | def main() -> field[2] {
6 | field a = foo::<3>()[0];
7 | return foo::<2>();
8 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/issue_1038/reversed/b.zok:
--------------------------------------------------------------------------------
1 | from "./a" import SIZE_WORDS;
2 |
3 | def main(field[SIZE_WORDS] a) {
4 | assert(a == [0; SIZE_WORDS]);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/right_rotation.zok:
--------------------------------------------------------------------------------
1 | def rotr32(u32 x) -> u32 {
2 | return (x >> N) | (x << (32 - N));
3 | }
4 |
5 | def main(u32 i) -> u32 {
6 | return rotr32::<2>(i);
7 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/keccak/224bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[28] {
4 | return keccak::<_, 28>(input, 0x01);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/keccak/256bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[32] {
4 | return keccak::<_, 32>(input, 0x01);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/keccak/384bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[48] {
4 | return keccak::<_, 48>(input, 0x01);
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/keccak/512bit.zok:
--------------------------------------------------------------------------------
1 | from "hashes/keccak/keccak" import main as keccak;
2 |
3 | def main(u8[N] input) -> u8[64] {
4 | return keccak::<_, 64>(input, 0x01);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/array_loop.zok:
--------------------------------------------------------------------------------
1 | def main() -> u32 {
2 | u32[3] a = [1, 2, 3];
3 | u32 mut c = 0;
4 | for u32 i in 0..3 {
5 | c = c + a[i];
6 | }
7 | return c;
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/assign_to_element.zok:
--------------------------------------------------------------------------------
1 | def foo() -> u32 {
2 | return 0;
3 | }
4 |
5 | def main(u32[1] mut a, (u32,) mut b) {
6 | a[0] = foo();
7 | b.0 = foo();
8 | return;
9 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/for_scope.zok:
--------------------------------------------------------------------------------
1 | def main() -> u32 {
2 | u32 mut a = 0;
3 | for u32 i in 0..5 {
4 | a = a + i;
5 | }
6 | // return i; <- not allowed
7 | return a;
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/unpack_value_too_large.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import unpack;
2 |
3 | def main() {
4 | bool[2] bits = unpack(4); // we need 3 bits to unpack 4
5 | return;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/factorization.zok:
--------------------------------------------------------------------------------
1 | // a and b are factorization of c
2 | def main(field c, private field a, private field b) {
3 | field d = a * b;
4 | assert(c == d);
5 | return;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/multiple_witnesses.zok:
--------------------------------------------------------------------------------
1 | // this code does not need to be flattened
2 | def main(field x, field a, field b) -> field {
3 | assert(a == b * 7);
4 | return x + a + b;
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/cache.zok:
--------------------------------------------------------------------------------
1 | def id() -> u32 {
2 | return N;
3 | }
4 |
5 | def main() {
6 | assert(id::<5>() == 5);
7 | assert(id::<6>() == 6);
8 | return;
9 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/left_rotation.zok:
--------------------------------------------------------------------------------
1 | def rotl32(u32 x) -> u32 {
2 | return ((x << N) | (x >> (32 - N)));
3 | }
4 |
5 | def main(u32 i) -> u32 {
6 | return rotl32::<2>(i);
7 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/struct_init.zok:
--------------------------------------------------------------------------------
1 | struct Point {
2 | field x;
3 | field y;
4 | }
5 |
6 | def main() -> Point {
7 | Point p = Point { x: 1, y: 0 };
8 | return p;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/incompatible.zok:
--------------------------------------------------------------------------------
1 | def foo(field[P] a, field[P] b) -> field {
2 | return 42;
3 | }
4 |
5 | def main() -> field {
6 | return foo([1, 2], [1]);
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/import_constants.zok:
--------------------------------------------------------------------------------
1 | from "./foo" import FOO;
2 | from "./bar" import BAR;
3 | from "./baz" import BAZ;
4 |
5 | def main() -> bool {
6 | return FOO == BAR + BAZ;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/field.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_MIN, FIELD_MAX, FIELD_SIZE_IN_BITS;
2 |
3 | def main() -> (field, field, u32) {
4 | return (FIELD_MIN, FIELD_MAX, FIELD_SIZE_IN_BITS);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/generic_function_declaration.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field[N] {
2 | return [42; N];
3 | }
4 |
5 | def main() -> field[2] {
6 | field[2] res = foo();
7 | return res;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/mutability/multi_assign_to_non_mutable.zok:
--------------------------------------------------------------------------------
1 | def foo() -> (field, field):
2 | return 1, 2
3 |
4 | def main():
5 | field a, field b = foo()
6 | a = 3
7 | return
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/out_of_bounds.zok:
--------------------------------------------------------------------------------
1 | def main(field a, field b) -> field {
2 | field[10] arr = [0; 10];
3 | u32 index = [a, 1] != [b, 0] ? 1000 : 0;
4 | return arr[index];
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/reassignment.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> field {
2 | field mut a = x + 5;
3 | field b = a + x;
4 | a = 7;
5 | field c = a + b;
6 | a = a + 5;
7 | return a + c;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/nested.zok:
--------------------------------------------------------------------------------
1 | const field A = 2;
2 | const field B = 2;
3 | const field[2] ARRAY = [A * 2, B * 2];
4 |
5 | def main() -> field {
6 | return ARRAY[0] + ARRAY[1];
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/multidef.zok:
--------------------------------------------------------------------------------
1 | def foo(field[T] b) -> field[T] {
2 | return b;
3 | }
4 |
5 | def main(field[3] a) -> field[3] {
6 | field[3] res = foo(a);
7 | return res;
8 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/u32/pack128.zok:
--------------------------------------------------------------------------------
1 | import "./pack" as pack;
2 |
3 | // pack 128 big-endian bits into one field element
4 | def main(u32[4] input) -> field {
5 | return pack(input);
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_1.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field i) -> field {
4 | field output = poseidon([i]);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field[2] i) -> field {
4 | field output = poseidon(i);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field[3] i) -> field {
4 | field output = poseidon(i);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field[4] i) -> field {
4 | field output = poseidon(i);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_5.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field[5] i) -> field {
4 | field output = poseidon(i);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_6.zok:
--------------------------------------------------------------------------------
1 | import "hashes/poseidon/poseidon" as poseidon;
2 |
3 | def main(field[6] i) -> field {
4 | field output = poseidon(i);
5 | return output;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/declaration.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | // declare and define `my_variable`
3 | field mut my_variable = 2;
4 | // redefine `my_variable`
5 | my_variable = 3;
6 | return;
7 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/constant_reduction_fail.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import bit_array_le;
2 |
3 | const bool CONST = bit_array_le([true], [true]);
4 |
5 | def main() -> bool {
6 | return CONST;
7 | }
8 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/declare_non_identifier.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field[2] a[2] = [1, 2]; // only variables can be declared in such a statement, declaring `a[2]` is invalid
3 | return;
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/conflicting_constant.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 42;
2 |
3 | def foo(field[N] a) -> bool {
4 | return true;
5 | }
6 |
7 | def main() {
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/shadowing.zok:
--------------------------------------------------------------------------------
1 | def add(field a,field b) -> field {
2 | return a + b;
3 | }
4 |
5 | def main(field a,field b) -> field {
6 | field mut c = add(a, b);
7 | return c;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/bool_128_to_u32_4.zok:
--------------------------------------------------------------------------------
1 | import "./bool_array_to_u32_array" as bool_to_u32;
2 |
3 | def main(bool[128] bits) -> u32[4] {
4 | u32[4] res = bool_to_u32(bits);
5 | return res;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/bool_256_to_u32_8.zok:
--------------------------------------------------------------------------------
1 | import "./bool_array_to_u32_array" as bool_to_u32;
2 |
3 | def main(bool[256] bits) -> u32[8] {
4 | u32[8] res = bool_to_u32(bits);
5 | return res;
6 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcFeistel.zok:
--------------------------------------------------------------------------------
1 | import "hashes/mimcSponge/mimcFeistel" as mimcFeistel;
2 |
3 | def main(field a, field b, field c) -> field[2] {
4 | return mimcFeistel(a, b, c);
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/for.zok:
--------------------------------------------------------------------------------
1 | def main() -> u32 {
2 | u32 mut res = 0;
3 | for u32 i in 0..4 {
4 | for u32 j in i..5 {
5 | res = res + i;
6 | }
7 | }
8 | return res;
9 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/rng_tutorial/get_hash.zok:
--------------------------------------------------------------------------------
1 | import "hashes/sha256/512bit" as sha256;
2 |
3 | def main(u32[16] hashMe) -> u32[8] {
4 | u32[8] h = sha256(hashMe[0..8], hashMe[8..16]);
5 | return h;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/constant_in_sig.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 1;
2 |
3 | def foo(bool[N] arr) -> bool {
4 | return true;
5 | }
6 |
7 | def main(bool[N] arr) {
8 | assert(foo(arr));
9 | return;
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/structs/nested_access.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | field a;
3 | }
4 |
5 | struct Bar {
6 | Foo foo;
7 | }
8 |
9 | def main(Bar b) {
10 | field a = b.foo.a;
11 | return;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_core/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![feature(box_patterns, box_syntax)]
2 |
3 | pub mod compile;
4 | mod flatten;
5 | pub mod imports;
6 | mod macros;
7 | mod optimizer;
8 | mod semantics;
9 | mod static_analysis;
10 |
--------------------------------------------------------------------------------
/zokrates_ast/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![feature(box_patterns, box_syntax)]
2 |
3 | pub mod common;
4 | pub mod flat;
5 | pub mod ir;
6 | pub mod typed;
7 | pub mod untyped;
8 | pub mod zir;
9 |
10 | pub use common::Solver;
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/multidim_update.zok:
--------------------------------------------------------------------------------
1 | def main(field[10][10][10] mut a, u32 i, u32 j, u32 k) -> field[3] {
2 | a[i][j][k] = 42;
3 | field[3][3] b = [[1, 2, 3], [1, 2, 3], [1, 2, 3]];
4 | return b[0];
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/field_overflow.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field pMinusOne = 21888242871839275222246405745257275088548364400416034343698204186575808495616;
3 | assert(0 - 1 == pMinusOne);
4 | return;
5 | }
6 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/functions.zok:
--------------------------------------------------------------------------------
1 | def add(field f,field g) -> field {
2 | return f + g;
3 | }
4 |
5 | def main(field a, field b) -> field {
6 | field c = add(a, b);
7 | return c;
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/inliner_state_aux.zok:
--------------------------------------------------------------------------------
1 | // the issue only shows if `K` is an array, renaming this constant to something else works
2 | const u32[1] K = [1];
3 |
4 | def main() -> u32 {
5 | return K[0];
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/structs/constant.zok:
--------------------------------------------------------------------------------
1 | struct State {
2 | u32[16] memory;
3 | }
4 |
5 | def main() {
6 | State mut s = State { memory: [0; 16] };
7 | s.memory[0] = 0x00000001;
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/add.zok:
--------------------------------------------------------------------------------
1 | // only using add, no need to flatten
2 | def main(field a) -> field {
3 | field b = a + 5;
4 | field c = a + b + a + 4;
5 | field d = a + c + a + b;
6 | return b + c + d;
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/array_loop_update.zok:
--------------------------------------------------------------------------------
1 | def main() -> u32[3] {
2 | u32[3] a = [1, 2, 3];
3 | u32[3] mut c = [4, 5, 6];
4 | for u32 i in 0..3 {
5 | c[i] = c[i] + a[i];
6 | }
7 | return c;
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/abi.zok:
--------------------------------------------------------------------------------
1 | struct Bar {
2 | field a;
3 | }
4 |
5 | struct Foo {
6 | u8 a;
7 | Bar b;
8 | }
9 |
10 | def main(Foo foo, bool[2] bar, field num) -> field {
11 | return 42;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/out_of_bounds_write.zok:
--------------------------------------------------------------------------------
1 | def foo(field[1] a) -> field[1] {
2 | return a;
3 | }
4 |
5 | def main(field a) {
6 | field[1] h = foo([a]);
7 | h[1] = 1;
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/flatten.zok:
--------------------------------------------------------------------------------
1 | // this code needs flattening
2 | def main(field a) -> field {
3 | field b = a + 5 + a * a;
4 | field c = b + a + a * b * b;
5 | field d = a * b + c * c;
6 | return b + c + d;
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/zokrates_js/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM zokrates/env:latest
2 |
3 | COPY . src
4 | RUN cd src/zokrates_js && npm run build && rm -rf target/
5 |
6 | RUN cd / && mkdir build \
7 | && cp -rf src/zokrates_js/* /build/ \
8 | && rm -rf src
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_4_to_bool_128.zok:
--------------------------------------------------------------------------------
1 | import "./u32_array_to_bool_array" as to_bool_array;
2 |
3 | def main(u32[4] input) -> bool[128] {
4 | bool[128] res = to_bool_array(input);
5 | return res;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_8_to_bool_256.zok:
--------------------------------------------------------------------------------
1 | import "./u32_array_to_bool_array" as to_bool_array;
2 |
3 | def main(u32[8] input) -> bool[256] {
4 | bool[256] res = to_bool_array(input);
5 | return res;
6 | }
7 |
--------------------------------------------------------------------------------
/scripts/install_solcjs_deb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | apt-get update -y
4 | apt-get install -y curl gnupg sudo build-essential git
5 | curl -sL https://deb.nodesource.com/setup_16.x | bash -
6 | apt-get install -y nodejs
7 | npm i -g solc
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/conditional_panic.zok:
--------------------------------------------------------------------------------
1 | def main(field x) -> field {
2 | return if x == 0 {
3 | 0
4 | } else {
5 | 1 / x // executed even for x := 0, which leads to the execution failing
6 | };
7 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/function_scope.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field {
2 | // return myGlobal; <- not allowed
3 | return 42;
4 | }
5 |
6 | def main() -> field {
7 | field myGlobal = 42;
8 | return foo();
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/call_in_const_aux.zok:
--------------------------------------------------------------------------------
1 | const field F = 10;
2 | const u32 A = 10;
3 | const u32 B = A;
4 |
5 | def foo(field X) -> field[N] {
6 | return [X; N];
7 | }
8 |
9 | def main() {
10 | return;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/embed_type_mismatch.zok:
--------------------------------------------------------------------------------
1 | import "EMBED/u8_to_bits" as u8_to_bits;
2 |
3 | def main(u8 x) {
4 | bool[32] b = u8_to_bits(x); // note the incorrect array length on the left
5 | return;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/out_of_bounds_read.zok:
--------------------------------------------------------------------------------
1 | def foo(field[1] a) -> field[1] {
2 | return a;
3 | }
4 |
5 | def main(field a) {
6 | field[1] h = foo([a]);
7 | field f = h[1];
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/pack128.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | import "./pack" as pack;
4 |
5 | // pack 128 big-endian bits into one field element
6 | def main(bool[128] bits) -> field {
7 | return pack(bits);
8 | }
--------------------------------------------------------------------------------
/zokrates_test_derive/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_test_derive"
3 | version = "0.0.1"
4 | authors = ["schaeff "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | glob = "0.3.0"
9 |
10 | [lib]
11 |
--------------------------------------------------------------------------------
/changelogs/unreleased/34-zhfnjust:
--------------------------------------------------------------------------------
1 | ## [1.8.2] - 2022-09-17
2 |
3 | ### Release
4 | - https://github.com/Zokrates/ZoKrates/releases/tag/1.8.2
5 |
6 | ### Changes
7 | - support bellman in zokrates_js
--------------------------------------------------------------------------------
/zokrates_cli/examples/array_overload.zok:
--------------------------------------------------------------------------------
1 | def foo(field[2] a) -> bool {
2 | return true;
3 | }
4 |
5 | def foo(field[1] a) -> bool {
6 | return true;
7 | }
8 |
9 | def main() -> bool {
10 | return foo([1]);
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/ifelse_statements.zok:
--------------------------------------------------------------------------------
1 | def main(bool flag) -> field {
2 | field a = 1;
3 | return if flag {
4 | field b = a; // not supported
5 | b
6 | } else {
7 | false
8 | };
9 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/propagate_call.zok:
--------------------------------------------------------------------------------
1 | def foo(field a, field b) -> (field, field) {
2 | assert(a == b);
3 | return (a, b);
4 | }
5 |
6 | def main() -> field {
7 | (field, field) v = foo(1, 1);
8 | return v.0 + v.1;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/split.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import unpack;
2 | from "field" import FIELD_SIZE_IN_BITS;
3 |
4 | def main(field a) -> bool[FIELD_SIZE_IN_BITS] {
5 | bool[FIELD_SIZE_IN_BITS] b = unpack(a);
6 | return b;
7 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/multiplexer/lookup1bit.zok:
--------------------------------------------------------------------------------
1 | // One-bit window lookup table using one constraint
2 | def main(bool selector, field[2] target) -> field {
3 | field out = selector ? target[1] : target[0];
4 | return out;
5 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/assign_size_mismatch.zok:
--------------------------------------------------------------------------------
1 | def foo(field[N] a) -> bool {
2 | field[3] b = a;
3 | return true;
4 | }
5 |
6 | def main(field[1] a) {
7 | assert(foo(a));
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/structs/constant_in_member.zok:
--------------------------------------------------------------------------------
1 | const u32 SIZE = 42;
2 |
3 | struct Foo {
4 | field[SIZE] foo;
5 | }
6 |
7 | def main() {
8 | Foo f = Foo {
9 | foo: [42; SIZE]
10 | };
11 | return;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_book/src/examples/index.md:
--------------------------------------------------------------------------------
1 | # ZoKrates Examples
2 |
3 | This section covers examples of using the ZoKrates programming language.
4 |
5 | - [A SNARK Powered RNG](./rng_tutorial.md)
6 | - [Proving knowledge of a hash preimage](./sha256example.md)
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/cached_condition.zok:
--------------------------------------------------------------------------------
1 | // `a < b` should be flattened a single time, even if 1000 elements are assigned conditionally
2 |
3 | def main(field a, field b) -> field[1000] {
4 | return a < b ? [0f; 1000] : [1; 1000];
5 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/return_inference.zok:
--------------------------------------------------------------------------------
1 | def bar() -> field[N] {
2 | return [42; N];
3 | }
4 |
5 | def foo() -> field[N] {
6 | return bar();
7 | }
8 |
9 | def main() -> field[2] {
10 | return foo();
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/struct_assign.zok:
--------------------------------------------------------------------------------
1 | struct Point {
2 | field x;
3 | field y;
4 | }
5 |
6 | def main(field a) -> Point {
7 | Point mut p = Point { x: 1, y: 0 };
8 | p.x = a;
9 | p.y = p.x;
10 | return p;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/assertion.zok:
--------------------------------------------------------------------------------
1 | def foo(field[N] inputs) -> bool {
2 | assert(N <= 5);
3 | return true;
4 | }
5 |
6 | def main() {
7 | bool b = foo([1, 2, 3, 4, 5, 6]);
8 | return;
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/sub.zok:
--------------------------------------------------------------------------------
1 | // only using sub, no need to flatten
2 | def main(field a) -> field {
3 | field b = a + 100;
4 | field c = b + a + b;
5 | field d = b - a - 3 - a;
6 | field e = d + 3 - a;
7 | return d + c + e;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_js/node/index.js:
--------------------------------------------------------------------------------
1 | const lib = require("../lib.js");
2 | const metadata = require("../metadata.js");
3 |
4 | const initialize = async () => {
5 | return lib(require("./pkg/index.js"));
6 | };
7 |
8 | module.exports = { initialize, metadata };
9 |
--------------------------------------------------------------------------------
/changelogs/unreleased/29-zhfnjust:
--------------------------------------------------------------------------------
1 | ## [0.8.0-scrypt] - 2022-07-31
2 |
3 | ### Release
4 | - https://github.com/Zokrates/ZoKrates/releases/tag/0.8.0-scrypt
5 |
6 | ### Changes
7 | - Add `export-verifier-scrypt` command
--------------------------------------------------------------------------------
/zokrates_book/src/examples/magic_square.md:
--------------------------------------------------------------------------------
1 | # A ZK Magic Square in the browser
2 |
3 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/bool_or.zok:
--------------------------------------------------------------------------------
1 | // example using if-then-else-fi with ||
2 | def main(field a, field b) -> field {
3 | field y = a + 2 == 4 || b * 2 == 2 ? 1 : 0;
4 | field z = y == 1 || y == 0 ? y : 1;
5 | assert(z == 1);
6 | return z;
7 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/conflicting_functions.zok:
--------------------------------------------------------------------------------
1 | def foo(field[N] a) -> bool {
2 | return true;
3 | }
4 |
5 | def foo(field[P] a) -> bool {
6 | return true;
7 | }
8 |
9 | def main() {
10 | return;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/import_structs.zok:
--------------------------------------------------------------------------------
1 | from "./bar" import Bar as MyBar;
2 | from "./bar" import Bar;
3 |
4 | def main() {
5 | MyBar my_bar = MyBar {};
6 | Bar bar = Bar {};
7 | assert(my_bar == bar);
8 | return;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/pack.zok:
--------------------------------------------------------------------------------
1 | def main(bool[N] bits) -> field {
2 | field mut out = 0;
3 | for u32 j in 0..N {
4 | u32 i = N - (j + 1);
5 | out = out + (bits[i] ? 2 ** j : 0);
6 | }
7 | return out;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/bool_and.zok:
--------------------------------------------------------------------------------
1 | // example using ternary with &&
2 |
3 | def main(field a, field b) -> field {
4 | field y = a + 2 == 3 && a * 2 == 2 ? 1 : 0;
5 | field z = y == 1 && 1 - y == 0 ? y : 1;
6 | assert(b == 1);
7 | return a;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/call.zok:
--------------------------------------------------------------------------------
1 | def foo(field[T] b) -> field {
2 | return 1;
3 | }
4 |
5 | def bar(field[T] b) -> field {
6 | return foo(b);
7 | }
8 |
9 | def main(field[3] a) -> field {
10 | return foo(a) + bar(a);
11 | }
--------------------------------------------------------------------------------
/zokrates_js/index.js:
--------------------------------------------------------------------------------
1 | import lib from "./lib.js";
2 | import metadata from "./metadata.js";
3 |
4 | const initialize = async () => {
5 | const pkg = await import("./pkg/index.js");
6 | return lib(pkg);
7 | };
8 |
9 | export { initialize, metadata };
10 |
--------------------------------------------------------------------------------
/zokrates_book/src/language/macros.md:
--------------------------------------------------------------------------------
1 | ## Macros
2 |
3 | ZoKrates currently exposes a single macro:
4 |
5 | ```
6 | #pragma curve $CURVE
7 | ```
8 |
9 | The effect of this macro is to abort compilation if this file is being compiled for a curve different from `$CURVE`.
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/return_generic_call_mismatch.zok:
--------------------------------------------------------------------------------
1 | def bar() -> field[3] {
2 | return [1, 2, 3];
3 | }
4 |
5 | def foo() -> field[N] {
6 | return bar();
7 | }
8 |
9 | def main() -> field[2] {
10 | return foo();
11 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/shadowing.zok:
--------------------------------------------------------------------------------
1 | def main() -> (field, field) {
2 | field mut a = 0;
3 | field mut b = 0;
4 | for u32 i in 0..2 {
5 | a = a + 1;
6 | field a = 42;
7 | b = b + a;
8 | }
9 | return (a, b);
10 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/side_effects.zok:
--------------------------------------------------------------------------------
1 | def incr(field mut a) -> field {
2 | a = a + 1;
3 | return a;
4 | }
5 |
6 | def main() {
7 | field x = 1;
8 | field res = incr(x);
9 | assert(x == 1); // x has not changed
10 | return;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/import_with_alias.zok:
--------------------------------------------------------------------------------
1 | from "./bar" import main as bar;
2 | from "./baz" import BAZ as baz;
3 | import "./foo" as f;
4 |
5 | def main() -> field {
6 | field foo = f();
7 | assert(foo == bar() + baz);
8 | return foo;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist/
3 | out/
4 | test/out/
5 | test/dist
6 | test/scrypts
7 | scrypts/
8 | optimizations/
9 | **/.env
10 | **/scrypt.index.json
11 | .vscode/*
12 | !.vscode/launch.json
13 | !.vscode/tasks.json
14 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/utils/256bitsDirectionHelper.zok:
--------------------------------------------------------------------------------
1 | // Concatenate two u32[8] arrays in an order defined by a boolean selector
2 | def main(bool selector, u32[8] lhs, u32[8] rhs) -> u32[16] {
3 | return selector ? [...rhs, ...lhs] : [...lhs, ...rhs];
4 | }
5 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/generics.zok:
--------------------------------------------------------------------------------
1 | def sum(field[N] a) -> field {
2 | field mut res = 0;
3 | for u32 i in 0..N {
4 | res = res + a[i];
5 | }
6 | return res;
7 | }
8 |
9 | def main(field[3] a) -> field {
10 | return sum(a);
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/sha256_tutorial/hashexample.zok:
--------------------------------------------------------------------------------
1 | import "hashes/sha256/512bitPacked" as sha256packed;
2 |
3 | def main(private field a, private field b, private field c, private field d) -> field[2] {
4 | field[2] h = sha256packed([a, b, c, d]);
5 | return h;
6 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/type_annotations.zok:
--------------------------------------------------------------------------------
1 | def foo() -> (field, field[3]) {
2 | return (1, [2, 3, 4]);
3 | }
4 |
5 | def foo() -> (field, field) {
6 | return (1, 2);
7 | }
8 |
9 | def main() {
10 | (field, field[3]) a = foo();
11 | return;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/wrong_member_type.zok:
--------------------------------------------------------------------------------
1 | struct B {
2 | field a;
3 | }
4 |
5 | struct A {
6 | B a;
7 | }
8 |
9 | def main() {
10 | A a = A {
11 | a: B {
12 | a: false
13 | }
14 | };
15 | return;
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.prettierignore:
--------------------------------------------------------------------------------
1 | **/node_modules/
2 | **/dist/
3 | **/out/
4 | **/test/out/
5 | **/test/dist
6 | **/test/scrypts
7 | **/scrypts/
8 | **/.env
9 | **/scrypt.index.json
10 | **/.vscode/*
11 | !**/.vscode/launch.json
12 | !**/.vscode/tasks.json
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/taxation.zok:
--------------------------------------------------------------------------------
1 | def wtax(field debt, field wealth) -> field {
2 | field x = wealth < debt ? 0 : (wealth - debt);
3 | return x;
4 | }
5 |
6 | def main(field debt, field wealth) -> field {
7 | field tax = wtax(debt, wealth);
8 | return tax;
9 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/arrays/fun_spread.zok:
--------------------------------------------------------------------------------
1 | import "utils/pack/bool/nonStrictUnpack256.zok" as unpack256;
2 |
3 | def main(field[2] inputs) -> bool[512] {
4 | bool[512] preimage512 = [...unpack256(inputs[0]), ...unpack256(inputs[1])];
5 | return preimage512;
6 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/add_loop.zok:
--------------------------------------------------------------------------------
1 | // 32 constraints for input constraining
2 | def main(u32 a) -> u32 {
3 | u32 mut res = 0x00000000;
4 | for u32 i in 0..10 {
5 | res = res + a;
6 | }
7 | return res; // 42 constraints (decomposing on 42 bits)
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/propagate.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a = 1 + 2 + 3;
3 | field b = 1 < a ? 3 : a + 3;
4 | field mut c = b + a == 2 ? 1 : b;
5 | for u32 e in 0..2 {
6 | field g = 4;
7 | c = c + g;
8 | }
9 | return c * a;
10 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/simple_conditional.zok:
--------------------------------------------------------------------------------
1 | // simple conditional example
2 | // x = 2 -> 2 + 1 + 2**3 = 11
3 | // x = 5 -> 5 + 5 + 5**3 = 135
4 | def main(field x) -> field {
5 | field y = x < 3 ? 1 : 5;
6 | field z = y < x ? x**3 : y**3;
7 | return x + y + z;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/update.zok:
--------------------------------------------------------------------------------
1 | def foo(field[3] mut a) -> field {
2 | a[1] = 2;
3 | return a[1];
4 | }
5 |
6 | def main() -> (field, field) {
7 | field[3] a = [0, 0, 0];
8 | field res = foo(a);
9 | assert(a[1] == 0);
10 | return (res, a[1]);
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/shadowing.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | field a = 2;
3 | field a = 3; // shadowing
4 | for u32 i in 0..5 {
5 | bool a = true; // shadowing
6 | }
7 | // `a` is the variable declared before the loop
8 | return a;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/variable_constant_lt.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import bit_array_le;
2 |
3 | // Calling the `bit_array_le` embed on a non-constant second argument should fail at compile-time
4 | def main(bool[1] a, bool[1] b) -> bool {
5 | return bit_array_le(a, b);
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/for.zok:
--------------------------------------------------------------------------------
1 | def bound(field x) -> u32 {
2 | return 41 + 1;
3 | }
4 |
5 | def main(field a) -> field {
6 | field mut x = 7;
7 | x = x + 1;
8 | for u32 i in 0..bound(x) + bound(x + 1) {
9 | x = x + a;
10 | }
11 | return x;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/ternary_precedence.zok:
--------------------------------------------------------------------------------
1 | def main(bool a) -> field {
2 | // ternary expression should be wrapped in parentheses 1 + (a ? 2 : 3)
3 | // otherwise the whole expression is parsed as (1 + a) ? 2 : 3
4 | field x = 1 + a ? 2 : 3;
5 | return x;
6 | }
7 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/foo.zok:
--------------------------------------------------------------------------------
1 | from "./baz" import Baz;
2 | from "./baz" import main as my_function;
3 | import "./baz";
4 |
5 | const field FOO = 144;
6 |
7 | def main() -> field {
8 | Baz b = Baz {};
9 | assert(baz() == my_function());
10 | return FOO;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/taxation.zok:
--------------------------------------------------------------------------------
1 | def wtax(field debt, field wealth) -> field {
2 | field x = wealth < debt ? 0 : (wealth - debt);
3 | return x;
4 | }
5 |
6 | def main(private field debt, private field wealth) -> field {
7 | field tax = wtax(debt, wealth);
8 | return tax;
9 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/memoize/no_array_memoization.zok:
--------------------------------------------------------------------------------
1 | def foo(field[1] a) -> field {
2 | return a[0];
3 | }
4 |
5 | def main() {
6 | field[1] mut a = [1];
7 | field b = foo(a);
8 | a[0] = 0;
9 | field c = foo(a);
10 | assert(c == 0);
11 | return;
12 | }
--------------------------------------------------------------------------------
/zokrates_parser/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_parser"
3 | version = "0.3.2"
4 | authors = ["JacobEberhardt "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | pest = "2.0"
9 | pest_derive = "2.0"
10 |
11 | [dev-dependencies]
12 | glob = "0.2"
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/generic_call.zok:
--------------------------------------------------------------------------------
1 | def foo() -> field[P] {
2 | return [42; P];
3 | }
4 |
5 | def main() -> field[2] {
6 | // `P` is inferred from the declaration of `res`, while `N` is provided explicitly
7 | field[2] res = foo::<3, _>();
8 | return res;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/type_aliases.zok:
--------------------------------------------------------------------------------
1 | type MyField = field;
2 |
3 | type Rectangle = bool[L][W];
4 |
5 | type Square = Rectangle;
6 |
7 | def main() {
8 | MyField f = 42;
9 | Rectangle<2, 2> r = [[true; 2]; 2];
10 | Square<2> s = r;
11 | return;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/ternary_eq.zok:
--------------------------------------------------------------------------------
1 | // example using ternary operator with ==
2 | // x = 1 -> 1 + 1 + 1 = 3
3 | // x = 2 -> 2 + 5 + 125 = 132
4 | def main(field x) -> field {
5 | field y = x + 2 == 3 ? 1 : 5;
6 | field z = y == x ? x**3 : y**3;
7 | return x + y + z;
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/struct.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 2;
2 |
3 | struct State {
4 | field[N] a;
5 | field[N][N] b;
6 | }
7 |
8 | const State STATE = State {
9 | a: [1, 2],
10 | b: [[3, 4], [5, 6]]
11 | };
12 |
13 | def main() -> State {
14 | return STATE;
15 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/multidim_array.zok:
--------------------------------------------------------------------------------
1 | def main() -> field {
2 | // Array of two elements of array of 3 elements
3 | field[2][3] a = [[1, 2, 3],[4, 5, 6]];
4 |
5 | field[3] b = a[0]; // should be [1, 2, 3]
6 |
7 | // allowed access [0..2][0..3]
8 | return a[1][2];
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/call_in_const.zok:
--------------------------------------------------------------------------------
1 | from "./call_in_const_aux.zok" import A, foo, F;
2 |
3 | def bar(field[A] x) -> field[A] {
4 | return x;
5 | }
6 |
7 | const field[A] Y = [...bar(foo::(F))[..A - 1], 1];
8 |
9 | def main(field[A] X) {
10 | assert(X == Y);
11 | return;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/comparison_operators.zok:
--------------------------------------------------------------------------------
1 | // comparison operator example
2 | def main(field mut x) -> field {
3 | field mut y = x >= 3 ? 1 : 5;
4 | field mut z = y <= x ? x**3 : y**3;
5 | y = x < 3 ? 2 : 6;
6 | z = y > z ? 1 : 2;
7 | x = x == x ? x : y;
8 | return x + y + z;
9 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/unpack128.zok:
--------------------------------------------------------------------------------
1 | import "./unpack" as unpack;
2 |
3 | // Unpack a field element as 128 big-endian bits
4 | // If the input is larger than `2**128 - 1`, the output is truncated.
5 | def main(field i) -> bool[128] {
6 | bool[128] res = unpack(i);
7 | return res;
8 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/u32/pack.zok:
--------------------------------------------------------------------------------
1 | import "../../casts/u32_array_to_bool_array" as to_bits;
2 | import "../bool/pack";
3 |
4 | // pack N big-endian bits into one field element
5 | def main(u32[N] input) -> field {
6 | bool[N * 32] bits = to_bits(input);
7 | return pack(bits);
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/update_with_call.zok:
--------------------------------------------------------------------------------
1 | def foo(field a) -> field {
2 | return 2;
3 | }
4 |
5 | def main(field a) -> (field, field) {
6 | field[2] mut result = [0, 0];
7 | field r = foo(a);
8 | result[1] = r;
9 | assert(result[1] == r);
10 | return (result[1], r);
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/value.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field[3] a = [1, 2, 3];
3 | bool[3] b = [true, true, false];
4 | field[3][2] c = [[1, 2], [3, 4], [5, 6]];
5 |
6 | field[3] aa = [...a];
7 | bool[3] bb = [...b];
8 | field[3][2] cc = [...c];
9 |
10 | return;
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/structs/generic.zok:
--------------------------------------------------------------------------------
1 | struct B {
2 | field[P] a;
3 | }
4 |
5 | struct A {
6 | field[N] a;
7 | B b;
8 | }
9 |
10 | def main(A<2> a) -> bool {
11 | u32 SIZE = 1 + 1;
12 | A b = A { a: [1, 2], b: B { a: [1, 2] } } ;
13 | return a == b;
14 | }
15 |
--------------------------------------------------------------------------------
/zokrates_common/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub mod constants;
2 | pub mod helpers;
3 |
4 | use std::path::PathBuf;
5 |
6 | pub trait Resolver {
7 | fn resolve(
8 | &self,
9 | current_location: PathBuf,
10 | import_location: PathBuf,
11 | ) -> Result<(String, PathBuf), E>;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/cache.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128", "Bls12_381"],
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_js/README.md:
--------------------------------------------------------------------------------
1 | # zokrates.js
2 |
3 | JavaScript bindings for [ZoKrates](https://github.com/Zokrates/ZoKrates) project.
4 |
5 | ```bash
6 | npm install zokrates-js
7 | ```
8 |
9 | Check the offical [ZoKrates documentation](https://zokrates.github.io/toolbox/zokrates_js.html) for more details.
10 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/unpack256.zok:
--------------------------------------------------------------------------------
1 | import "./unpack" as unpack;
2 |
3 | // Unpack a field element as 256 big-endian bits
4 | // If the input is larger than `2**256 - 1`, the output is truncated.
5 | def main(field i) -> bool[256] {
6 | bool[256] res = unpack::<256>(i);
7 | return res;
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/comments.zok:
--------------------------------------------------------------------------------
1 | // only using add, no need to flatten
2 | def main(field a) -> field { // a needs to be 1
3 | field b = a + 5; // inline comment
4 | field c = a + b + a + 4;
5 | assert(a == 1); // another inline comment
6 | field d = a + c + a + b;
7 | return b + c + d;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/mixed.zok:
--------------------------------------------------------------------------------
1 | const u32 N = 2;
2 | const bool B = true;
3 |
4 | struct Foo {
5 | field[N] a;
6 | bool b;
7 | }
8 |
9 | const Foo[N] F = [
10 | Foo { a: [1, 2], b: B },
11 | Foo { a: [3, 4], b: !B }
12 | ];
13 |
14 | def main() -> Foo[N] {
15 | return F;
16 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/return_inference.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128"],
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": ["42", "42"]
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/panics/loop_bound.zok:
--------------------------------------------------------------------------------
1 | def throwing_bound(u32 x) -> u32 {
2 | assert(x == N);
3 | return 1;
4 | }
5 |
6 | // Even if the bound is constant at compile time, it can throw at runtime
7 | def main(u32 x) {
8 | for u32 i in 0..throwing_bound::<1>(x) {}
9 | return;
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/field_to_u8.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_SIZE_IN_BITS;
2 | import "utils/pack/bool/unpack";
3 | import "utils/casts/u8_from_bits";
4 |
5 | def main(field input) -> u8 {
6 | bool[FIELD_SIZE_IN_BITS] bits = unpack(input);
7 | return u8_from_bits(bits[FIELD_SIZE_IN_BITS-8..]);
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/array_generic_inference.zok:
--------------------------------------------------------------------------------
1 | def myFct(u64[N] ignored) -> u64[N2] {
2 | assert(2*N == N2);
3 | return [0; N2];
4 | }
5 |
6 | const u32 N = 3;
7 | const u32 N2 = 2 * N;
8 |
9 | def main(u64[N] arg) -> bool {
10 | u64[N2] someVariable = myFct(arg);
11 | return true;
12 | }
13 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "plugins": ["@typescript-eslint"],
5 | "extends": [
6 | "eslint:recommended",
7 | "plugin:@typescript-eslint/eslint-recommended",
8 | "plugin:@typescript-eslint/recommended"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/import/import.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/import/import.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": "3"
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/shadowing.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/shadowing.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": ["2", "84"]
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/field_to_u16.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_SIZE_IN_BITS;
2 | import "utils/pack/bool/unpack";
3 | import "utils/casts/u16_from_bits";
4 |
5 | def main(field input) -> u16 {
6 | bool[FIELD_SIZE_IN_BITS] bits = unpack(input);
7 | return u16_from_bits(bits[FIELD_SIZE_IN_BITS-16..]);
8 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/field_to_u32.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_SIZE_IN_BITS;
2 | import "utils/pack/bool/unpack";
3 | import "utils/casts/u32_from_bits";
4 |
5 | def main(field input) -> u32 {
6 | bool[FIELD_SIZE_IN_BITS] bits = unpack(input);
7 | return u32_from_bits(bits[FIELD_SIZE_IN_BITS-32..]);
8 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/field_to_u64.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_SIZE_IN_BITS;
2 | import "utils/pack/bool/unpack";
3 | import "utils/casts/u64_from_bits";
4 |
5 | def main(field input) -> u64 {
6 | bool[FIELD_SIZE_IN_BITS] bits = unpack(input);
7 | return u64_from_bits(bits[FIELD_SIZE_IN_BITS-64..]);
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/const_complex_type_mismatch.zok:
--------------------------------------------------------------------------------
1 | const u32 ONE = 1;
2 | const u32 TWO = 2;
3 | const field[ONE] ONE_FIELD = [1; TWO]; // actually set the value to an array of 2 elements
4 |
5 | def main(field[TWO] TWO_FIELDS) {
6 | assert(TWO_FIELDS == ONE_FIELD); // use the value as is
7 | return;
8 | }
9 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/same_parameter_name.zok:
--------------------------------------------------------------------------------
1 | def foo(field[N] x) -> field[N] {
2 | return x;
3 | }
4 |
5 | def bar(field[N] x) -> field[N] {
6 | field[N] r = x;
7 | return r;
8 | }
9 |
10 | def main(field[3] x) -> field[2] {
11 | field[2] z = foo(x)[0..2];
12 | return bar(z);
13 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/element_order.zok:
--------------------------------------------------------------------------------
1 | // this tests the abi, checking that the fields of a (field, bool) instance get encoded in the right order
2 | // if the the encoder reverses `0` and `1`, the boolean check ends up being done on the field value, which would fail
3 | def main((field, bool) f) {
4 | return;
5 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/ecc/edwardsNegate.zok:
--------------------------------------------------------------------------------
1 | // Negate a point on an Edwards curve
2 | // Curve parameters are defined with the last argument
3 | // Twisted Edwards Curves, BBJLP-2008, section 2 pg 2
4 | def main(field[2] pt) -> field[2] {
5 | field u = pt[0];
6 | field v = pt[1];
7 |
8 | return [-u, v];
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/mimc7/mimc7.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/mimc7/mimc7.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha3/224bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha3/224bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha3/256bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha3/256bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha3/384bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha3/384bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha3/512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha3/512bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/boolean_array.zok:
--------------------------------------------------------------------------------
1 | def main(bool[3] mut a) -> field[3] {
2 | bool[3] c = [true, true || false, true];
3 | a[1] = true || a[2];
4 | a[2] = a[0];
5 | field[3] mut result = [0; 3];
6 | for u32 i in 0..3 {
7 | result[i] = a[i] ? 33 : 0;
8 | }
9 | return result;
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/no_flatten.zok:
--------------------------------------------------------------------------------
1 | // this code does not need to be flattened
2 | def main(field x, field y, field z) -> field {
3 | field a = x + 3 * y - z * 2 - x * 12;
4 | assert(3*y - z * 2 - x * 12 == a - x);
5 | assert((x + y) - ((z + 3*x) - y) == (x - y) + ((2*x - 4*y) + (4*y - 2*z)));
6 | return x;
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/spaces_tabs_comments.zok:
--------------------------------------------------------------------------------
1 | // comment
2 |
3 | // comment
4 |
5 | def main(field x) -> field {
6 | // comment
7 | field y = x**3;
8 | field b = x**5;
9 |
10 | field c = x / 2;
11 | field d = (2 * x + 3 * b) * (x - b);
12 | return y + x + y + c + d;
13 | // comment
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/tuples/add.zok:
--------------------------------------------------------------------------------
1 | def main((field, field) p, (field, field) q) -> (field, field) {
2 | field a = 42;
3 | field d = 21;
4 |
5 | field dpxpyqxqy = d * p.0 * p.1 * q.0 * q.1;
6 |
7 | return ((p.0 * q.1 + q.0 * p.1) / (1 + dpxpyqxqy), (q.0 * q.1 - a * p.0 * p.1) / (1 - dpxpyqxqy));
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/tuples/generic.zok:
--------------------------------------------------------------------------------
1 | struct B {
2 | field[P] a;
3 | }
4 |
5 | struct A {
6 | field[N] a;
7 | B b;
8 | }
9 |
10 | def main((field[2], (field[2],)) a) -> bool {
11 | u32 SIZE = 1 + 1;
12 | (field[SIZE], (field[SIZE],)) b = ([1, 2], ([1, 2],)) ;
13 | return a == b;
14 | }
15 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha256/512bit.zok:
--------------------------------------------------------------------------------
1 | import "./sha256" as sha256;
2 |
3 | // A function that takes 2 u32[8] arrays as inputs, concatenates them,
4 | // and returns their sha256 compression as a u32[8].
5 | // Note: no padding is applied
6 |
7 | def main(u32[8] a, u32[8] b) -> u32[8] {
8 | return sha256([[...a, ...b]]);
9 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/keccak/224bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/keccak/224bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/keccak/256bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/keccak/256bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/keccak/384bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/keccak/384bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/keccak/512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/keccak/512bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/keccak/keccak.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/keccak/keccak.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/cube.zok:
--------------------------------------------------------------------------------
1 | def main(field[2][2][2] cube) -> field {
2 | field mut res = 0;
3 |
4 | for u32 i in 0..2 {
5 | for u32 j in 0..2 {
6 | for u32 k in 0..2 {
7 | res = res + cube[i][j][k];
8 | }
9 | }
10 | }
11 |
12 | return res;
13 | }
14 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/multidef.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128", "Bls12_381"],
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [["1", "2", "3"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": ["1", "2", "3"]
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_p.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/blake2/blake2s_p.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_book/src/toolbox/cli.md:
--------------------------------------------------------------------------------
1 | # Command Line Tool
2 |
3 | ZoKrates provides a command line interface.
4 | You can see an overview of the available subcommands by running
5 |
6 | ```sh
7 | zokrates
8 | ```
9 |
10 | You can get help about a particular subcommand with `--help`, for example:
11 | ```sh
12 | zokrates compile --help
13 | ```
--------------------------------------------------------------------------------
/zokrates_cli/examples/arrays/wrap_select.zok:
--------------------------------------------------------------------------------
1 | def get(field[32] array, u32 index) -> field {
2 | return array[index];
3 | }
4 |
5 | def main() -> field {
6 | field[32] array = [0, 0, 0, 0, 0, 0, 7, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
7 | field r = get(array, 7);
8 | return r;
9 | }
10 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/no_args_multiple.zok:
--------------------------------------------------------------------------------
1 | def constant() -> field {
2 | return 123123;
3 | }
4 |
5 | def add(field mut a, field b) -> field {
6 | a = constant();
7 | return a + b;
8 | }
9 |
10 | def main(field a, field b) -> field {
11 | field c = add(a, b + constant());
12 | return constant();
13 | }
14 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/README.md:
--------------------------------------------------------------------------------
1 | Build:
2 |
3 | ```sh
4 | npm run build
5 | ```
6 |
7 | Run local tests:
8 |
9 | ```sh
10 | npm t
11 | ```
12 |
13 | Run test on the Bitcoin testnet:
14 |
15 | ```sh
16 | npm run testnet
17 | ```
18 |
19 | Deploy an instance on the Bitcoin testnet:
20 |
21 | ```
22 | npm run deploy
23 | ```
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/generics/same_parameter_name.json:
--------------------------------------------------------------------------------
1 | {
2 | "curves": ["Bn128", "Bls12_381"],
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [["1", "2", "3"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": ["1", "2"]
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u8_to_field.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u8_to_bits;
2 |
3 | def main(u8 i) -> field {
4 | bool[8] bits = u8_to_bits(i);
5 | field mut res = 0;
6 | for u32 j in 0..8 {
7 | u32 exponent = 8 - j - 1;
8 | res = res + (bits[j] ? 2 ** exponent : 0);
9 | }
10 | return res;
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/multi_shadowing.zok:
--------------------------------------------------------------------------------
1 | def add(field a,field b) -> field {
2 | field v = a + b;
3 | return v;
4 | }
5 |
6 | def sub(field a, field b) -> field {
7 | return a - b;
8 | }
9 |
10 | def main(field a, field b) -> field {
11 | field c = add(a, b);
12 | field d = sub(a, b);
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u16_to_field.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u16_to_bits;
2 |
3 | def main(u16 i) -> field {
4 | bool[16] bits = u16_to_bits(i);
5 | field mut res = 0;
6 | for u32 j in 0..16 {
7 | u32 exponent = 16 - j - 1;
8 | res = res + (bits[j] ? 2 ** exponent : 0);
9 | }
10 | return res;
11 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_to_field.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u32_to_bits;
2 |
3 | def main(u32 i) -> field {
4 | bool[32] bits = u32_to_bits(i);
5 | field mut res = 0;
6 | for u32 j in 0..32 {
7 | u32 exponent = 32 - j - 1;
8 | res = res + (bits[j] ? 2 ** exponent : 0);
9 | }
10 | return res;
11 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u64_to_field.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u64_to_bits;
2 |
3 | def main(u64 i) -> field {
4 | bool[64] bits = u64_to_bits(i);
5 | field mut res = 0;
6 | for u32 j in 0..64 {
7 | u32 exponent = 64 - j - 1;
8 | res = res + (bits[j] ? 2 ** exponent : 0);
9 | }
10 | return res;
11 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/edwardsAdd.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/edwardsAdd.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/blake2/blake2s_512bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/mimcSponge/mimcSponge.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/mimcSponge/mimcSponge.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/1024bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/1024bitPadded.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/generics/conflicting_call.zok:
--------------------------------------------------------------------------------
1 | def foo(field[N] a) -> field[P] {
2 | return a;
3 | }
4 |
5 | def foo(field[P] a) -> field[N] {
6 | return a;
7 | }
8 |
9 | def bar(field[Q] a) -> field[Q] {
10 | return foo(a);
11 | }
12 |
13 | def main() -> field[1] {
14 | return bar([1]);
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/left_rotation_bits.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_bits" as to_bits;
2 | import "utils/casts/u32_from_bits" as from_bits;
3 |
4 | def rotl32(u32 e) -> u32 {
5 | bool[32] b = to_bits(e);
6 | return from_bits([...b[N..], ...b[..N]]);
7 | }
8 |
9 | def main(u32 i) -> u32 {
10 | return rotl32::<2>(i);
11 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/memoize/no_array_memoization.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/memoize/no_array_memoization.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/constant.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/tuples/constant.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/empty.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/tuples/empty.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": [[]]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_field/src/bls12_381.rs:
--------------------------------------------------------------------------------
1 | use ark_bls12_381::Bls12_381;
2 |
3 | prime_field!("bls12_381", Bls12_381, G2Type::Fq2);
4 |
5 | ark_extensions!(Bls12_381);
6 |
7 | #[cfg(feature = "bellman")]
8 | use bellman_ce::pairing::bls12_381::{Bls12, Fq2};
9 |
10 | use crate::G2Type;
11 | #[cfg(feature = "bellman")]
12 | bellman_extensions!(Bls12, Fq2);
13 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1024bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/blake2/blake2s_1024bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_1536bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/blake2/blake2s_1536bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/blake2/blake2s_8192bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/blake2/blake2s_8192bit.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/conditional_expensive.zok:
--------------------------------------------------------------------------------
1 | def cheap(field x) -> field {
2 | return x + 1;
3 | }
4 |
5 | def expensive(field x) -> field {
6 | return x**1000;
7 | }
8 |
9 | def main(field x) -> field {
10 | return if x == 1 {
11 | cheap(x)
12 | } else {
13 | expensive(x) // both branches executed
14 | };
15 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/struct_member_type_mismatch_field.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | field[2] values;
3 | }
4 |
5 | struct Bar {
6 | Foo foo;
7 | field bar;
8 | }
9 |
10 | def main() {
11 | Bar s = Bar {
12 | foo: Foo { values: [1] },
13 | bar: 0,
14 | };
15 | field b = s.bar;
16 | return;
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/right_rotation_bits.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_bits" as to_bits;
2 | import "utils/casts/u32_from_bits" as from_bits;
3 |
4 | def rotr32(u32 e) -> u32 {
5 | bool[32] b = to_bits(e);
6 | return from_bits([...b[32-N..], ...b[..32-N]]);
7 | }
8 |
9 | def main(u32 i) -> u32 {
10 | return rotr32::<2>(i);
11 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/structs/constant.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/structs/constant.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/edwardsCompress.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/edwardsCompress.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/edwardsOnCurve.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/edwardsOnCurve.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/1024bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/embed/1024bitPadded.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": []
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": []
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/.github/workflows/docs-check.yml:
--------------------------------------------------------------------------------
1 | name: Check markdown links
2 | on: [pull_request]
3 | jobs:
4 | markdown-link-check:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v2
8 | - uses: gaurav-nelson/github-action-markdown-link-check@v1
9 | with:
10 | use-quiet-mode: 'no'
11 | use-verbose-mode: 'yes'
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/numeric_inference.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | // `255` is infered to `255f`, and the addition happens between field elements
3 | assert(255 + 1f == 256);
4 |
5 | // `255` is infered to `255u8`, and the addition happens between u8
6 | // This causes an overflow
7 | assert(255 + 1u8 == 0);
8 |
9 | return;
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/ambiguous_generic_call.zok:
--------------------------------------------------------------------------------
1 | // this should not compile, as A == B
2 |
3 | const u32 A = 1;
4 | const u32 B = 1;
5 |
6 | def foo(field[A] a) -> bool {
7 | return true;
8 | }
9 |
10 | def foo(field[B] a) -> bool {
11 | return true;
12 | }
13 |
14 | def main() {
15 | assert(foo([1]));
16 | return;
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/bool.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/bool.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": true
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/field.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/field.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": "1"
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/nested.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/nested.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": "8"
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/fact_up_to_4.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_field" as to_field;
2 |
3 | def main(field x) -> field {
4 | field mut f = 1;
5 | field mut counter = 0;
6 | for u32 i in 1..5 {
7 | f = counter == x ? f : f * to_field(i);
8 | counter = counter == x ? counter : counter + 1;
9 | }
10 | return f;
11 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/memoize/memoize.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/memoize/memoize.zok",
3 | "max_constraint_count": 32,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": ["3"]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/edwardsOrderCheck.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/edwardsOrderCheck.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/edwardsScalarMult.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/edwardsScalarMult.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/ecc/proofOfOwnership.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/ecc/proofOfOwnership.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/512bit.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/scripts/benchmark.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Usage: benchmark.sh
4 | # For MacOS: install gtime with homebrew `brew install gnu-time`
5 |
6 | cmd=$*
7 | format="mem=%KK rss=%MK elapsed=%E cpu=%P cpu.sys=%S inputs=%I outputs=%O"
8 |
9 | if command -v gtime; then
10 | gtime -f "$format" $cmd
11 | else
12 | /usr/bin/time -f "$format" $cmd
13 | fi
14 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/array.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/array.zok",
3 | "max_constraint_count": 2,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": ["1", "2"]
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/uint.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/uint.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": "0x00000001"
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/constant.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/constant.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": "0x01234567"
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/rotate.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_bits" as to_bits;
2 | import "utils/casts/u32_from_bits" as from_bits;
3 |
4 | def right_rotate(u32 e) -> u32 {
5 | bool[32] b = to_bits(e);
6 | return from_bits([...b[32-N..], ...b[..32-N]]);
7 | }
8 |
9 | def main(u32 e) -> u32 {
10 | return right_rotate::<4>(e);
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_fs_resolver/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_fs_resolver"
3 | version = "0.5.2"
4 | authors = ["Thibaut Schaeffer "]
5 | repository = "https://github.com/JacobEberhardt/ZoKrates.git"
6 | edition = "2018"
7 |
8 | [dependencies]
9 | zokrates_common = { path = "../zokrates_common" }
10 |
11 | [dev-dependencies]
12 | tempfile = "3"
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/pedersen/512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/pedersen/512bit.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/signatures/verifyEddsa.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/signatures/verifyEddsa.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/bool/pack128.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/bool/pack128.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/u32/pack128.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/u32/pack128.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/u32/unpack128.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/u32/unpack128.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core/src/optimizer/canonicalizer.rs:
--------------------------------------------------------------------------------
1 | use zokrates_ast::ir::{folder::Folder, LinComb};
2 | use zokrates_field::Field;
3 |
4 | #[derive(Default)]
5 | pub struct Canonicalizer;
6 |
7 | impl Folder for Canonicalizer {
8 | fn fold_linear_combination(&mut self, l: LinComb) -> LinComb {
9 | l.into_canonical().into()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/pedersen/512bitBool.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/pedersen/512bitBool.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/256bitPadded.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/512bitPacked2.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/512bitPacked.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/512bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/512bitPadded.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/embed/512bit.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/sha256Padded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/sha256Padded.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/bool/unpack128.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/bool/unpack128.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/bool/unpack256.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/ambiguous_generic_call_too_strict.zok:
--------------------------------------------------------------------------------
1 | // this should actually compile, as A != B
2 |
3 | const u32 A = 2;
4 | const u32 B = 1;
5 |
6 | def foo(field[A] a) -> bool {
7 | return true;
8 | }
9 |
10 | def foo(field[B] a) -> bool {
11 | return true;
12 | }
13 |
14 | def main() {
15 | assert(foo([1]));
16 | return;
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/compile_errors/struct_member_type_mismatch_u8.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | u8[2] values;
3 | }
4 |
5 | struct Bar {
6 | Foo foo;
7 | u8 bar;
8 | }
9 |
10 | def main() {
11 | Bar s = Bar {
12 | foo: Foo { values: [1] }, // notice the size mismatch here
13 | bar: 0,
14 | };
15 | u8 b = s.bar;
16 | return;
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_common/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_common"
3 | version = "0.1.1"
4 | authors = ["dark64 "]
5 | edition = "2018"
6 |
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 |
9 | [features]
10 | default = ["bellman", "ark"]
11 | bellman = []
12 | ark = []
13 |
14 |
15 | [dependencies]
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/compare_min_to_max.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_MAX;
2 |
3 | // /!\ should be called with a = 0
4 | // as `|a - FIELD_MAX| < 2**(N-2)` the comparison should succeed
5 |
6 | def main(field a) -> bool {
7 | field p = FIELD_MAX + a;
8 | // we added a = 0 to prevent the condition to be evaluated at compile time
9 | return a < p;
10 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/tuple.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/tuple.zok",
3 | "max_constraint_count": 3,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": [["1", "1"], true]
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/tuples/element_order.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/tuples/element_order.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": [["3", true]]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/propagation/rotate.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/propagation/rotate.zok",
3 | "max_constraint_count": 1,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/u32/unpack128.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | import "../bool/unpack128" as unpack;
4 | import "../../casts/bool_128_to_u32_4" as from_bits;
5 |
6 | // Unpack a field element as 128 big-endian bits
7 | // Precondition: the input is smaller or equal to `2**128 - 1`
8 | def main(field i) -> u32[4] {
9 | return from_bits(unpack(i));
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/multiplexer/lookup1bit.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/multiplexer/lookup2bit.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/multiplexer/lookup2bit.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/js-format-check.yml:
--------------------------------------------------------------------------------
1 | name: Check JS/JSON/TS format
2 | on: [pull_request]
3 | jobs:
4 | js-format-check:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v2
8 | - name: Check format with prettier
9 | uses: creyD/prettier_action@v4.2
10 | with:
11 | prettier_options: --check ./**/*.{js,ts,json}
12 |
--------------------------------------------------------------------------------
/zokrates_ast/src/common/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod embed;
2 | mod error;
3 | mod format_string;
4 | mod parameter;
5 | mod solvers;
6 | mod variable;
7 |
8 | pub use self::embed::FlatEmbed;
9 | pub use self::error::RuntimeError;
10 | pub use self::parameter::Parameter;
11 | pub use self::solvers::Solver;
12 | pub use self::variable::Variable;
13 | pub use format_string::FormatString;
14 |
--------------------------------------------------------------------------------
/zokrates_book/src/language/generics.md:
--------------------------------------------------------------------------------
1 | ## Generics
2 |
3 | ZoKrates supports code that is generic over constants of the `u32` type. No specific keyword is used: the compiler determines if the generic parameters are indeed constant at compile time. Here's an example of generic code in ZoKrates:
4 |
5 | ```zokrates
6 | {{#include ../../../zokrates_cli/examples/book/generics.zok}}
7 | ```
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/structs.zok:
--------------------------------------------------------------------------------
1 | struct Bar {
2 | field[N] c;
3 | bool d;
4 | }
5 |
6 | struct Foo {
7 | Bar
a;
8 | bool b;
9 | }
10 |
11 | def main() -> Foo<2> {
12 | Foo<2>[2] mut f = [Foo { a: Bar { c: [0, 0], d: false }, b: true}, Foo { a: Bar {c: [0, 0], d: false}, b: true }];
13 | f[0].a.c = [42, 43];
14 | return f[0];
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/empty_spread_propagation.zok:
--------------------------------------------------------------------------------
1 | def func() -> bool {
2 | u64[N] y = [...[0; N-1], 1]; // the rhs should *not* be reduced to [1] because the spread is not empty
3 | u64 mut q = 0;
4 |
5 | for u32 i in 0..N {
6 | q = y[i];
7 | }
8 |
9 | return true;
10 | }
11 |
12 | def main() {
13 | assert(func::<2>());
14 | return;
15 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/expressions.zok:
--------------------------------------------------------------------------------
1 | def add(field a,field b) -> field {
2 | field v = a + b;
3 | return v;
4 | }
5 |
6 | // Expected for inputs 1,1: c=4, d=7, e=10
7 | def main(field a,field b) -> field {
8 | field c = add(a*2+3*b-a,b-1);
9 | field d = add(a*b+2, a*b*c);
10 | field e = add(add(a,d),add(a,b));
11 | return e;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/precedence.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/precedence.zok",
3 | "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/structs/member_order.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | field b;
3 | bool a;
4 | }
5 |
6 | // this tests the abi, checking that the fields of a `Foo` instance get encoded in the right order
7 | // if the the encoder reverses `a` and `b`, the boolean check ends up being done on the field value, which would fail
8 | def main(Foo f) {
9 | return;
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/casts/u8.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/casts/u8.zok",
3 | "max_constraint_count": 0,
4 | "curves": ["Bn128"],
5 | "tests": [
6 | {
7 | "input": {
8 | "values": []
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": []
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/tuples/set_member.zok:
--------------------------------------------------------------------------------
1 | struct Bar {
2 | field[2] c;
3 | bool d;
4 | }
5 |
6 | struct Foo {
7 | Bar a;
8 | bool b;
9 | }
10 |
11 | def main() -> ((field[2], bool), bool) {
12 | ((field[2], bool), bool)[2] mut f = [
13 | (([0, 0], false), true),
14 | (([0, 0], false), true)
15 | ];
16 | f[0].0.0 = [42, 43];
17 | return f[0];
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/complex_call.zok:
--------------------------------------------------------------------------------
1 | struct Foo {
2 | bool[2] a;
3 | field b;
4 | }
5 |
6 | def f(bool a, field b, Foo c, field[2] d) -> (Foo, field) {
7 | return (Foo { a: [a, a], b: d[0] }, c.a[0] ? b + c.b : d[1]);
8 | }
9 |
10 | def main(bool a, field b, Foo c, field[2] d) -> (Foo, field) {
11 | (Foo, field) r = f(a, b, c, d);
12 | return r;
13 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/multiplexer/lookup2bit.zok:
--------------------------------------------------------------------------------
1 | // Two-bit window lookup table using one constraint
2 | // Maps the bits `b` to a list of field elements `c`
3 | def main(bool[2] b, field[4] c) -> field {
4 | field alpha = c[1] - c[0] + (b[1] ? (c[3] - c[2] - c[1] + c[0]) : 0);
5 | field out = (b[0] ? alpha : 0) + c[0] - (b[1] ? (0 - c[2] + c[0]) : 0);
6 | return out;
7 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/256bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/embed/256bitPadded.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/embed/512bitPacked.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPadded.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/sha256/embed/512bitPadded.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/casts/bool.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/casts/bool.zok",
3 | "max_constraint_count": 0,
4 | "curves": ["Bn128"],
5 | "tests": [
6 | {
7 | "input": {
8 | "values": []
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": []
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/casts/u16.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/casts/u16.zok",
3 | "max_constraint_count": 0,
4 | "curves": ["Bn128"],
5 | "tests": [
6 | {
7 | "input": {
8 | "values": []
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": []
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/casts/u32.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/casts/u32.zok",
3 | "max_constraint_count": 0,
4 | "curves": ["Bn128"],
5 | "tests": [
6 | {
7 | "input": {
8 | "values": []
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": []
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/casts/u64.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/casts/u64.zok",
3 | "max_constraint_count": 0,
4 | "curves": ["Bn128"],
5 | "tests": [
6 | {
7 | "input": {
8 | "values": []
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": []
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/multiplexer/lookup3bitSigned.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/multiplexer/lookup3bitSigned.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/bool/nonStrictUnpack256.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/bool/nonStrictUnpack256.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/u32/nonStrictUnpack256.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/utils/pack/u32/nonStrictUnpack256.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/dev.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rustlang/rust:nightly
2 |
3 | MAINTAINER JacobEberhardt , Thibaut Schaeffer
4 |
5 | RUN useradd -u 1000 -m zokrates
6 |
7 | COPY ./scripts/install_solcjs_deb.sh /tmp/
8 | RUN /tmp/install_solcjs_deb.sh
9 |
10 | USER zokrates
11 |
12 | WORKDIR /home/zokrates
13 |
14 | COPY --chown=zokrates:zokrates . ZoKrates
15 |
--------------------------------------------------------------------------------
/zokrates_common/src/constants.rs:
--------------------------------------------------------------------------------
1 | pub const BELLMAN: &str = "bellman";
2 | pub const ARK: &str = "ark";
3 |
4 | pub const BN128: &str = "bn128";
5 | pub const BLS12_381: &str = "bls12_381";
6 | pub const BLS12_377: &str = "bls12_377";
7 | pub const BW6_761: &str = "bw6_761";
8 |
9 | pub const G16: &str = "g16";
10 | pub const GM17: &str = "gm17";
11 | pub const MARLIN: &str = "marlin";
12 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/array_size.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/array_size.zok",
3 | "max_constraint_count": 2,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": [["42", "42"]]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": ["42", "42"]
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/constants/propagate.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/constants/propagate.zok",
3 | "max_constraint_count": 4,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": ["42", "42", "42", "42"]
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha256/embed/shaRoundNoBoolCheck.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | from "EMBED" import sha256round;
4 |
5 | // a and b is NOT checked to be 0 or 1
6 | // the return value is checked to be 0 or 1
7 | // IV vector is checked to be of type bool
8 | def main(bool[256] a, bool[256] b, bool[256] IV) -> bool[256] {
9 | return sha256round([...a, ...b], IV);
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/utils/256bitsDirectionHelper.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/utils/256bitsDirectionHelper.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": []
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": []
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/sha256_tutorial/hashexample_updated.zok:
--------------------------------------------------------------------------------
1 | import "hashes/sha256/512bitPacked" as sha256packed;
2 |
3 | def main(private field a, private field b, private field c, private field d) {
4 | field[2] h = sha256packed([a, b, c, d]);
5 | assert(h[0] == 263561599766550617289250058199814760685);
6 | assert(h[1] == 65303172752238645975888084098459749904);
7 | return;
8 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/ch.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/ch.zok",
3 | "max_constraint_count": 200,
4 | "tests": [
5 | {
6 | "input": {
7 | "values": ["0x00000000", "0x00000000", "0x00000000"]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": "0x00000000"
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/unpack_unchecked.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import unpack;
2 |
3 | // Unpack a field element as N big endian bits without checking for overflows
4 | // This does *not* guarantee a single output: for example, 0 can be decomposed as 0 or as P and this function does not enforce either
5 | def main(field i) -> bool[N] {
6 | bool[N] res = unpack(i);
7 | return res;
8 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/complex_call_in_constant.zok:
--------------------------------------------------------------------------------
1 | def constant() -> u32 {
2 | u32 mut res = 0;
3 | u32 x = 3;
4 | for u32 y in 0..x {
5 | res = res + 1;
6 | }
7 | return res;
8 | }
9 |
10 | const u32 CONSTANT = 1 + constant();
11 |
12 | const u32 OTHER_CONSTANT = 42;
13 |
14 | def main(field[CONSTANT] a) -> u32 {
15 | return CONSTANT + OTHER_CONSTANT;
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/compare_min_to_max.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/compare_min_to_max.zok",
3 | "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": ["0"]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": false
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_pest_ast/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_pest_ast"
3 | version = "0.3.0"
4 | authors = ["schaeff "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | zokrates_parser = { version = "0.3.0", path = "../zokrates_parser" }
9 | pest = "2.0"
10 | pest-ast = "0.3.3"
11 | from-pest = "0.3.1"
12 | lazy_static = "1.3.0"
13 |
14 | [dev-dependencies]
15 | glob = "0.2"
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha256/1024bit.zok:
--------------------------------------------------------------------------------
1 | import "./sha256" as sha256;
2 |
3 | // A function that takes 4 u32[8] arrays as inputs, concatenates them,
4 | // and returns their sha256 compression as a u32[8].
5 | // Note: no padding is applied
6 |
7 | def main(u32[8] a, u32[8] b, u32[8] c, u32[8] d) -> u32[8] {
8 | u32[8] res = sha256([[...a, ...b], [...c, ...d]]);
9 | return res;
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/pack256.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | import "./pack" as pack;
4 |
5 | // pack 256 big-endian bits into one field element
6 | // Note: This is not a injective operation as `p` is smaller than `2**256 - 1` for bn128
7 | // For example, `[0, 0,..., 0]` and `bits(p)` both point to `0`
8 | def main(bool[256] bits) -> field {
9 | return pack(bits);
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/test1.zok:
--------------------------------------------------------------------------------
1 | // only using sub, no need to flatten
2 | def main(field x) -> field {
3 | field a = 5;
4 | field b = 7;
5 | field c = a == b ? 4 : 3;
6 | assert(c == 3);
7 | field d = a == 5 ? 1 : 2;
8 | assert(d == 1);
9 | field e = a < b ? 5 : 6;
10 | assert(e == 5);
11 | field f = b < a ? 7 : 8;
12 | assert(f == 8);
13 | return x;
14 | }
15 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/multiplexer/lookup3bitSigned.zok:
--------------------------------------------------------------------------------
1 | import "./lookup2bit" as lookup;
2 |
3 | // Three-bit window lookup (2bits + signature bit) in 2bit table
4 | // using two constraints. Maps the bits `b` to a list of constants `c`
5 | def main(bool[3] b, field[4] c) -> field {
6 | field alpha = lookup([b[0], b[1]], c);
7 | field out = alpha - 2 * (b[2] ? alpha : 0);
8 | return out;
9 | }
--------------------------------------------------------------------------------
/CHANGELOG-scrypt.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | ## [1.9.0] - 2023-03-07
5 |
6 | sCrypt verifier export is now an scrypt-ts project.
7 |
8 | ## [1.8.2] - 2022-09-17
9 |
10 | base on v0.8.2 merge https://github.com/Zokrates/ZoKrates/commit/9d04dca66e2e2a99b5b5acbf3168393bf9b8e06e
11 |
12 | ### Changes
13 | - support bellman in zokrates_js
14 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/test_lt_max_value.zok:
--------------------------------------------------------------------------------
1 | from "field" import FIELD_SIZE_IN_BITS;
2 |
3 | // we can compare numbers up to 2^(pbits - 2) - 1, ie any number which fits in (pbits - 2) bits
4 | // lt should work for the maxvalue = 2^(pbits - 2) - 1
5 |
6 | def main(field a) -> bool {
7 | u32 pbits = FIELD_SIZE_IN_BITS;
8 | field maxvalue = 2**(pbits - 2) - 1;
9 | return 0 < maxvalue;
10 | }
11 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/complex_call.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/complex_call.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [true, "2", { "a": [false, true], "b": "2" }, ["3", "4"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": [{ "a": [true, true], "b": "3" }, "4"]
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/pow.zok:
--------------------------------------------------------------------------------
1 | def main() {
2 | field mut x = 2**4;
3 | assert(x == 16);
4 | x = x**2;
5 | assert(x == 256);
6 | field y = 3**3;
7 | assert(y == 27);
8 | field z = y**2;
9 | assert(z == 729);
10 | field mut a = 5**2;
11 | assert(a == 25);
12 | a = a**2;
13 | assert(a == 625);
14 | a = 5**5;
15 | assert(a == 3125);
16 | return;
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "endOfLine": "auto",
3 | "overrides": [
4 | {
5 | "files": "*.ts",
6 | "options": {
7 | "semi": false,
8 | "printWidth": 80,
9 | "tabWidth": 4,
10 | "useTabs": false,
11 | "singleQuote": true,
12 | "trailingComma": "es5",
13 | "bracketSpacing": true
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/256bitPadded.zok:
--------------------------------------------------------------------------------
1 | import "hashes/sha256/256bitPadded" as sha256;
2 |
3 | def main() {
4 | u32[8] a = [0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89];
5 | u32[8] digest = sha256(a);
6 |
7 | assert(digest == [0x16d947ca, 0x4831aee7, 0x6999aa28, 0x20e5c3b4, 0x8171bf49, 0x27241da9, 0xebe644df, 0x9b690df0]);
8 | return;
9 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/imports/inliner_state.zok:
--------------------------------------------------------------------------------
1 | from "./inliner_state_aux" import main as test;
2 |
3 | // we check that the constant inliner does not get corrupted
4 | // notice that the constant generic has the same name as the constant `K`
5 | // defined in the `test1.zok` module
6 | def tmp() {
7 | u32 junk = test() + K;
8 | return;
9 | }
10 |
11 | // dummy main
12 | def main() {
13 | return;
14 | }
15 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/struct_generic_inference.zok:
--------------------------------------------------------------------------------
1 | struct SomeStruct {
2 | u64[N] f;
3 | }
4 |
5 | def myFct(SomeStruct ignored) -> u32[N2] {
6 | assert(2*N == N2);
7 | return [N3; N2];
8 | }
9 |
10 | const u32 N = 3;
11 |
12 | const u32 N2 = 2*N;
13 |
14 | def main(SomeStruct arg) -> u32 {
15 | u32[N2] someVariable = myFct::<_, _, 42>(arg);
16 | return someVariable[0];
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/structs/add.zok:
--------------------------------------------------------------------------------
1 | struct Point {
2 | field x;
3 | field y;
4 | }
5 |
6 | def main(Point p, Point q) -> Point {
7 | field a = 42;
8 | field d = 21;
9 |
10 | field dpxpyqxqy = d * p.x * p.y * q.x * q.y;
11 |
12 | return Point {
13 | x: (p.x * q.y + q.x * p.y) / (1 + dpxpyqxqy),
14 | y: (q.x * q.y - a * p.x * p.y) / (1 - dpxpyqxqy)
15 | };
16 | }
17 |
18 |
19 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/bool/nonStrictUnpack256.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | import "./unpack_unchecked";
4 |
5 | // Unpack a field element as 256 big-endian bits
6 | // Note: uniqueness of the output is not guaranteed
7 | // For example, `0` can map to `[0, 0, ..., 0]` or to `bits(p)`
8 | def main(field i) -> bool[256] {
9 | bool[254] b = unpack_unchecked(i);
10 | return [false, false, ...b];
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/alias/struct_aliasing.zok:
--------------------------------------------------------------------------------
1 | type FieldArray = field[N];
2 |
3 | struct Foo {
4 | FieldArray a;
5 | FieldArray b;
6 | }
7 |
8 | type Bar = Foo<2, 2>;
9 | type Buzz = Foo;
10 |
11 | def main(Bar a) -> Buzz<2> {
12 | Bar bar = Bar { a: [1, 2], b: [1, 2] };
13 | Buzz<2> buzz = Buzz { a: [1, 2], b: [1, 2] };
14 | assert(bar == buzz);
15 | return buzz;
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/poseidon/poseidon_2.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [["1", "2"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": "7853200120776062878684798364095072458815029376092732009249414926327459813530"
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/alias/basic_aliasing.zok:
--------------------------------------------------------------------------------
1 | type byte = u8;
2 | type uint32 = u32;
3 | type UInt32Array = uint32[N];
4 |
5 | type matrix = field[R][C];
6 |
7 | def fill(field v) -> matrix {
8 | return [[v; C]; R];
9 | }
10 |
11 | def main(uint32 a, uint32 b) -> (UInt32Array<2>, matrix<2, 4>) {
12 | UInt32Array<2> res = [a, b];
13 | matrix<2, 4> m = fill(1);
14 | return (res, m);
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_stdlib"
3 | version = "0.3.2"
4 | authors = ["Stefan Deml ", "schaeff "]
5 | edition = "2018"
6 |
7 | [dev-dependencies]
8 | zokrates_test = { version = "0.2", path = "../zokrates_test" }
9 |
10 | [build-dependencies]
11 | fs_extra = "1.1.0"
12 | zokrates_test_derive = { version = "0.0", path = "../zokrates_test_derive" }
13 |
14 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha256/1536bit.zok:
--------------------------------------------------------------------------------
1 | import "./sha256" as sha256;
2 |
3 | // A function that takes 6 u32[8] arrays as inputs, concatenates them,
4 | // and returns their sha256 compression as a u32[8].
5 | // Note: no padding is applied
6 |
7 | def main(u32[8] a, u32[8] b, u32[8] c, u32[8] d, u32[8] e, u32[8] f) -> u32[8] {
8 | u32[8] res = sha256([[...a, ...b], [...c, ...d], [...e, ...f]]);
9 | return res;
10 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_3.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/poseidon/poseidon_3.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [["1", "2", "3"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": "6542985608222806190361240322586112750744169038454362455181422643027100751666"
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/alias/import_alias.zok:
--------------------------------------------------------------------------------
1 | from "./basic_aliasing.zok" import matrix;
2 | from "./struct_aliasing.zok" import Buzz;
3 |
4 | const u32 R = 2;
5 | const u32 C = 4;
6 |
7 | type matrix_2x4 = matrix;
8 |
9 | def buzz() -> Buzz {
10 | return Buzz { a: [0; N], b: [0; N] };
11 | }
12 |
13 | def main(matrix_2x4 m) -> (Buzz<2>, matrix_2x4) {
14 | Buzz<2> b = buzz::<2>();
15 | return (b, m);
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/explicit_generic_parameters.zok:
--------------------------------------------------------------------------------
1 | // a function to sum the N first powers of a field element
2 | def sum_powers(field a) -> field {
3 | field mut res = 0;
4 | for u32 i in 0..N {
5 | res = res + a ** i;
6 | }
7 | return res;
8 | }
9 |
10 | def main(field a) -> field {
11 | // call `sum_powers` providing the explicit generic parameter `N := 5`
12 | return sum_powers::<5>(a);
13 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/functions/multi_functions.zok:
--------------------------------------------------------------------------------
1 | def add(field a, field b) -> field {
2 | field v = a + b;
3 | return v + a;
4 | }
5 |
6 | def main(field a, field b, field c, field d) -> field {
7 | field mut g = a + b;
8 | field x = add(a, b);
9 | field y = add(c, d);
10 | g = add(x, g);
11 | g = add(x, g);
12 | field f = c + d + a;
13 | g = add(g + a, add(x, b));
14 | return x + y + g + f;
15 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/poseidon/poseidon_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/hashes/poseidon/poseidon_4.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [["1", "2", "3", "4"]]
7 | },
8 | "output": {
9 | "Ok": {
10 | "value": "18821383157269793795438455681495246036402687001665670618754263018637548127333"
11 | }
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/u32_array_to_bool_array.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u32_to_bits;
2 |
3 | def main(u32[N] input) -> bool[P] {
4 | assert(P == 32 * N);
5 |
6 | bool[P] mut res = [false; P];
7 |
8 | for u32 i in 0..N {
9 | bool[32] bits = u32_to_bits(input[i]);
10 | for u32 j in 0..32 {
11 | res[i * 32 + j] = bits[j];
12 | }
13 | }
14 |
15 | return res;
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/hashes/sha256/embed/512bitPacked.zok:
--------------------------------------------------------------------------------
1 | import "hashes/sha256/embed/512bitPacked" as sha256packed;
2 |
3 | def main() {
4 | field a = 0;
5 | field b = 0;
6 | field c = 0;
7 | field d = 5;
8 |
9 | field[2] h = sha256packed([a, b, c, d]);
10 |
11 | assert(h[0] == 263561599766550617289250058199814760685);
12 | assert(h[1] == 65303172752238645975888084098459749904);
13 |
14 | return;
15 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/pack/u32/nonStrictUnpack256.zok:
--------------------------------------------------------------------------------
1 | #pragma curve bn128
2 |
3 | import "../bool/nonStrictUnpack256" as unpack;
4 | import "../../casts/bool_256_to_u32_8" as from_bits;
5 |
6 | // Unpack a field element as a u32[8] (big-endian)
7 | // Note: uniqueness of the output is not guaranteed
8 | // For example, `0` can map to `[0, 0, ..., 0]` or to `bits(p)`
9 | def main(field i) -> u32[8] {
10 | return from_bits(unpack(i));
11 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/pass_by_value.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/pass_by_value.zok",
3 | "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
4 | "tests": [
5 | {
6 | "input": {
7 | "values": [["1"], { "a": "1" }, "1"]
8 | },
9 | "output": {
10 | "Ok": {
11 | "value": [["2"], ["1"], { "a": "2" }, { "a": "1" }, "2", "1"]
12 | }
13 | }
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_book/src/language/logging.md:
--------------------------------------------------------------------------------
1 | ## Logging
2 |
3 | ZoKrates supports a command to log messages during execution in the interpreter.
4 |
5 | The values of expressions can be checked and basic string interpolation is supported:
6 |
7 | ```zokrates
8 | {{#include ../../../zokrates_cli/examples/book/logging.zok}}
9 | ```
10 |
11 | By default, logs get removed during compilation. In order to include them in the compiled program, the `--debug` flag has to be enabled.
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/no_return.smt2:
--------------------------------------------------------------------------------
1 | ; Auto generated by ZoKrates
2 | ; Number of circuit variables: 3
3 | ; Number of equalities: 1
4 | (declare-const |~prime| Int)
5 | (declare-const |~one| Int)
6 | (declare-const |_0| Int)
7 | (declare-const |_1| Int)
8 | (assert (and
9 | (= |~prime| 21888242871839275222246405745257275088548364400416034343698204186575808495617)
10 | (= |~one| 1)
11 | (= (mod (* (* |~one| 1) (* |_0| 1)) |~prime|) (mod (* |_1| 1) |~prime|))
12 | ))
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/uint/operations.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/uint/operations.zok",
3 | "tests": [
4 | {
5 | "input": {
6 | "values": [
7 | "0x12345678",
8 | "0x01234567",
9 | ["0xfefefefe", "0xefefefef", "0xffffffff", "0xeeeeeeee"]
10 | ]
11 | },
12 | "output": {
13 | "Ok": {
14 | "value": []
15 | }
16 | }
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/zokrates_core_test/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "zokrates_core_test"
3 | version = "0.2.8"
4 | authors = ["schaeff "]
5 | edition = "2018"
6 |
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 |
9 | [dev-dependencies]
10 | zokrates_test = { version = "0.2", path = "../zokrates_test" }
11 |
12 | [build-dependencies]
13 | zokrates_test_derive = { version = "0.0", path = "../zokrates_test_derive" }
14 |
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/hashes/sha256/embed/512bit.zok:
--------------------------------------------------------------------------------
1 | import "./IVconstants" as IVconstants;
2 | import "./shaRoundNoBoolCheck" as sha256;
3 |
4 | // A function that takes 2 bool[256] arrays as inputs
5 | // and returns their sha256 compression function as an array of 256 bool.
6 | // No padding is being applied
7 | def main(bool[256] a, bool[256] b) -> bool[256] {
8 | bool[256] IV = IVconstants();
9 | bool[256] digest = sha256(a, b, IV);
10 | return digest;
11 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/stdlib/utils/casts/bool_array_to_u32_array.zok:
--------------------------------------------------------------------------------
1 | from "EMBED" import u32_from_bits;
2 |
3 | // convert an array of bool to an array of u32
4 | // the sizes must match (one u32 for 32 bool) otherwise an error will happen
5 | def main(bool[N] bits) -> u32[P] {
6 | assert(N == 32 * P);
7 |
8 | u32[P] mut res = [0; P];
9 |
10 | for u32 i in 0..P {
11 | res[i] = u32_from_bits(bits[32 * i..32 * (i + 1)]);
12 | }
13 |
14 | return res;
15 | }
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/structs/member_order.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/structs/member_order.zok",
3 | "curves": ["Bn128"],
4 | "tests": [
5 | {
6 | "abi": true,
7 | "input": {
8 | "values": [
9 | {
10 | "a": true,
11 | "b": "3"
12 | }
13 | ]
14 | },
15 | "output": {
16 | "Ok": {
17 | "value": []
18 | }
19 | }
20 | }
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/spread_slice.json:
--------------------------------------------------------------------------------
1 | {
2 | "entry_point": "./tests/tests/spread_slice.zok",
3 | "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
4 | "max_constraint_count": 9,
5 | "tests": [
6 | {
7 | "input": {
8 | "values": [["1", "2", "3"], ["4", "5", "6"], "7"]
9 | },
10 | "output": {
11 | "Ok": {
12 | "value": ["1", "2", "5", "6", "1", "2", "3", "5", "7"]
13 | }
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/zokrates_core_test/tests/tests/panics/conditional_bound_throw.zok:
--------------------------------------------------------------------------------
1 | def throwing_bound(u32 x) -> u32 {
2 | assert(x == N);
3 | return 1;
4 | }
5 |
6 | // this compiles: the conditional, even though it can throw, has a constant compile-time value of `1`
7 | // However, the assertions are still checked at runtime, which leads to panics without branch isolation.
8 | def main(u32 x) {
9 | for u32 i in 0..x == 0 ? throwing_bound::<0>(x) : throwing_bound::<1>(x) {}
10 | return;
11 | }
--------------------------------------------------------------------------------
/zokrates_cli/examples/n_choose_k.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_field" as to_field;
2 |
3 | // Binomial Coeffizient, n!/(k!*(n-k)!).
4 | def fac(field x) -> field {
5 | field mut f = 1;
6 | field mut counter = 0;
7 | for u32 i in 1..100 {
8 | f = counter == x ? f : f * to_field(i);
9 | counter = counter == x ? counter : counter + 1;
10 | }
11 | return f;
12 | }
13 |
14 | def main(field n, field k) -> field {
15 | return fac(n) / (fac(k) * fac(n - k));
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_cli/tests/code/n_choose_k.zok:
--------------------------------------------------------------------------------
1 | import "utils/casts/u32_to_field" as to_field;
2 |
3 | // Binomial Coeffizient, n!/(k!*(n-k)!).
4 | def fac(field x) -> field {
5 | field mut f = 1;
6 | field mut counter = 0;
7 | for u32 i in 1..100 {
8 | f = counter == x ? f : f * to_field(i);
9 | counter = counter == x ? counter : counter + 1;
10 | }
11 | return f;
12 | }
13 |
14 | def main(field n, field k) -> field {
15 | return fac(n)/(fac(k)*fac(n-k));
16 | }
17 |
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/multiplexer/lookup1bit.zok:
--------------------------------------------------------------------------------
1 | import "utils/multiplexer/lookup1bit" as lookup;
2 |
3 | def left() -> bool {
4 | bool sel = false; // left
5 | field[2] t = [0, 1];
6 |
7 | assert(0 == lookup(sel, t));
8 | return true;
9 | }
10 |
11 | def right() -> bool {
12 | bool sel = true; // right
13 | field[2] t = [0, 1];
14 |
15 | assert(1 == lookup(sel, t));
16 | return true;
17 | }
18 |
19 | def main() {
20 | assert(left());
21 | assert(right());
22 | return;
23 | }
--------------------------------------------------------------------------------
/zokrates_stdlib/tests/tests/utils/pack/bool/unpack256.zok:
--------------------------------------------------------------------------------
1 | import "utils/pack/bool/unpack256" as unpack256;
2 |
3 | def testFive() -> bool {
4 | bool[256] b = unpack256(5);
5 | assert(b == [...[false; 253], true, false, true]);
6 | return true;
7 | }
8 |
9 | def testZero() -> bool {
10 | bool[256] b = unpack256(0);
11 | assert(b == [false; 256]);
12 | return true;
13 | }
14 |
15 | def main() {
16 | assert(testFive());
17 | assert(testZero());
18 | return;
19 | }
20 |
--------------------------------------------------------------------------------
/zokrates_cli/examples/book/sha256_tutorial/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | bin=$1; stdlib=$2
5 |
6 | function zokrates() {
7 | ZOKRATES_STDLIB=$stdlib $bin "$@"
8 | }
9 |
10 | zokrates compile -i hashexample.zok
11 | zokrates compute-witness -a 0 0 0 5
12 |
13 | grep '~out' witness
14 |
15 | cp -f hashexample_updated.zok hashexample.zok
16 |
17 | zokrates compile -i hashexample.zok
18 | zokrates setup
19 | zokrates export-verifier
20 | zokrates compute-witness -a 0 0 0 5
21 | zokrates generate-proof
--------------------------------------------------------------------------------
/zokrates_cli/scrypt_proj_template/optimizations/apply_asm_optim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | apply() {
5 | scryptSrc=$1
6 | dirOptim=$2
7 |
8 | for fAsm in $(find $dirOptim -type f -name '*.asm'); do
9 | funcName=$(basename $fAsm .asm)
10 | node optimizations/replaceFuncBodyAsm.js $scryptSrc $funcName $fAsm > $scryptSrc.tmp
11 | mv $scryptSrc.tmp $scryptSrc
12 | done
13 |
14 | }
15 |
16 | # BN256
17 | apply artifacts/src/contracts/snark.scrypt optimizations/ec/bn256
18 |
--------------------------------------------------------------------------------