1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

Merge pull request #1226 from Zokrates/ignore-error-message-in-hash

Fix duplicate optimiser
This commit is contained in:
Thibaut Schaeffer 2022-09-19 17:53:03 +02:00 committed by GitHub
commit 29bfcac860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 8 deletions

3
Cargo.lock generated
View file

@ -3031,6 +3031,7 @@ dependencies = [
"ark-bls12-377",
"cfg-if 0.1.10",
"csv",
"derivative",
"num-bigint 0.2.6",
"pairing_ce",
"serde",
@ -3215,7 +3216,7 @@ dependencies = [
[[package]]
name = "zokrates_js"
version = "1.1.2"
version = "1.1.3"
dependencies = [
"console_error_panic_hook",
"indexmap",

View file

@ -0,0 +1 @@
Fix duplicate constraint optimiser

View file

@ -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"

View file

@ -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;
@ -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>>)>),
}
@ -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,

View file

@ -0,0 +1,6 @@
{
"entry_point": "./tests/tests/duplicate.zok",
"max_constraint_count": 1,
"curves": ["Bn128"],
"tests": []
}

View file

@ -0,0 +1,4 @@
def main(field a) {
assert(a == 0);
assert(a == 0);
}