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

Decrypt logs inside aztec-nr #10723

Open
Tracked by #10652 ...
nventuro opened this issue Dec 13, 2024 · 0 comments
Open
Tracked by #10652 ...

Decrypt logs inside aztec-nr #10723

nventuro opened this issue Dec 13, 2024 · 0 comments

Comments

@nventuro
Copy link
Contributor

nventuro commented Dec 13, 2024

We're currently encrypting in Noir and decrypting in TS, which makes it quite hard to change encryption schemes, and forces all contracts to use the same one. We should change this so that decryption is done in the contracts as part of the process_logs function.

Note that we will not be able to do this for partial notes since those are trickier due to the mixed ciphertext and plaintext in the log payload. Perhaps we'd tackle those first? (#10724) Alternatively we can continue handling the partial flow in PXE and skip those in the contracts if we got them.

nventuro added a commit that referenced this issue Jan 16, 2025
Closes #9576

This PR offloads the later stages of note log processing from PXE into
aztec-nr. The plan is to take over at the decrypted log payload stage,
and later on expand scope to also include decryption and (eventually)
tagging indices management.

Update: this now works, with some caveats. I'll leave some comments here
re. current status in case anyone wants to take a look, and for me to
resume work once I'm back.

Contracts are now expected to have a `process_logs` function that will
be called during note syncing. This function is not yet being
autogenerated, but I did manually add it to SchnorrAccount and
TokenContract for local testing - it should be fairly easy to
autogenerate it.

PXE still performs tagging index synchronization, fetches all relevant
logs, decrypts them, and merges the public and private components when
they are partial note logs. This will continue to be this way for a
while: we'll tackle these problems in #10723 and #10724. However, past
this point we delegate work to the contract.[^1] The contract performs
nonce discovery and computes note hash and nullifier, and then calls a
new PXE oracle called `deliverNote`. PXE validates that the note hash
exists in the tree, and adds the note to its database. **Edit:** I now
updated this section to remove all of the old relevant TS code. We no
longer do nonce discovery in PXE.

With this first step, PXE no longer needs to know about note type ids,
which become exclusively an aztec-nr concept. It will continue to know
about storage slots, but only because we index by them. More importantly
however, this makes us quite ready to continue building on top of this
work in order to fully move the other parts of the stack (notably
decryption and partial notes) into the contract as well.

[^1]: As of right now we're still doing all of the work in PXE,
including payload destructuring and nonce discovery, but we discard the
results and re-compute them in the contract. Changing this involves
deleting a bunch of files and re-structuring some dataflows, and I
haven't gotten round to it yet. We should do this in this PR.

---------

Co-authored-by: Jan Beneš <[email protected]>
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

No branches or pull requests

1 participant