Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 0ad5448

Browse files
committed
minor updates, bump snark-verifier
1 parent 7bb4d86 commit 0ad5448

File tree

3 files changed

+32
-245
lines changed

3 files changed

+32
-245
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregator/src/aggregation/circuit.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::{
77
};
88
use ark_std::{end_timer, start_timer};
99
use halo2_base::{
10-
gates::GateInstructions, utils::fe_to_biguint, Context, ContextParams, QuantumCell::Existing,
10+
gates::{GateInstructions, RangeInstructions},
11+
Context, ContextParams,
12+
QuantumCell::Existing,
1113
};
1214

1315
use halo2_ecc::fields::FieldChip;
@@ -28,13 +30,15 @@ use std::rc::Rc;
2830
use std::{env, fs::File};
2931

3032
#[cfg(not(feature = "disable_proof_aggregation"))]
31-
use snark_verifier::loader::halo2::{halo2_ecc::halo2_base::AssignedValue, Halo2Loader};
33+
use snark_verifier::loader::halo2::{
34+
halo2_ecc::halo2_base::AssignedValue, Halo2Loader, IntegerInstructions,
35+
};
36+
use snark_verifier::pcs::kzg::KzgSuccinctVerifyingKey;
3237
#[cfg(not(feature = "disable_proof_aggregation"))]
3338
use snark_verifier::{
3439
loader::halo2::halo2_ecc::halo2_base,
3540
pcs::kzg::{Bdfg21, Kzg},
3641
};
37-
use snark_verifier::pcs::kzg::KzgSuccinctVerifyingKey;
3842
#[cfg(not(feature = "disable_proof_aggregation"))]
3943
use snark_verifier_sdk::{aggregate_hybrid, flatten_accumulator};
4044
use snark_verifier_sdk::{CircuitExt, Snark, SnarkWitness};
@@ -322,12 +326,18 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
322326
let transcript_init_state_halo2 = config
323327
.ecc_chip()
324328
.field_chip()
325-
.load_constant(&mut ctx, fe_to_biguint(&fixed_transcript_init_state_halo2));
329+
.range()
330+
.gate()
331+
.assign_constant(&mut ctx, fixed_transcript_init_state_halo2)
332+
.expect("IntegerInstructions::assign_constant infallible");
326333
log::debug!("load transcript OK");
327334
let transcript_init_state_sp1 = config
328335
.ecc_chip()
329336
.field_chip()
330-
.load_constant(&mut ctx, fe_to_biguint(&fixed_transcript_init_state_sp1));
337+
.range()
338+
.gate()
339+
.assign_constant(&mut ctx, fixed_transcript_init_state_sp1)
340+
.expect("IntegerInstructions::assign_constant infallible");
331341
log::info!("populating constants OK");
332342

333343
// Commitments to the preprocessed polynomials.
@@ -341,7 +351,6 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
341351
.zip_eq(preprocessed_polys_halo2.iter())
342352
.zip_eq(preprocessed_polys_sp1.iter())
343353
{
344-
let commitment = commitment.clone().into_assigned();
345354
let check_1 =
346355
config
347356
.ecc_chip()
@@ -370,11 +379,9 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
370379
}
371380

372381
// Transcript initial state.
373-
/*
374382
for transcript_init_state in transcript_init_states {
375383
let transcript_init_state = transcript_init_state
376-
.expect("SNARK should have an initial state for transcript")
377-
.into_assigned();
384+
.expect("SNARK should have an initial state for transcript");
378385
let transcript_check_1 = config.flex_gate().is_equal(
379386
&mut ctx,
380387
Existing(transcript_init_state),
@@ -394,7 +401,6 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
394401
.flex_gate()
395402
.assert_is_const(&mut ctx, &transcript_check, Fr::ONE);
396403
}
397-
*/
398404

399405
// extract the following cells for later constraints
400406
// - the accumulators

aggregator/src/constants.rs

Lines changed: 14 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use halo2_proofs::halo2curves::bn256::{Fq, Fr, G1Affine};
1+
use halo2_proofs::halo2curves::bn256::{Fr, G1Affine};
22
use std::sync::LazyLock;
33

44
// A chain_id is u64 and uses 8 bytes
@@ -89,6 +89,14 @@ pub(crate) const BITS: usize = 88;
8989
/// will be padded.
9090
pub const MAX_AGG_SNARKS: usize = 45;
9191

92+
/// Alias for a list of G1 points.
93+
type PreprocessedPolyCommits = Vec<G1Affine>;
94+
/// Alias for the transcript's initial state.
95+
type TranscriptInitState = Fr;
96+
/// Alias for the fixed part of the protocol which consists of the commitments to the preprocessed
97+
/// polynomials and the initial state of the transcript.
98+
type FixedProtocol = (PreprocessedPolyCommits, TranscriptInitState);
99+
92100
/// The [`Batch Circuit`] supports aggregation of up to [`MAX_AGG_SNARKS`] SNARKs, where either
93101
/// SNARK is of 2 kinds, namely:
94102
///
@@ -99,11 +107,8 @@ pub const MAX_AGG_SNARKS: usize = 45;
99107
/// preprocessed polynomials and the transcript's initial state belong to a fixed set, one
100108
/// belonging to each of the above SNARK kinds.
101109
///
102-
/// Represents the fixed commitments to the preprocessed polynomials for [`ChunkKind::Halo2`].
103-
pub type PreprocessedPolyCommits = Vec<G1Affine>;
104-
pub type TranscriptInitState = Fr;
105-
pub type FixedProtocol = (PreprocessedPolyCommits, TranscriptInitState);
106-
110+
/// Represents the fixed commitments to the preprocessed polynomials and the initial state of the
111+
/// transcript for [`ChunkKind::Halo2`].
107112
pub static FIXED_PROTOCOL_HALO2: LazyLock<FixedProtocol> = LazyLock::new(|| {
108113
let name =
109114
std::env::var("HALO2_CHUNK_PROTOCOL").unwrap_or("chunk_chunk_halo2.protocol".to_string());
@@ -121,6 +126,9 @@ pub static FIXED_PROTOCOL_HALO2: LazyLock<FixedProtocol> = LazyLock::new(|| {
121126
.expect("transcript initial state is None"),
122127
)
123128
});
129+
130+
/// Represents the fixed commitments to the preprocessed polynomials and the initial state of the
131+
/// transcript for [`ChunkKind::Sp1`].
124132
pub static FIXED_PROTOCOL_SP1: LazyLock<FixedProtocol> = LazyLock::new(|| {
125133
let name =
126134
std::env::var("SP1_CHUNK_PROTOCOL").unwrap_or("chunk_chunk_sp1.protocol".to_string());
@@ -138,230 +146,3 @@ pub static FIXED_PROTOCOL_SP1: LazyLock<FixedProtocol> = LazyLock::new(|| {
138146
.expect("transcript initial state is None"),
139147
)
140148
});
141-
142-
pub static PREPROCESSED_POLYS_HALO2: LazyLock<Vec<G1Affine>> = LazyLock::new(|| {
143-
vec![
144-
G1Affine {
145-
x: Fq::from_raw([
146-
4541478842587617678,
147-
7188475718571567728,
148-
239378696823010373,
149-
179342154257362491,
150-
]),
151-
y: Fq::from_raw([
152-
2102960765482384605,
153-
18163083796572731063,
154-
17943480866217266774,
155-
85103875006328896,
156-
]),
157-
},
158-
G1Affine {
159-
x: Fq::from_raw([
160-
4093061539863783111,
161-
194291308596025748,
162-
11369022891089479442,
163-
1463255879024205618,
164-
]),
165-
y: Fq::from_raw([
166-
16700532425791245072,
167-
7378851796565816368,
168-
17346566642486298786,
169-
970075911594951367,
170-
]),
171-
},
172-
G1Affine {
173-
x: Fq::from_raw([
174-
6315321914675870134,
175-
1582860689439567350,
176-
15739400164232855740,
177-
1223439486676386684,
178-
]),
179-
y: Fq::from_raw([
180-
13096458462745381806,
181-
11924041770036958177,
182-
12977682459629830027,
183-
1912305792904139855,
184-
]),
185-
},
186-
G1Affine {
187-
x: Fq::from_raw([
188-
408389462232057354,
189-
10888945426883186814,
190-
9738219244958428216,
191-
3343776552242400005,
192-
]),
193-
y: Fq::from_raw([
194-
2204271371398632469,
195-
3229396059398198493,
196-
15594587291868236687,
197-
1533897200726072018,
198-
]),
199-
},
200-
G1Affine {
201-
x: Fq::from_raw([
202-
14778744839025706557,
203-
7305439111399726684,
204-
14617960481571289161,
205-
2468165792866445337,
206-
]),
207-
y: Fq::from_raw([
208-
15298503060320124348,
209-
16948478742631860463,
210-
10983004142833888255,
211-
70418435200471011,
212-
]),
213-
},
214-
G1Affine {
215-
x: Fq::from_raw([
216-
10682202061899776328,
217-
12746133157404224107,
218-
10194303803070492548,
219-
3314924930376820519,
220-
]),
221-
y: Fq::from_raw([
222-
10891118471780302094,
223-
7166241992404117528,
224-
6263062724619736264,
225-
340188705380829494,
226-
]),
227-
},
228-
G1Affine {
229-
x: Fq::from_raw([
230-
9240035288364311447,
231-
16941312289372401027,
232-
15915874119483357666,
233-
2647144763697367565,
234-
]),
235-
y: Fq::from_raw([
236-
11086173928117658245,
237-
3518116464318723439,
238-
13832518766777794466,
239-
2351978436917361063,
240-
]),
241-
},
242-
]
243-
});
244-
245-
/// Represents the fixed commitments to the preprocessed polynomials for [`ChunkKind::Sp1`].
246-
pub static PREPROCESSED_POLYS_SP1: LazyLock<Vec<G1Affine>> = LazyLock::new(|| {
247-
vec![
248-
G1Affine {
249-
x: Fq::from_raw([
250-
4541478842587617678,
251-
7188475718571567728,
252-
239378696823010373,
253-
179342154257362491,
254-
]),
255-
y: Fq::from_raw([
256-
2102960765482384605,
257-
18163083796572731063,
258-
17943480866217266774,
259-
85103875006328896,
260-
]),
261-
},
262-
G1Affine {
263-
x: Fq::from_raw([
264-
14482602916982982999,
265-
2357100016965177442,
266-
18431616353722806990,
267-
1632384859399911320,
268-
]),
269-
y: Fq::from_raw([
270-
9341870623509249436,
271-
10625117674485803345,
272-
11602556742997327241,
273-
588490870283709105,
274-
]),
275-
},
276-
G1Affine {
277-
x: Fq::from_raw([
278-
1695984461415246698,
279-
16627531726212442277,
280-
7436715082446168910,
281-
1334937499741146447,
282-
]),
283-
y: Fq::from_raw([
284-
10378694966954049300,
285-
14869436676005235944,
286-
8183056858201575129,
287-
2775754316985040075,
288-
]),
289-
},
290-
G1Affine {
291-
x: Fq::from_raw([
292-
10696015357775661092,
293-
16365831078551355495,
294-
6432053641301558040,
295-
3332063291233986333,
296-
]),
297-
y: Fq::from_raw([
298-
15981342105615776301,
299-
12342977772828558934,
300-
12118653449154188133,
301-
528988368198712851,
302-
]),
303-
},
304-
G1Affine {
305-
x: Fq::from_raw([
306-
4303830904018986544,
307-
12892574281015932006,
308-
12553056811812850723,
309-
3211210156168296116,
310-
]),
311-
y: Fq::from_raw([
312-
4036545931324298107,
313-
7599907392816691312,
314-
15293245440448741876,
315-
212143551489911410,
316-
]),
317-
},
318-
G1Affine {
319-
x: Fq::from_raw([
320-
10931155675221794876,
321-
4312691987032924781,
322-
9804797475001633245,
323-
3451890802936893314,
324-
]),
325-
y: Fq::from_raw([
326-
11180962733343570413,
327-
10484712170183330434,
328-
14444948151863902680,
329-
2123487521383807780,
330-
]),
331-
},
332-
G1Affine {
333-
x: Fq::from_raw([
334-
1814367689437931729,
335-
8489483461414090990,
336-
10000388380055359653,
337-
1286074470617787276,
338-
]),
339-
y: Fq::from_raw([
340-
7726546312100213647,
341-
1034780786427294399,
342-
6531068821869198065,
343-
517274402271116562,
344-
]),
345-
},
346-
]
347-
});
348-
349-
/// Represents the initial state of the transcript for [`ChunkKind::Halo2`].
350-
pub static TRANSCRIPT_INIT_STATE_HALO2: LazyLock<Fr> = LazyLock::new(|| {
351-
Fr::from_raw([
352-
3505826241380660566,
353-
11473746322117040456,
354-
14075887197298535585,
355-
1737617936020314372,
356-
])
357-
});
358-
359-
/// Represents the initial state of the transcript for [`ChunkKind::Sp1`].
360-
pub static TRANSCRIPT_INIT_STATE_SP1: LazyLock<Fr> = LazyLock::new(|| {
361-
Fr::from_raw([
362-
1678899198020618715,
363-
10231258143962228858,
364-
12365017456265435574,
365-
841984517048583699,
366-
])
367-
});

0 commit comments

Comments
 (0)