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

feat: add remaining constraints in aggchain proof #84

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

hadjiszs
Copy link
Contributor

@hadjiszs hadjiszs commented Mar 4, 2025

Description

  • Add verification of the l1 head
  • Hardcode the hash of the aggregation vkey directly in the aggchain proof program
  • Adapt for the optimisticMode
    • Align the aggchain_params expression
    • Add the case signature verification of the fep public values
  • Compute the hash chain global index from the prover inputs
  • Add the "delete" hashChains
  • Put the right static calls to retrieve the new and prev hash chain global index

Fixes #76

PR Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added or updated tests that comprehensively prove my change is effective or that my feature works

@hadjiszs hadjiszs marked this pull request as ready for review March 7, 2025 10:44
@hadjiszs hadjiszs requested a review from a team as a code owner March 7, 2025 10:44
@hadjiszs hadjiszs requested review from iljakuklic and atanmarko March 7, 2025 10:44
Copy link
Contributor

@iljakuklic iljakuklic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full review yet. The parts I went through look good. The main point is how we integrate the vkey hash constant with #83.

Comment on lines +10 to +13
/// Hardcoded hash of the "aggregation vkey".
/// NOTE: Format being `hash_u32()` of the `SP1StarkVerifyingKey`.
#[cfg(target_os = "zkvm")]
pub const AGGREGATION_VKEY_HASH: Vkey = [0u32; 8]; // TODO: to put the right value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to check the vkey hash before the proof checking (as done in #83), this constant would have to be available publicly. Either by exporting it from this crate or by moving it into some sort of -common crate. Also, it may be worth considering making the constant of the type VKeyHash, also introduced in #83.

I appreciate that if merging this PR is time sensitive, just exporting it from the crate as is might be the most viable option for now.

Comment on lines +57 to +61
if !self.l1_head_inclusion_proof.verify(
self.l1_info_tree_leaf.1.hash(),
self.l1_info_tree_leaf.0,
self.l1_info_root,
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny style nit. I prefer to avoid multi-line if conditions.

Suggested change
if !self.l1_head_inclusion_proof.verify(
self.l1_info_tree_leaf.1.hash(),
self.l1_info_tree_leaf.0,
self.l1_info_root,
) {
let inclusion_proof_valid = self.l1_head_inclusion_proof.verify(
self.l1_info_tree_leaf.1.hash(),
self.l1_info_tree_leaf.0,
self.l1_info_root,
);
if !inclusion_proof_valid {

Copy link
Contributor

@atanmarko atanmarko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +330 to +331
/// Verify the claimed global indexes extracting the unset global indexes
/// are equal to the Constrained global indexes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Verify the claimed global indexes extracting the unset global indexes
/// are equal to the Constrained global indexes.
/// Verify that the claimed global indexes extracting the unset global indexes
/// are equal to the Constrained global indexes.

.inserted_gers
.iter()
.map(|inserted_ger| inserted_ger.ger())
.collect();
Copy link
Contributor

@atanmarko atanmarko Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they always in the same order, do you need to sort them here for comparison?

Copy link
Contributor

@iljakuklic iljakuklic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just some nits.


impl StaticCallWithContext {
/// Returns the decoded output values of a static call.
pub fn execute_static_call<C: SolCall>(
Copy link
Contributor

@iljakuklic iljakuklic Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may now just be called execute since StaticCall is already a part the type name.

self.verify_inserted_gers()
}
}

/// Check that the rebuilt hash chain is equal to the new hash chain.
fn rebuild_hash_chain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not completely sold on the rebuild_ part of the name since this also does verification.

// Iterate over values and remove (skip) one occurrence for each removed value
values
.iter()
.cloned()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be demoted to copied

Suggested change
.cloned()
.copied()

Comment on lines +434 to +435
.cloned()
.filter(|value| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably does not make much difference since the value is Copy anyway so cloning it is supposed to be cheap. However in general, I'd suggest filtering first and then applying map-like operations if practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding bridge constraint on claims in the aggchain proof program
4 participants