Skip to content

Commit

Permalink
merge branch 'willem/rotate-input-encoder-solidity' of github.com:Cha…
Browse files Browse the repository at this point in the history
…inSafe/Spectre into willem/rotate-input-encoder-solidity
  • Loading branch information
willemolding committed Oct 17, 2023
2 parents 29e12bd + 4512053 commit 1ac13f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions lightclient-circuits/src/committee_update_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl<S: Spec, F: Field> CommitteeUpdateCircuit<S, F> {
[(); { S::SYNC_COMMITTEE_SIZE }]:,
{
let pubkeys_x = args.pubkeys_compressed.iter().cloned().map(|mut bytes| {
bytes.reverse();
bytes[47] &= 0b00011111;
bls12_381::Fq::from_bytes_le(&bytes)
});
Expand Down
30 changes: 16 additions & 14 deletions lightclient-circuits/tests/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use ethereum_consensus_types::signing::{compute_domain, DomainType};
use ethereum_consensus_types::{ForkData, Root};
use halo2_base::gates::builder::CircuitBuilderStage;
use halo2_proofs::dev::MockProver;
use halo2curves::bn256::{self, Fr};
use halo2curves::bls12_381;
use halo2curves::bn256::{self, Fr};
use itertools::Itertools;
use light_client_verifier::ZiplineUpdateWitnessCapella;
use lightclient_circuits::committee_update_circuit::CommitteeUpdateCircuit;
Expand Down Expand Up @@ -364,11 +364,7 @@ fn read_test_files_and_gen_witness(
.next_sync_committee
.aggregate_pubkey
.to_bytes()
.iter()
// Reverse bytes because of endieness
.copied()
.rev()
.collect_vec();
.to_vec();

let mut agg_pk: ByteVector<48> = ByteVector(Vector::try_from(agg_pubkeys_compressed).unwrap());

Expand All @@ -381,10 +377,7 @@ fn read_test_files_and_gen_witness(
.pubkeys
.iter()
.cloned()
.map(|pk| {
// Reverse bytes because of endieness
pk.to_bytes().iter().copied().rev().collect_vec()
})
.map(|pk| pk.to_bytes().to_vec())
.collect_vec(),
randomness: crypto::constant_randomness(),
_spec: Default::default(),
Expand Down Expand Up @@ -667,8 +660,18 @@ mod solidity_tests {
[(); Spec::SYNC_COMMITTEE_SIZE]:,
{
fn from(args: CommitteeRotationArgs<Spec, Fr>) -> Self {
let poseidon_commitment_le =
poseidon_committee_commitment_from_compressed(&args.pubkeys_compressed).unwrap();
let poseidon_commitment_le = poseidon_committee_commitment_from_compressed(
&args
.pubkeys_compressed
.iter()
.cloned()
.map(|mut b| {
b.reverse();
b
})
.collect_vec(),
)
.unwrap();

let mut pk_vector: Vector<Vector<u8, 48>, { Spec::SYNC_COMMITTEE_SIZE }> = args
.pubkeys_compressed
Expand Down Expand Up @@ -718,8 +721,7 @@ mod solidity_tests {
bytes[47] &= 0b00011111;
bls12_381::Fq::from_bytes_le(&bytes)
});
let poseidon_commitment =
fq_array_poseidon_native::<bn256::Fr>(pubkeys_x).unwrap();
let poseidon_commitment = fq_array_poseidon_native::<bn256::Fr>(pubkeys_x).unwrap();
Ok(poseidon_commitment.to_bytes_le().try_into().unwrap())
}

Expand Down

0 comments on commit 1ac13f0

Please sign in to comment.