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

Update method of hashing the SignedTxRequest in the circuits. #361

Closed
spalladino opened this issue Apr 25, 2023 · 2 comments · Fixed by #541
Closed

Update method of hashing the SignedTxRequest in the circuits. #361

spalladino opened this issue Apr 25, 2023 · 2 comments · Fixed by #541
Assignees

Comments

@spalladino
Copy link
Collaborator

As part of this discussion, we agreed that we need a way to reconstruct tx hashes for private and public txs from the L2 block. Given it's possible it'll change in the near future, rather than passing in a new field altogether with the tx hash, we'll be using the first nullifier of each tx to store the hash. We'll also alter how we calculate tx hashes: for all txs, public or private, they'll be the hash of the signed tx request.

This means we need to make the following changes:

  • In the Tx object in the types package, update how tx hashes are calculated. The hash should always be obtained by pedersen hashing the signed tx request (check if we need a new generator point). For the sake of simplicity, we'll disallow txs that have both a private and a public signed tx request.
  • In both the private and public kernel circuits, calculate the tx hash from the signed tx request, ordering the fields in the same way as in the client.
  • In the archiver/sequencer, when processing a new L2 block that was observed on L1, just use the first nullifier as the tx hash to figure out which txs need to be removed from the P2P pool.

For reference, the hash of a tx should be calculated by concatenating the following fields in the following order, and pedersen hashing them:

from
to
functionData
args
nonce
txContext
chainId
signature.r
signature.s
@spalladino spalladino added the discussion-needed Still needs more discussion before we jump to work on this label Apr 25, 2023
@spalladino spalladino removed the discussion-needed Still needs more discussion before we jump to work on this label Apr 25, 2023
@dbanks12
Copy link
Contributor

dbanks12 commented May 4, 2023

Note there is now a third entry in the signature struct signature.v that might need to be added in this list.

@PhilWindle PhilWindle changed the title Calculate tx hash from signed tx request and push it as first nullifier Update method of hashing the SignedTxRequest in the circuits. May 7, 2023
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 a pull request may close this issue.

3 participants