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

Silo unencrypted and generic encrypted logs in the tail kernel circuits #6537

Closed
MirandaWood opened this issue May 20, 2024 · 0 comments · Fixed by #6536
Closed

Silo unencrypted and generic encrypted logs in the tail kernel circuits #6537

MirandaWood opened this issue May 20, 2024 · 0 comments · Fixed by #6536

Comments

@MirandaWood
Copy link
Contributor

We need to silo unencrypted logs and encrypted logs not linked to notes in the tail circuit.

  • Unencrypted logs are hashed with the contract address in the tail and checked in the L1 hash to ensure the claimed data source is correct, as per the current protocol.
  • Encrypted logs linked to note hashes are already linked to a contract address by being linked to notes, so no siloing is required.
  • Generic encrypted logs will currently be hashed with a contract address tag, as per the protocol, but there may be a more efficient way to silo them. We already emit them with a header including the contract address, so it may be worth using that instead of separately hashing down the line. See Event Logs in 🧚‍♂️ Keys #5606.
@github-project-automation github-project-automation bot moved this to Todo in A3 May 20, 2024
MirandaWood added a commit that referenced this issue May 24, 2024
Closes #6537
### Siloing logs
#### Unencrypted logs
This PR now silos unencrypted logs by hashing their value with their
contract address in the tail kernels. For easier reviewing, this is
under commit
[8c9faee](8c9faee).
The main changes are:

- `LogHash` -> `ScopedLogHash`, and siloing the hash value in tails
- Replicating siloing in `TxsDecoder` L1 contract (the log itself
contains the contract address, so we just use that)
- Replicating siloing in ts (`hash()` in `tx_l2_logs`)

#### Encrypted logs
Following the
[protocol](https://docs.aztec.network/protocol-specs/logs#hashing-2), we
use `maskedContractAddress = pedersen(contractAddress, randomness)` to
silo encrypted non-note logs where the `randomness` is provided by the
original private call.
Since this requires an extra piece of information to 'follow' encrypted
logs through the context, kernels, and ts, there are a lot of changes.
See
[93e61ae](93e61ae)
for easier reviewing. Main changes are:

- The oracle now also emits `randomness` and `contractAddress` so we can
track and silo the log in ts.
- `LogHash` -> `EncryptedLogHash` in context and pre-tail kernels to
include `randomness` (following [protocol
struct](https://docs.aztec.network/protocol-specs/circuits/private-function#encryptedloghash)).
- `LogHash` -> `ScopedEncryptedLogHash` in accumulated data, to silo the
log in the tail.
- Replicating siloing in `TxsDecoder` by providing
`maskedContractAddress` in the block logs and extracting during hashing.
- Added `EncryptedL2NoteLog`and refactored `EncryptedL2Log` for non-note
encrypted logs in ts, since we need to hash and serialise the logs
differently.

#### Note logs length
To keep the code consistent and readable, I also added
`note_encrypted_log_preimages_length` as its own property in the tail
kernel, rollup, and `tx` struct in
[a54dbd5](a54dbd5).

#### Notes & TODOs

- Note that the protocol describes the siloed log hash as `H(value,
address)`, but all other siloed values in the kernels have `H(address,
value)`, so I followed the latter.
- `maskedContractAddress` has been renamed from `contractAddressTag` (as
the term `tag` is already used for note processing) to avoid confusion.
- I was originally going to rename `LogHash` -> `UnencryptedLogHash`,
but found that it's easier and a bit cheaper to convert
`ScopedEncryptedLogHash` -> `LogHash` when using `expose_to_public`,
since we remove the `randomness` and have the same struct as an
unencrypted log. Happy to create a separate struct if that's clearer in
the code however.

---

- [x] Silo unencrypted logs
- [x] Silo encrypted (non-note) logs
- [x] Add `note_encrypted_log_preimages_length` separately to circuits
and tx effects
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant