-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(avm-simulator): hashing opcodes indirection (#5376)
**Situation for hashes before this PR** The hash situation is quite peculiar. Noir defines its hashes as _black box functions_ in the [stdlib](https://github.com/AztecProtocol/aztec-packages/blob/25caf4d8050cc7446595fcb159f140e7fbee6767/noir/noir-repo/noir_stdlib/src/hash.nr). However, the signature for most of them is not really good for bytecode/avm. E.g., they take and/or return `u8`s instead of Fields, some of them are permutations, others have separators, etc. Moreover, Brillig preprocessing changes the signature to accept vectors (variable size at runtime) vs arrays (size known at runtime) for some of the black box functions. The AVM defines: * [pedersen](https://github.com/AztecProtocol/aztec-packages/blob/25caf4d8050cc7446595fcb159f140e7fbee6767/avm-transpiler/src/transpile.rs#L880): it implements the blackbox function. * the rest, are defined as [oracles](https://github.com/AztecProtocol/aztec-packages/blob/8a7606875fbb7d3eb15b6d8eaa7e297e1a8838ea/noir-projects/aztec-nr/aztec/src/avm/hash.nr). This means that if a contract uses the stdlib (blackbox) hashes for these functions, it will not currently work with the avm. The definition as oracles is to have a (likely temporary) better signature for the hashes. Some of the indirections in our pedersen opcode were handled incorrectly (the transpiler was assuming an array, not a vector). **After the PR** I started implementing all of the hashing opcodes from the blackbox functions but this was quite difficult to quickly do in TS. So for the moment I'm just fixing the indirection problems. I also restricted `getSlice` to fail if called on undefined areas, which uncovered a few other bugs in tests.
- Loading branch information
Showing
6 changed files
with
113 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.