Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 32 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serde_json = { version = "1.0.105", features = [
borsh = { version = "1.5.5", features = ["derive"], default-features = false }
itertools = { version = "0.14", default-features = false }
sp1-zkvm = "5.0.0"
sp1-sdk = { version = "5.0.0", features = ["native-gnark"] }
sp1-sdk = { version = "5.0.6", features = ["native-gnark"] }
sp1-verifier = "5.0.0"

# alloy
Expand Down
2 changes: 1 addition & 1 deletion crates/integrations/sp1-helios/circuit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ sp1-verifier.workspace = true
borsh.workspace = true
helios-recursion-types.workspace = true
alloy-sol-types.workspace = true
alloy-primitives.workspace = true
sp1-helios-primitives.workspace = true
beacon-electra.workspace = true
ssz_rs = "0.9.0"
18 changes: 14 additions & 4 deletions crates/integrations/sp1-helios/circuit/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#![no_main]
sp1_zkvm::entrypoint!(main);
use alloy_primitives::U256;
use alloy_sol_types::SolValue;
use beacon_electra::merkleize_header;
use helios_recursion_types::{RecursionCircuitInputs, RecursionCircuitOutputs};
Expand Down Expand Up @@ -114,9 +115,11 @@ fn get_helios_outputs(
if recursive_proof_outputs.is_some() {
let recursive_proof_outputs =
recursive_proof_outputs.expect("Failed to unwrap recursive proof outputs");
if helios_output.prevSyncCommitteeHash != recursive_proof_outputs.active_committee
&& helios_output.prevSyncCommitteeHash != recursive_proof_outputs.previous_committee
{

// the new head must be greater than the previous head
assert!(helios_output.prevHead < helios_output.newHead);

if helios_output.prevSyncCommitteeHash != recursive_proof_outputs.active_committee {
panic!("Sync committee mismatch!");
}
}
Expand All @@ -134,7 +137,14 @@ fn get_helios_outputs(
.try_into()
.expect("Failed to unwrap recursive proof outputs"),
root: state_root.to_vec().try_into().unwrap(),
height: ssz_rs::deserialize::<u64>(height).expect("Failed to deserialize block number"),
height: unpad_block_number(height),
vk: recursive_proof_inputs.recursive_vk.clone(),
}
}

// the block height leaf in the merkle tree was padded to 32 bytes, so we need to unpad it
fn unpad_block_number(padded: &[u8; 32]) -> u64 {
let mut bytes = [0u8; 8];
bytes.copy_from_slice(&padded[..8]);
u64::from_le_bytes(bytes)
}
18 changes: 14 additions & 4 deletions crates/integrations/sp1-helios/circuit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#![no_main]
sp1_zkvm::entrypoint!(main);
use alloy_primitives::U256;
use alloy_sol_types::SolValue;
use beacon_electra::merkleize_header;
use helios_recursion_types::{RecursionCircuitInputs, RecursionCircuitOutputs};
Expand Down Expand Up @@ -114,9 +115,11 @@ fn get_helios_outputs(
if recursive_proof_outputs.is_some() {
let recursive_proof_outputs =
recursive_proof_outputs.expect("Failed to unwrap recursive proof outputs");
if helios_output.prevSyncCommitteeHash != recursive_proof_outputs.active_committee
&& helios_output.prevSyncCommitteeHash != recursive_proof_outputs.previous_committee
{

// the new head must be greater than the previous head
assert!(helios_output.prevHead < helios_output.newHead);

if helios_output.prevSyncCommitteeHash != recursive_proof_outputs.active_committee {
panic!("Sync committee mismatch!");
}
}
Expand All @@ -134,7 +137,14 @@ fn get_helios_outputs(
.try_into()
.expect("Failed to unwrap recursive proof outputs"),
root: state_root.to_vec().try_into().unwrap(),
height: ssz_rs::deserialize::<u64>(height).expect("Failed to deserialize block number"),
height: unpad_block_number(height),
vk: recursive_proof_inputs.recursive_vk.clone(),
}
}

// the block height leaf in the merkle tree was padded to 32 bytes, so we need to unpad it
fn unpad_block_number(padded: &[u8; 32]) -> u64 {
let mut bytes = [0u8; 8];
bytes.copy_from_slice(&padded[..8]);
u64::from_le_bytes(bytes)
}
2 changes: 1 addition & 1 deletion crates/integrations/sp1-helios/wrapper-circuit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use helios_recursion_types::{
};
use sp1_verifier::Groth16Verifier;

const RECURSIVE_VK: &str = "0x007e6a423d4e8cdb5d4307fc04f0caec22af32a2b59e7ad34bd011542c0ab30a";
const RECURSIVE_VK: &str = "0x0034e4a559df3be8975c94d57857e1e6fbfc4d26177b8f60ccd2dd86e75fd8c7";

fn main() {
// Get the Groth16 verification key for proof verification
Expand Down
8 changes: 8 additions & 0 deletions crates/integrations/sp1-tendermint/circuit/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub fn main() {
if inputs.trusted_height == TRUSTED_HEIGHT {
assert_eq!(tendermintx_output.trusted_header_hash, TRUSTED_ROOT);
} else {
let recusive_proof_outputs: RecursionCircuitOutputs = borsh::from_slice(
&inputs
.recursive_public_values
.as_ref()
.expect("Failed to unwrap recursive public values"),
)
.expect("Failed to deserialize Recursive Outputs");
assert!(tendermintx_output.target_height > recusive_proof_outputs.height);
Groth16Verifier::verify(
&inputs
.recursive_proof
Expand Down
8 changes: 8 additions & 0 deletions crates/integrations/sp1-tendermint/circuit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub fn main() {
if inputs.trusted_height == TRUSTED_HEIGHT {
assert_eq!(tendermintx_output.trusted_header_hash, TRUSTED_ROOT);
} else {
let recusive_proof_outputs: RecursionCircuitOutputs = borsh::from_slice(
&inputs
.recursive_public_values
.as_ref()
.expect("Failed to unwrap recursive public values"),
)
.expect("Failed to deserialize Recursive Outputs");
assert!(tendermintx_output.target_height > recusive_proof_outputs.height);
Groth16Verifier::verify(
&inputs
.recursive_proof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tendermint_recursion_types::{
RecursionCircuitOutputs, WrapperCircuitInputs, WrapperCircuitOutputs,
};

const RECURSIVE_VK: &str = "0x007233d84afece20b8bb52baf8d0eeaa471956b609de542144fcf8ae0364affa";
const RECURSIVE_VK: &str = "0x009094b993417fd795f3785e430cc9153705f79c798ac8f337acfabad95d4edc";

fn main() {
// Get the Groth16 verification key for proof verification
Expand Down
Loading
Loading