forked from visoftsolutions/noir_rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Verify function against contract class id in private kernel (Az…
…tecProtocol#4337) Updates the private kernel circuit to verify that the function being executed belongs to the contract class id in the address preimage. - Introduces `ContractClassId` as a type in noir-protocol-circuits - Updates contract class computation to remove public functions root since they'll be eventually dropped - Updates `PrivateCallData` input to private kernel to include preimages for address and contract class - Introduces `WrappedFieldLike` type for codegen so all wrapped field types can be converted from fields - Introduces an immutable simple `MerkleTree` type in circuits.js so we don't pass raw `Fr[]`s around - Sets `vk_hash` to zero in ts-land since it's mocked to zero in noir-land - Replaces pxe `contract_tree` with a `private_functions_tree` - Updates noir protocol circuits fixture data and builder - Introduces `WrappedFieldLike` to encoder to easily pass structs with just an `inner` field from aztecjs Pending updating yellow paper with new kernel circuit structs (coming up in another PR). Fixes AztecProtocol#4056
- Loading branch information
1 parent
44ae25d
commit 34a8a00
Showing
63 changed files
with
2,117 additions
and
1,202 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
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
Binary file added
BIN
+4.32 KB
yarn-project/circuits.js/src/contract/__snapshots__/private_function.test.ts.snap
Binary file not shown.
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
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
34 changes: 34 additions & 0 deletions
34
yarn-project/circuits.js/src/contract/private_function.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { PrivateFunction } from '@aztec/types/contracts'; | ||
|
||
import { fr, makeSelector } from '../tests/factories.js'; | ||
import { computePrivateFunctionsRoot, computePrivateFunctionsTree } from './private_function.js'; | ||
|
||
describe('PrivateFunction', () => { | ||
const privateFunctions: PrivateFunction[] = [ | ||
{ selector: makeSelector(1), vkHash: fr(2), isInternal: false }, | ||
{ selector: makeSelector(3), vkHash: fr(4), isInternal: false }, | ||
]; | ||
|
||
it('computes merkle tree', () => { | ||
const tree = computePrivateFunctionsTree(privateFunctions); | ||
expect(tree.nodes.map(node => node.toString())).toMatchSnapshot(); | ||
}); | ||
|
||
it('computes merkle tree root', () => { | ||
const root = computePrivateFunctionsRoot(privateFunctions); | ||
expect(root.toString()).toMatchSnapshot(); | ||
}); | ||
|
||
it('tree and root methods agree', () => { | ||
const tree = computePrivateFunctionsTree(privateFunctions); | ||
const root = computePrivateFunctionsRoot(privateFunctions); | ||
expect(Fr.fromBuffer(tree.root).equals(root)).toBe(true); | ||
}); | ||
|
||
it('sorts functions before computing tree', () => { | ||
const root = computePrivateFunctionsRoot(privateFunctions); | ||
const rootReversed = computePrivateFunctionsRoot([...privateFunctions].reverse()); | ||
expect(root.equals(rootReversed)).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.