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

[Preview - historical] Frontend-Backend split #243

Merged
merged 32 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb5d1aa
Reimplement keygen_vk for fe-be split as keygen_vk_v2
ed255 Dec 13, 2023
d318a9d
Reimplement keygen_pk for fe-be split as keygen_pk_v2
ed255 Dec 13, 2023
a601925
WIP: ProverV2 implementation
ed255 Dec 13, 2023
4510059
WIP
ed255 Dec 14, 2023
1b35fab
Complete create_proof refactor for fe-be split
ed255 Dec 14, 2023
50e7354
Make new prover methods work with multi-instance
ed255 Dec 15, 2023
98759c3
Get queires for proving
ed255 Dec 15, 2023
9ee0ced
Port verify_proof to fe-be split
ed255 Dec 15, 2023
013e6d4
Add sample circuit for testing
ed255 Dec 27, 2023
50fb46a
Make progress on testing fe-be split
ed255 Dec 28, 2023
a8a2009
Add witness calculator
ed255 Dec 29, 2023
c272378
Full flow, but verification fails
ed255 Dec 29, 2023
6037910
WIP
ed255 Jan 2, 2024
19298c2
Get it working
ed255 Jan 3, 2024
0ebdc59
Clean up
ed255 Jan 3, 2024
96ea944
Clean up
ed255 Jan 3, 2024
bfc5d86
Clean up
ed255 Jan 3, 2024
8495457
Benchmark
ed255 Jan 3, 2024
c412223
Merge branch 'main' into feature/frontend-backend
ed255 Jan 4, 2024
568b0e5
WIP
ed255 Jan 4, 2024
ca9d052
Make legacy wrappers over v2
ed255 Jan 4, 2024
8813ef7
Remove old API in favour of legacy wrappers
ed255 Jan 5, 2024
86ef75f
Fix test
ed255 Jan 5, 2024
58c9567
Address some clippy warnings
ed255 Jan 5, 2024
1bc84ca
Fix pinned vk test
ed255 Jan 5, 2024
582d6d5
Remove Polynomial from backend interface
ed255 Jan 9, 2024
a3ecfba
Clean up
ed255 Jan 10, 2024
d3e2543
Merge branch 'main' into feature/frontend-backend
ed255 Jan 11, 2024
d350e72
Address some of the review comments from @CPerezz
ed255 Jan 15, 2024
2c50b39
Simplify Backend gate type
ed255 Jan 16, 2024
c71fbfa
Document some types
ed255 Jan 16, 2024
20c16dd
Split collect_queries function
ed255 Jan 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ criterion = "0.3"
gumdrop = "0.8"
proptest = "1"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
dhat = "0.3.2"
serde_json = "1"

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
Expand All @@ -94,6 +95,7 @@ thread-safe-region = []
sanity-checks = []
batch = ["rand_core/getrandom"]
circuit-params = []
heap-profiling = []
cost-estimator = ["serde", "serde_derive"]
derive_serde = ["halo2curves/derive_serde"]

Expand Down
61 changes: 60 additions & 1 deletion halo2_proofs/src/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::helpers::{
};
use crate::poly::{
Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, PinnedEvaluationDomain,
Polynomial,
Polynomial, Rotation,
};
use crate::transcript::{ChallengeScalar, EncodedChallenge, Transcript};
use crate::SerdeFormat;
Expand Down Expand Up @@ -43,6 +43,64 @@ pub use verifier::*;
use evaluation::Evaluator;
use std::io;

/// List of queries (columns and rotations) used by a circuit
#[derive(Debug, Clone)]
pub struct Queries {
/// List of unique advice queries
pub advice: Vec<(Column<Advice>, Rotation)>,
/// List of unique instance queries
pub instance: Vec<(Column<Instance>, Rotation)>,
/// List of unique fixed queries
pub fixed: Vec<(Column<Fixed>, Rotation)>,
/// Contains an integer for each advice column
/// identifying how many distinct queries it has
/// so far; should be same length as cs.num_advice_columns.
pub num_advice_queries: Vec<usize>,
}

impl Queries {
/// Returns the minimum necessary rows that need to exist in order to
/// account for e.g. blinding factors.
pub fn minimum_rows(&self) -> usize {
self.blinding_factors() // m blinding factors
+ 1 // for l_{-(m + 1)} (l_last)
+ 1 // for l_0 (just for extra breathing room for the permutation
// argument, to essentially force a separation in the
// permutation polynomial between the roles of l_last, l_0
// and the interstitial values.)
+ 1 // for at least one row
}

/// Compute the number of blinding factors necessary to perfectly blind
/// each of the prover's witness polynomials.
pub fn blinding_factors(&self) -> usize {
// All of the prover's advice columns are evaluated at no more than
let factors = *self.num_advice_queries.iter().max().unwrap_or(&1);
// distinct points during gate checks.

// - The permutation argument witness polynomials are evaluated at most 3 times.
// - Each lookup argument has independent witness polynomials, and they are
// evaluated at most 2 times.
let factors = std::cmp::max(3, factors);

// Each polynomial is evaluated at most an additional time during
// multiopen (at x_3 to produce q_evals):
let factors = factors + 1;

// h(x) is derived by the other evaluations so it does not reveal
// anything; in fact it does not even appear in the proof.

// h(x_3) is also not revealed; the verifier only learns a single
// evaluation of a polynomial in x_1 which has h(x_3) and another random
// polynomial evaluated at x_3 as coefficients -- this random polynomial
// is "random_poly" in the vanishing argument.

// Add an additional blinding factor as a slight defense against
// off-by-one errors.
factors + 1
}
}

/// This is a verifying key which allows for the verification of proofs for a
/// particular circuit.
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -331,6 +389,7 @@ pub struct PinnedVerificationKey<'a, C: CurveAffine> {
fixed_commitments: &'a Vec<C>,
permutation: &'a permutation::VerifyingKey<C>,
}

/// This is a proving key which allows for the creation of proofs for a
/// particular circuit.
#[derive(Clone, Debug)]
Expand Down
Loading
Loading