Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: codegen for multiple public input columns #61

Merged
merged 14 commits into from
May 28, 2024
25 changes: 17 additions & 8 deletions bberg/src/verifier_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,29 @@ impl VerifierBuilder for BBFiles {
};

let verify_proof_function_declaration: String = if has_public_input_columns {
format!("bool {name}Verifier::verify_proof(const HonkProof& proof, const std::vector<FF>& public_inputs)")
format!("bool {name}Verifier::verify_proof(const HonkProof& proof, const std::vector<std::vector<FF>>& public_inputs)")
} else {
format!("bool {name}Verifier::verify_proof(const HonkProof& proof)")
};

let (public_inputs_check, evaluate_public_inputs) = if has_public_input_columns {
let public_inputs_column = public_cols[0].clone(); // asserted to be 1 for the meantime, this will be generalized when required
let inputs_check = format!(
let public_inputs_column_transformation = |public_inputs_column_name: &String, i: usize| {
format!(
"
FF public_column_evaluation = evaluate_public_input_column(public_inputs, circuit_size, multivariate_challenge);
if (public_column_evaluation != claimed_evaluations.{public_inputs_column}) {{
FF {public_inputs_column_name}_evaluation = evaluate_public_input_column(public_inputs[{i}], circuit_size, multivariate_challenge);
if ({public_inputs_column_name}_evaluation != claimed_evaluations.{public_inputs_column_name}) {{
return false;
}}
"
);
)
};

let (public_inputs_check, evaluate_public_inputs) = if has_public_input_columns {
let inputs_check = public_cols
.iter()
.enumerate()
.map(|(i, col_name)| public_inputs_column_transformation(col_name, i))
.collect::<String>();

Maddiaa0 marked this conversation as resolved.
Show resolved Hide resolved
let evaluate_public_inputs = format!(
"

Expand Down Expand Up @@ -168,6 +176,7 @@ impl VerifierBuilder for BBFiles {
return false;
}}

// Public columns evaluation checks
{public_inputs_check}

// Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the
Expand Down Expand Up @@ -203,7 +212,7 @@ impl VerifierBuilder for BBFiles {

// If there are public input columns, then the generated verifier must take them in as an argument for the verify_proof
let verify_proof = if !public_cols.is_empty() {
"bool verify_proof(const HonkProof& proof, const std::vector<FF>& public_inputs);"
"bool verify_proof(const HonkProof& proof, const std::vector<std::vector<FF>>& public_inputs);"
.to_string()
} else {
"bool verify_proof(const HonkProof& proof);".to_owned()
Expand Down
5 changes: 0 additions & 5 deletions bberg/src/vm_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use ast::analyzed::Analyzed;

use itertools::Itertools;
use number::FieldElement;

use crate::circuit_builder::CircuitBuilder;
Expand Down Expand Up @@ -217,9 +216,5 @@ pub fn extract_public_input_columns(witness_columns: Vec<String>) -> (Vec<String
.filter(|name| name.ends_with("__is_public"))
.collect();

assert!(
public_input_column_names.len() <= 1,
"There should only be one public input column (for now)"
);
(witness_names, public_input_column_names)
}
Loading