diff --git a/CHANGELOG.md b/CHANGELOG.md index 42f323d3..e589ac99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 + +### 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 diff --git a/Cargo.lock b/Cargo.lock index 5564cf11..33389a5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3049,7 +3049,7 @@ dependencies = [ [[package]] name = "zokrates_ast" -version = "0.1.2" +version = "0.1.3" dependencies = [ "ark-bls12-377", "cfg-if 0.1.10", @@ -3096,7 +3096,7 @@ dependencies = [ [[package]] name = "zokrates_cli" -version = "0.8.2" +version = "0.8.3" dependencies = [ "assert_cli", "blake2 0.8.1", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "zokrates_core_test" -version = "0.2.8" +version = "0.2.9" dependencies = [ "zokrates_test", "zokrates_test_derive", @@ -3255,7 +3255,7 @@ dependencies = [ [[package]] name = "zokrates_js" -version = "1.1.3" +version = "1.1.4" dependencies = [ "console_error_panic_hook", "indexmap", @@ -3333,7 +3333,7 @@ dependencies = [ [[package]] name = "zokrates_stdlib" -version = "0.3.2" +version = "0.3.3" dependencies = [ "fs_extra", "zokrates_test", diff --git a/changelogs/unreleased/1224-dark64 b/changelogs/unreleased/1224-dark64 deleted file mode 100644 index 8977675b..00000000 --- a/changelogs/unreleased/1224-dark64 +++ /dev/null @@ -1 +0,0 @@ -Disallow the use of the `private` and `public` keywords on non-entrypoint functions \ No newline at end of file diff --git a/changelogs/unreleased/1226-schaeff b/changelogs/unreleased/1226-schaeff deleted file mode 100644 index ef2ac9b7..00000000 --- a/changelogs/unreleased/1226-schaeff +++ /dev/null @@ -1 +0,0 @@ -Fix duplicate constraint optimiser \ No newline at end of file diff --git a/changelogs/unreleased/1232-dark64 b/changelogs/unreleased/1232-dark64 new file mode 100644 index 00000000..86c554b4 --- /dev/null +++ b/changelogs/unreleased/1232-dark64 @@ -0,0 +1 @@ +Loosen up whitespace restrictions to allow more formatting styles \ No newline at end of file diff --git a/zokrates_ast/Cargo.toml b/zokrates_ast/Cargo.toml index 187e6a2d..a41269c2 100644 --- a/zokrates_ast/Cargo.toml +++ b/zokrates_ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_ast" -version = "0.1.2" +version = "0.1.3" edition = "2021" [features] diff --git a/zokrates_ast/src/untyped/from_ast.rs b/zokrates_ast/src/untyped/from_ast.rs index 25636fa2..df8b66ea 100644 --- a/zokrates_ast/src/untyped/from_ast.rs +++ b/zokrates_ast/src/untyped/from_ast.rs @@ -23,7 +23,7 @@ fn import_directive_to_symbol_vec( match import { pest::ImportDirective::Main(import) => { let span = import.span; - let source = Path::new(import.source.span.as_str()); + let source = Path::new(import.source.raw.span.as_str()); let id = "main"; let alias = import.alias.map(|a| a.span.as_str()); @@ -41,7 +41,7 @@ fn import_directive_to_symbol_vec( } pest::ImportDirective::From(import) => { let span = import.span; - let source = Path::new(import.source.span.as_str()); + let source = Path::new(import.source.raw.span.as_str()); import .symbols .into_iter() @@ -251,7 +251,7 @@ impl<'ast> From> for untyped::StatementNode<'ast> { .map(untyped::ExpressionNode::from) .collect(); - untyped::Statement::Log(statement.format_string.span.as_str(), expressions) + untyped::Statement::Log(statement.format_string.raw.span.as_str(), expressions) .span(statement.span) } } @@ -322,7 +322,7 @@ impl<'ast> From> for untyped::StatementNode<'ast> untyped::Statement::Assertion( untyped::ExpressionNode::from(statement.expression), - statement.message.map(|m| m.value), + statement.message.map(|m| m.raw.value), ) .span(statement.span) } diff --git a/zokrates_cli/Cargo.toml b/zokrates_cli/Cargo.toml index 81e9a747..0aa94633 100644 --- a/zokrates_cli/Cargo.toml +++ b/zokrates_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_cli" -version = "0.8.2" +version = "0.8.3" authors = ["Jacob Eberhardt ", "Dennis Kuhnert ", "Thibaut Schaeffer "] repository = "https://github.com/Zokrates/ZoKrates.git" edition = "2018" diff --git a/zokrates_core_test/Cargo.toml b/zokrates_core_test/Cargo.toml index cb0214bb..40c31f33 100644 --- a/zokrates_core_test/Cargo.toml +++ b/zokrates_core_test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_core_test" -version = "0.2.8" +version = "0.2.9" authors = ["schaeff "] edition = "2018" diff --git a/zokrates_core_test/tests/tests/whitespace.zok b/zokrates_core_test/tests/tests/whitespace.zok new file mode 100644 index 00000000..48368839 --- /dev/null +++ b/zokrates_core_test/tests/tests/whitespace.zok @@ -0,0 +1,21 @@ +from "field" import FIELD_MIN, + FIELD_MAX, + FIELD_SIZE_IN_BITS; + +struct Foo +{ + field a; + field b; +} + +def main( + private Foo foo, + field c +) -> bool +{ + field[2] arr = [ + foo.a, + foo.b + ]; + return arr[0] * arr[1] == c; +} \ No newline at end of file diff --git a/zokrates_js/Cargo.toml b/zokrates_js/Cargo.toml index 59b20e61..feb949d1 100644 --- a/zokrates_js/Cargo.toml +++ b/zokrates_js/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_js" -version = "1.1.3" +version = "1.1.4" authors = ["Darko Macesic"] edition = "2018" diff --git a/zokrates_js/package-lock.json b/zokrates_js/package-lock.json index 0754562f..b15cb706 100644 --- a/zokrates_js/package-lock.json +++ b/zokrates_js/package-lock.json @@ -1,6 +1,6 @@ { "name": "zokrates-js", - "version": "1.1.2", + "version": "1.1.4", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/zokrates_js/package.json b/zokrates_js/package.json index 6ddcb0c8..ce404bac 100644 --- a/zokrates_js/package.json +++ b/zokrates_js/package.json @@ -1,6 +1,6 @@ { "name": "zokrates-js", - "version": "1.1.3", + "version": "1.1.4", "module": "index.js", "main": "node/index.js", "description": "JavaScript bindings for ZoKrates", diff --git a/zokrates_parser/src/zokrates.pest b/zokrates_parser/src/zokrates.pest index d0319d13..f6ca4e43 100644 --- a/zokrates_parser/src/zokrates.pest +++ b/zokrates_parser/src/zokrates.pest @@ -1,12 +1,12 @@ -file = { SOI ~ NEWLINE* ~ pragma? ~ NEWLINE* ~ symbol_declaration* ~ EOI } +file = { SOI ~ pragma? ~ symbol_declaration* ~ EOI } pragma = { "#pragma" ~ "curve" ~ curve } curve = @{ (ASCII_ALPHANUMERIC | "_") * } string = @{(!"\"" ~ ANY)*} +quoted_string = ${ "\"" ~ string ~ "\"" } semicolon = _{";"} -quoted_string = _{ "\"" ~ string ~ "\"" } -symbol_declaration = { (((import_directive | const_definition | type_definition) ~ semicolon) | (ty_struct_definition | function_definition)) ~ NEWLINE* } +symbol_declaration = { (((import_directive | const_definition | type_definition) ~ semicolon) | (ty_struct_definition | function_definition)) } import_directive = { main_import_directive | from_import_directive } from_import_directive = { "from" ~ quoted_string ~ "import" ~ import_symbol_list } @@ -41,8 +41,8 @@ ty_tuple_multiple_inner = _{ ty ~ ("," ~ ty)+ ~ ","? } // structs ty_struct = { identifier ~ explicit_generics? } // type definitions -ty_struct_definition = { "struct" ~ identifier ~ constant_generics_declaration? ~ "{" ~ NEWLINE* ~ struct_field_list ~ NEWLINE* ~ "}" ~ NEWLINE* } -struct_field_list = _{ (struct_field ~ semicolon ~ NEWLINE*)* } +ty_struct_definition = { "struct" ~ identifier ~ constant_generics_declaration? ~ "{" ~ struct_field_list ~ "}" } +struct_field_list = _{ (struct_field ~ semicolon)* } struct_field = { typed_identifier } vis_private = {"private"} @@ -57,10 +57,10 @@ statement = { (iteration_statement | asm_statement // does not require semicolon |return_statement | definition_statement | assertion_statement - ) ~ semicolon)) ~ NEWLINE* } + ) ~ semicolon)) } log_statement = { "log" ~ "(" ~ quoted_string ~ "," ~ expression_list ~ ")"} -block_statement = _{ "{" ~ NEWLINE* ~ statement* ~ NEWLINE* ~ "}" } +block_statement = _{ "{" ~ statement* ~ "}" } iteration_statement = { "for" ~ typed_identifier ~ "in" ~ expression ~ ".." ~ expression ~ block_statement } return_statement = { "return" ~ expression? } definition_statement = { typed_identifier_or_assignee ~ "=" ~ expression } @@ -95,7 +95,7 @@ inline_tuple_empty_expression_inner = _{ "" } inline_tuple_single_expression_inner = _{ expression ~ "," } inline_tuple_multiple_expression_inner = _{ expression ~ ("," ~ expression)+ ~ ","? } -block_expression = _{ "{" ~ NEWLINE* ~ statement* ~ expression ~ NEWLINE* ~ "}" } +block_expression = _{ "{" ~ statement* ~ expression ~ "}" } if_else_expression = { "if" ~ expression ~ block_expression ~ "else" ~ block_expression } access = { array_access | call_access | dot_access } @@ -111,12 +111,12 @@ identifier_or_decimal = { identifier | decimal_number } primary_expression = { identifier | literal } -inline_struct_expression = { identifier ~ "{" ~ NEWLINE* ~ inline_struct_member_list ~ NEWLINE* ~ "}" } -inline_struct_member_list = _{(inline_struct_member ~ ("," ~ NEWLINE* ~ inline_struct_member)*)? ~ ","? } +inline_struct_expression = { identifier ~ "{" ~ inline_struct_member_list ~ "}" } +inline_struct_member_list = _{(inline_struct_member ~ ("," ~ inline_struct_member)*)? ~ ","? } inline_struct_member = { identifier ~ ":" ~ expression } -inline_array_expression = { "[" ~ NEWLINE* ~ inline_array_inner ~ NEWLINE* ~ "]" } -inline_array_inner = _{(spread_or_expression ~ ("," ~ NEWLINE* ~ spread_or_expression)*)?} +inline_array_expression = { "[" ~ inline_array_inner ~ "]" } +inline_array_inner = _{(spread_or_expression ~ ("," ~ spread_or_expression)*)?} spread_or_expression = { spread | expression } range_or_expression = { range | expression } @@ -183,7 +183,7 @@ op_ternary = {"?" ~ expression ~ ":"} op_binary = _ { op_or | op_and | op_bit_xor | op_bit_and | op_bit_or | op_left_shift | op_right_shift | op_equal | op_not_equal | op_lte | op_lt | op_gte | op_gt | op_add | op_sub | op_mul | op_div | op_rem | op_ternary } op_unary = { op_pos | op_neg | op_not } -WHITESPACE = _{ " " | "\t" | "\\" ~ COMMENT? ~ NEWLINE} +WHITESPACE = _{ " " | "\t" | "\\" | COMMENT | NEWLINE } COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ (!NEWLINE ~ ANY)*) } // the ordering of reserved keywords matters: if "as" is before "assert", then "assert" gets parsed as (as)(sert) and incorrectly diff --git a/zokrates_pest_ast/src/lib.rs b/zokrates_pest_ast/src/lib.rs index d58231ea..9f37a90b 100644 --- a/zokrates_pest_ast/src/lib.rs +++ b/zokrates_pest_ast/src/lib.rs @@ -212,7 +212,7 @@ mod ast { #[derive(Debug, FromPest, PartialEq, Eq, Clone)] #[pest_ast(rule(Rule::main_import_directive))] pub struct MainImportDirective<'ast> { - pub source: AnyString<'ast>, + pub source: QString<'ast>, pub alias: Option>, #[pest_ast(outer())] pub span: Span<'ast>, @@ -230,7 +230,7 @@ mod ast { #[derive(Debug, FromPest, PartialEq, Eq, Clone)] #[pest_ast(rule(Rule::from_import_directive))] pub struct FromImportDirective<'ast> { - pub source: AnyString<'ast>, + pub source: QString<'ast>, pub symbols: Vec>, #[pest_ast(outer())] pub span: Span<'ast>, @@ -373,7 +373,7 @@ mod ast { #[derive(Debug, FromPest, PartialEq, Clone)] #[pest_ast(rule(Rule::log_statement))] pub struct LogStatement<'ast> { - pub format_string: AnyString<'ast>, + pub format_string: QString<'ast>, pub expressions: Vec>, #[pest_ast(outer())] pub span: Span<'ast>, @@ -390,18 +390,26 @@ mod ast { #[derive(Debug, FromPest, PartialEq, Eq, Clone)] #[pest_ast(rule(Rule::string))] - pub struct AnyString<'ast> { + pub struct RawString<'ast> { #[pest_ast(outer(with(span_into_str)))] pub value: String, #[pest_ast(outer())] pub span: Span<'ast>, } + #[derive(Debug, FromPest, PartialEq, Eq, Clone)] + #[pest_ast(rule(Rule::quoted_string))] + pub struct QString<'ast> { + pub raw: RawString<'ast>, + #[pest_ast(outer())] + pub span: Span<'ast>, + } + #[derive(Debug, FromPest, PartialEq, Clone)] #[pest_ast(rule(Rule::assertion_statement))] pub struct AssertionStatement<'ast> { pub expression: Expression<'ast>, - pub message: Option>, + pub message: Option>, #[pest_ast(outer())] pub span: Span<'ast>, } @@ -1234,9 +1242,12 @@ mod tests { pragma: None, declarations: vec![ SymbolDeclaration::Import(ImportDirective::Main(MainImportDirective { - source: AnyString { - value: String::from("foo"), - span: Span::new(source, 17, 20).unwrap() + source: QString { + raw: RawString { + value: String::from("foo"), + span: Span::new(source, 17, 20).unwrap() + }, + span: Span::new(source, 16, 21).unwrap() }, alias: None, span: Span::new(source, 9, 21).unwrap() @@ -1299,9 +1310,12 @@ mod tests { pragma: None, declarations: vec![ SymbolDeclaration::Import(ImportDirective::Main(MainImportDirective { - source: AnyString { - value: String::from("foo"), - span: Span::new(source, 17, 20).unwrap() + source: QString { + raw: RawString { + value: String::from("foo"), + span: Span::new(source, 17, 20).unwrap() + }, + span: Span::new(source, 16, 21).unwrap() }, alias: None, span: Span::new(source, 9, 21).unwrap() @@ -1388,9 +1402,12 @@ mod tests { pragma: None, declarations: vec![ SymbolDeclaration::Import(ImportDirective::Main(MainImportDirective { - source: AnyString { - value: String::from("foo"), - span: Span::new(source, 17, 20).unwrap() + source: QString { + raw: RawString { + value: String::from("foo"), + span: Span::new(source, 17, 20).unwrap() + }, + span: Span::new(source, 16, 21).unwrap() }, alias: None, span: Span::new(source, 9, 21).unwrap() diff --git a/zokrates_stdlib/Cargo.toml b/zokrates_stdlib/Cargo.toml index d7099520..24763e3f 100644 --- a/zokrates_stdlib/Cargo.toml +++ b/zokrates_stdlib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_stdlib" -version = "0.3.2" +version = "0.3.3" authors = ["Stefan Deml ", "schaeff "] edition = "2018"