-
Notifications
You must be signed in to change notification settings - Fork 328
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!: encrypted logs refactor #11400
Conversation
2a98d40
to
7336241
Compare
Docs PreviewHey there! 👋 You can check your preview at https://67954a73b0b4eec3480d8bf2--aztec-docs-dev.netlify.app |
…kages into mc/potato-encode
noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypt/poseidon2.nr
Outdated
Show resolved
Hide resolved
...cts/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/partial_note.nr
Show resolved
Hide resolved
noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note.nr
Show resolved
Hide resolved
pub fn bytes_to_fields<let N: u32>(input: [u8; N]) -> [Field; (N + 30) / 31] { | ||
let mut dst = [0; (N + 30) / 31]; | ||
// Note: ceil(N / 31) = (N + 30) / 31 | ||
pub fn be_bytes_31_to_fields<let N: u32>(bytes: [u8; N]) -> [Field; (N + 30) / 31] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimised vs the previous implementation that did a load of <
checks on indices at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you measure this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also no need to throw in optimizations on top of further changes 🙃 this could just be its own thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you measure this?
No, but each comparison is something like 15 constraints, so the if byte_index < N
for every byte of the old version will have blown up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is an example of me seeing something and going "I should fix this" instead of "I should open an issue for this and come back to it".
@@ -0,0 +1,124 @@ | |||
global KNOWN_NON_RESIDUE: Field = 5; // This is a non-residue in Noir's native Field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately, this should all go in the stdlib Field dir. It's all to get a sqrt function.
Changes to public function bytecode sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am so sorry about what you had to go through
noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypt/poseidon2.nr
Outdated
Show resolved
Hide resolved
noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypt/poseidon2.nr
Outdated
Show resolved
Hide resolved
@@ -334,6 +330,7 @@ comptime fn generate_multi_scalar_mul( | |||
aztec::protocol_types::point::Point { x: $generator_x, y: $generator_y, is_infinite: false } | |||
}, | |||
); | |||
// TODO: explain why it's ok to use the unsafe `from_field_unsafe`, here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok? Can we not use the fn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I couldn't determine whether it was safe or not, so I planted that todo as a flag.
noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note.nr
Show resolved
Hide resolved
noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note.nr
Show resolved
Hide resolved
I don't know how to diagnose these failed tests. Will need to find help from someone on Monday. |
Converting this to draft. Superseded by #11503 (which is a superset of this PR), which is ready to me merged. |
Addresses the comments from this old PR: #11400 Introduces Poseidon2 encryption, but doesn't plug it into any example contracts. --------- Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
Addresses the comments from this old PR: AztecProtocol/aztec-packages#11400 Introduces Poseidon2 encryption, but doesn't plug it into any example contracts. --------- Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
Description:
Optimisations:
New features: