Skip to content

Commit

Permalink
Merge pull request #1237 from Zokrates/rc/0.8.3
Browse files Browse the repository at this point in the history
Release 0.8.3
  • Loading branch information
dark64 authored Oct 11, 2022
2 parents f592a4a + 6bb1d86 commit d9006cb
Show file tree
Hide file tree
Showing 31 changed files with 711 additions and 508 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
https://github.com/Zokrates/ZoKrates/compare/latest...develop

## [0.8.3] - 2022-10-11

### Release
- https://github.com/Zokrates/ZoKrates/releases/tag/0.8.3 <!-- markdown-link-check-disable-line -->

### Changes
- Disallow the use of the `private` and `public` keywords on non-entrypoint functions (#1224, @dark64)
- Fix duplicate constraint optimiser (#1226, @schaeff)

## [0.8.2] - 2022-09-05

### Release
Expand Down
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions zokrates_ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zokrates_ast"
version = "0.1.2"
version = "0.1.3"
edition = "2021"

[features]
Expand All @@ -20,7 +20,4 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
zokrates_embed = { version = "0.1.0", path = "../zokrates_embed", default-features = false }
pairing_ce = { version = "^0.21", optional = true }
ark-bls12-377 = { version = "^0.3.0", features = ["curve"], default-features = false, optional = true }




derivative = "2.2.0"
21 changes: 18 additions & 3 deletions zokrates_ast/src/ir/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::common::FormatString;
use crate::typed::ConcreteType;
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;
use std::fmt;
Expand All @@ -25,9 +26,14 @@ pub use crate::common::Variable;

pub use self::witness::Witness;

#[derive(Debug, Serialize, Deserialize, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Serialize, Deserialize, Clone, Derivative)]
#[derivative(Hash, PartialEq, Eq)]
pub enum Statement<T> {
Constraint(QuadComb<T>, LinComb<T>, Option<RuntimeError>),
Constraint(
QuadComb<T>,
LinComb<T>,
#[derivative(Hash = "ignore")] Option<RuntimeError>,
),
Directive(Directive<T>),
Log(FormatString, Vec<(ConcreteType, Vec<LinComb<T>>)>),
}
Expand Down Expand Up @@ -74,7 +80,16 @@ impl<T: Field> fmt::Display for Directive<T> {
impl<T: Field> fmt::Display for Statement<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Statement::Constraint(ref quad, ref lin, _) => write!(f, "{} == {}", quad, lin),
Statement::Constraint(ref quad, ref lin, ref error) => write!(
f,
"{} == {}{}",
quad,
lin,
error
.as_ref()
.map(|e| format!(" // {}", e))
.unwrap_or_else(|| "".to_string())
),
Statement::Directive(ref s) => write!(f, "{}", s),
Statement::Log(ref s, ref expressions) => write!(
f,
Expand Down
53 changes: 47 additions & 6 deletions zokrates_ast/src/typed/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ pub trait Folder<'ast, T: Field>: Sized {
fold_member_expression(self, ty, e)
}

fn fold_identifier_expression<
E: Expr<'ast, T> + Id<'ast, T> + From<TypedExpression<'ast, T>>,
>(
&mut self,
ty: &E::Ty,
e: IdentifierExpression<'ast, E>,
) -> IdentifierOrExpression<'ast, T, E> {
fold_identifier_expression(self, ty, e)
}

fn fold_element_expression<
E: Expr<'ast, T> + Element<'ast, T> + From<TypedExpression<'ast, T>>,
>(
Expand Down Expand Up @@ -534,6 +544,19 @@ pub fn fold_statement<'ast, T: Field, F: Folder<'ast, T>>(
vec![res]
}

pub fn fold_identifier_expression<
'ast,
T: Field,
E: Expr<'ast, T> + Id<'ast, T> + From<TypedExpression<'ast, T>>,
F: Folder<'ast, T>,
>(
f: &mut F,
_: &E::Ty,
e: IdentifierExpression<'ast, E>,
) -> IdentifierOrExpression<'ast, T, E> {
IdentifierOrExpression::Identifier(IdentifierExpression::new(f.fold_name(e.id)))
}

pub fn fold_embed_call<'ast, T: Field, F: Folder<'ast, T>>(
f: &mut F,
e: EmbedCall<'ast, T>,
Expand Down Expand Up @@ -571,8 +594,11 @@ pub fn fold_array_expression_inner<'ast, T: Field, F: Folder<'ast, T>>(
use ArrayExpressionInner::*;

match e {
Identifier(id) => match f.fold_identifier_expression(ty, id) {
IdentifierOrExpression::Identifier(i) => ArrayExpressionInner::Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Block(block) => Block(f.fold_block_expression(block)),
Identifier(id) => Identifier(f.fold_name(id)),
Value(exprs) => Value(
exprs
.into_iter()
Expand Down Expand Up @@ -621,8 +647,11 @@ pub fn fold_struct_expression_inner<'ast, T: Field, F: Folder<'ast, T>>(
use StructExpressionInner::*;

match e {
Identifier(id) => match f.fold_identifier_expression(ty, id) {
IdentifierOrExpression::Identifier(i) => Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Block(block) => Block(f.fold_block_expression(block)),
Identifier(id) => Identifier(f.fold_name(id)),
Value(exprs) => Value(exprs.into_iter().map(|e| f.fold_expression(e)).collect()),
FunctionCall(function_call) => match f.fold_function_call_expression(ty, function_call) {
FunctionCallOrExpression::FunctionCall(function_call) => FunctionCall(function_call),
Expand Down Expand Up @@ -656,7 +685,10 @@ pub fn fold_tuple_expression_inner<'ast, T: Field, F: Folder<'ast, T>>(

match e {
Block(block) => Block(f.fold_block_expression(block)),
Identifier(id) => Identifier(f.fold_name(id)),
Identifier(id) => match f.fold_identifier_expression(ty, id) {
IdentifierOrExpression::Identifier(i) => Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Value(exprs) => Value(exprs.into_iter().map(|e| f.fold_expression(e)).collect()),
FunctionCall(function_call) => match f.fold_function_call_expression(ty, function_call) {
FunctionCallOrExpression::FunctionCall(function_call) => FunctionCall(function_call),
Expand Down Expand Up @@ -688,9 +720,12 @@ pub fn fold_field_expression<'ast, T: Field, F: Folder<'ast, T>>(
use FieldElementExpression::*;

match e {
Identifier(id) => match f.fold_identifier_expression(&Type::FieldElement, id) {
IdentifierOrExpression::Identifier(i) => Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Block(block) => Block(f.fold_block_expression(block)),
Number(n) => Number(n),
Identifier(id) => Identifier(f.fold_name(id)),
Add(box e1, box e2) => {
let e1 = f.fold_field_expression(e1);
let e2 = f.fold_field_expression(e2);
Expand Down Expand Up @@ -840,9 +875,12 @@ pub fn fold_boolean_expression<'ast, T: Field, F: Folder<'ast, T>>(
use BooleanExpression::*;

match e {
Identifier(id) => match f.fold_identifier_expression(&Type::Boolean, id) {
IdentifierOrExpression::Identifier(i) => Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Block(block) => BooleanExpression::Block(f.fold_block_expression(block)),
Value(v) => BooleanExpression::Value(v),
Identifier(id) => BooleanExpression::Identifier(f.fold_name(id)),
FieldEq(e) => match f.fold_eq_expression(e) {
EqOrBoolean::Eq(e) => BooleanExpression::FieldEq(e),
EqOrBoolean::Boolean(u) => u,
Expand Down Expand Up @@ -966,9 +1004,12 @@ pub fn fold_uint_expression_inner<'ast, T: Field, F: Folder<'ast, T>>(
use UExpressionInner::*;

match e {
Identifier(id) => match f.fold_identifier_expression(&ty, id) {
IdentifierOrExpression::Identifier(i) => Identifier(i),
IdentifierOrExpression::Expression(u) => u,
},
Block(block) => Block(f.fold_block_expression(block)),
Value(v) => Value(v),
Identifier(id) => Identifier(f.fold_name(id)),
Add(box left, box right) => {
let left = f.fold_uint_expression(left);
let right = f.fold_uint_expression(right);
Expand Down
Loading

0 comments on commit d9006cb

Please sign in to comment.