Skip to content

Commit

Permalink
Merge branch 'main' into gr@verify-api-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guorong009 committed Sep 26, 2024
2 parents 7e27637 + 81c7058 commit c4bfe60
Show file tree
Hide file tree
Showing 11 changed files with 1,067 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Cargo.lock
.DS_Store

layout.png
serialization-test.pk
serialization-example.vk
serialization-example.pk
44 changes: 44 additions & 0 deletions halo2_backend/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,47 @@ fn shuffle_argument_required_degree<F: Field, V: Variable>(arg: &shuffle::Argume
// (1 - (l_last + l_blind)) (z(\omega X) (s(X) + \gamma) - z(X) (a(X) + \gamma))
std::cmp::max(2 + shuffle_degree, 2 + input_degree)
}

#[cfg(test)]
mod tests {
use super::ExpressionBack;
use halo2curves::bn256::Fr;

#[test]
fn expressionback_iter_sum() {
let exprs: Vec<ExpressionBack<Fr>> = vec![
ExpressionBack::Constant(1.into()),
ExpressionBack::Constant(2.into()),
ExpressionBack::Constant(3.into()),
];
let happened: ExpressionBack<Fr> = exprs.into_iter().sum();
let expected: ExpressionBack<Fr> = ExpressionBack::Sum(
Box::new(ExpressionBack::Sum(
Box::new(ExpressionBack::Constant(1.into())),
Box::new(ExpressionBack::Constant(2.into())),
)),
Box::new(ExpressionBack::Constant(3.into())),
);

assert_eq!(happened, expected);
}

#[test]
fn expressionback_iter_product() {
let exprs: Vec<ExpressionBack<Fr>> = vec![
ExpressionBack::Constant(1.into()),
ExpressionBack::Constant(2.into()),
ExpressionBack::Constant(3.into()),
];
let happened: ExpressionBack<Fr> = exprs.into_iter().product();
let expected: ExpressionBack<Fr> = ExpressionBack::Product(
Box::new(ExpressionBack::Product(
Box::new(ExpressionBack::Constant(1.into())),
Box::new(ExpressionBack::Constant(2.into())),
)),
Box::new(ExpressionBack::Constant(3.into())),
);

assert_eq!(happened, expected);
}
}
3 changes: 3 additions & 0 deletions halo2_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ tabbycat = { version = "0.1", features = ["attributes"], optional = true }
proptest = "1"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
serde_json = "1"
tracing-subscriber = { version = "0.3" }
tracing = "0.1"
tracing-capture = "0.1"

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }
Expand Down
8 changes: 7 additions & 1 deletion halo2_frontend/src/dev/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ mod tests {
Ok(())
}
}
CircuitCost::<Eq, MyCircuit>::measure(K, &MyCircuit).proof_size(1);
let cost = CircuitCost::<Eq, MyCircuit>::measure(K, &MyCircuit);

let marginal_proof_size = cost.marginal_proof_size();
assert_eq!(usize::from(marginal_proof_size), 0);

let proof_size = cost.proof_size(1);
assert_eq!(usize::from(proof_size), 608);
}
}
Loading

0 comments on commit c4bfe60

Please sign in to comment.