Skip to content

Conversation

@S1nus
Copy link
Contributor

@S1nus S1nus commented Jun 6, 2025

Overview

Payy commitment (poseidon2 on bn254 scalars) equivalence proofs

@nuke-web3
Copy link
Member

working to mock this & ensure easy performance wins are included for the patch here: https://github.com/nuke-web3/sp1-poseidon2-testing

Would appreciate a look & collab on tweaks on that repo (& upstream) that we can include here

@nuke-web3 nuke-web3 marked this pull request as draft June 12, 2025 01:18
@nuke-web3 nuke-web3 self-requested a review July 17, 2025 16:53
Copy link
Member

@nuke-web3 nuke-web3 left a comment

Choose a reason for hiding this comment

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

Trying to wrap my head around how Payy sequencers and/or provers will retrieve data from this proof being posted to a settlement layer (Polygon in this case) and had a few notes:

Comment on lines +86 to +90
pub struct PayyInclusionToDataRootProofOutput {
pub data_root: [u8; 32],
// The Payy hash of the leaves, a bn254 scalar field element represented as [u8; 32].
pub payy_commitment: [u8; 32],
}
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, we will post this data to Polygon, so we have a agg_agg proof committed to, not all leaves (total 24 Poseidon2 hashes). correct? And the data root is connected in merkle proof for a recent blobstream DataRootTupleRoot right?

So ultimately if I wanted to sync up a Payy node with any update posted to DA, I would need to:

  • Find the Celestia block with data_root.
  • Search all blobs within that block until I find one with 24 leaf hashes together become the payy_commitment. (Possible to filter on Payy's known namespace{s})

I think blobstream needs a block height so we could connect root->height from what is on Polygon on a related contract. If not, AFAIK there is no direct API to get blobs from Celestia from only a data root. Some indexing for data roots -> block height is needed. If we can't get what we need from Polygon, maybe we should commit the height too so extra infra isn't required.

Could be that we assume it's not a big deal to search a Celestia block for reconstructing known payy_commitments. If not, committing more metadata in the proof output so you can directly call blob.Get to retrieve the specific data you need would be helpful. At least blob commitment if assume the namespace is public common knowledge so unneeded, and we have block height from some other cheap method.

Comment on lines +82 to +83
// the ~8 UTXO hashes for a Payy block, bn254 scalar field elements represented as [u8; 32].
pub hashes: Vec<[u8; 32]>,
Copy link
Member

Choose a reason for hiding this comment

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

I think now we need this to be 24 exactly, perhaps known & enforced at compile time, unsure if it will ever be different.

Suggested change
// the ~8 UTXO hashes for a Payy block, bn254 scalar field elements represented as [u8; 32].
pub hashes: Vec<[u8; 32]>,
// the ~8 UTXO hashes for a Payy block, bn254 scalar field elements represented as [u8; 32].
pub hashes: [[u8; 32]; 24],

3 user proofs on UTXOs (that include 4 hashes) -> 2 UTXO_agg -> 1 agg_agg proof.
From https://excalidraw.com/#json=qq9tvy6-Z3i4LRw0aVPbN,8u_rJ0LFt9P9Rk-YDqb5GA


println!("cycle-tracker-start: create blob");
let blob =
Blob::new(input.namespace_id, input.data, AppVersion::V3).expect("Failed creating blob");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Blob::new(input.namespace_id, input.data, AppVersion::V3).expect("Failed creating blob");
Blob::new(input.namespace_id, input.data, AppVersion::V4).expect("Failed creating blob");

need to test against latest node versions.

.expect("Failed verifying proof");
println!("cycle-tracker-end: verify proof");

let computed_payy_commitment: [u8; 32] = compute_payy_commitment(&input.hashes);
Copy link
Member

Choose a reason for hiding this comment

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

guess this is unimplimented!() at this time and needs to be connected to work in https://github.com/polybase/zk-rollup/pull/1709 IIUC.

env_logger = "0.11"
log = "0.4"
base64 = "0.22"
sp1-bn254-poseidon = {git = "https://github.com/S1nus/sp1-poseidon2-bn254-scalar"}
Copy link
Member

Choose a reason for hiding this comment

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

probably we should publish this on crates & version it before merging this PR? 🤷 at least tag a version?

Copy link
Member

@nuke-web3 nuke-web3 left a comment

Choose a reason for hiding this comment

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

after #93 we found #98 to be blocking this PR, so need a fix to that before this is merged (or included in the PR)

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.

3 participants