Skip to content

Commit 7eacce0

Browse files
committed
hotfix: poseidon commitment calculation
+ fix: aggregation circuit pinning
1 parent f9d3e5f commit 7eacce0

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

lightclient-circuits/src/aggregation_circuit.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use snark_verifier_sdk::{
1616
halo2::aggregation::{AggregationCircuit, AggregationConfigParams},
1717
Snark, SHPLONK,
1818
};
19-
use std::{fs::File, path::Path};
19+
use std::{env::var, fs::File, path::Path};
2020

2121
/// Configuration for the aggregation circuit.
2222
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
@@ -104,10 +104,20 @@ impl AppCircuit for AggregationCircuit {
104104
// We assume that `AggregationCircuit` will only be used for a single aggregation/compression layer.
105105
circuit.expose_previous_instances(false);
106106

107-
if matches!(stage, CircuitBuilderStage::Prover) {
108-
circuit.set_params(circuit_params);
109-
circuit.set_break_points(pinning.map_or(vec![], |p| p.break_points));
110-
};
107+
match stage {
108+
CircuitBuilderStage::Prover => {
109+
circuit.set_params(circuit_params);
110+
circuit.set_break_points(pinning.map_or(vec![], |p| p.break_points));
111+
}
112+
_ => {
113+
circuit.calculate_params(Some(
114+
var("MINIMUM_ROWS")
115+
.unwrap_or_else(|_| "0".to_string())
116+
.parse()
117+
.unwrap(),
118+
));
119+
}
120+
}
111121

112122
Ok(circuit)
113123
}

lightclient-circuits/src/gadget/crypto/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Code: https://github.com/ChainSafe/Spectre
33
// SPDX-License-Identifier: LGPL-3.0-only
44

5-
use crate::util::{CommonGateManager, Eth2ConfigPinning, GateBuilderConfig, Halo2ConfigPinning, PinnableCircuit};
5+
use crate::util::{
6+
CommonGateManager, Eth2ConfigPinning, GateBuilderConfig, Halo2ConfigPinning, PinnableCircuit,
7+
};
68
use eth_types::Field;
79
use getset::Getters;
810
use halo2_base::{

lightclient-circuits/src/ssz_merkle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn ssz_merkleize_chunks<F: Field, CircuitBuilder: CommonCircuitBuilder<F>>(
4242
} else {
4343
chunks.len().next_power_of_two().ilog2() as usize
4444
};
45-
45+
4646
for depth in 0..height {
4747
// Pad to even length using 32 zero bytes assigned as constants.
4848
let len_even = chunks.len() + chunks.len() % 2;

prover/src/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::{ops::Deref, sync::Arc};
66

77
use beacon_api_client::{BlockId, VersionedValue};
8-
use eth_types::NUM_LIMBS;
8+
use eth_types::LIMB_BITS;
99
use ethereum_consensus_types::LightClientBootstrap;
1010
use itertools::Itertools;
1111
use lightclient_circuits::poseidon::poseidon_committee_commitment_from_uncompressed;
@@ -56,7 +56,7 @@ pub(crate) async fn utils_cli(method: UtilsCmd) -> eyre::Result<()> {
5656
println!("SSZ root: {:?}", hex::encode(ssz_root.deref()));
5757

5858
let mut committee_poseidon =
59-
poseidon_committee_commitment_from_uncompressed(&pubkeys_uncompressed, NUM_LIMBS)
59+
poseidon_committee_commitment_from_uncompressed(&pubkeys_uncompressed, LIMB_BITS)
6060
.to_bytes();
6161
committee_poseidon.reverse();
6262
println!("Poseidon commitment: {}", hex::encode(committee_poseidon));

0 commit comments

Comments
 (0)