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:
StateDiffHints
(AztecProtocol#3919)
Fixes AztecProtocol#3916
- Loading branch information
Showing
9 changed files
with
273 additions
and
182 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
81 changes: 81 additions & 0 deletions
81
yarn-project/circuits.js/src/structs/rollup/state_diff_hints.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,81 @@ | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { Tuple } from '@aztec/foundation/serialize'; | ||
import { FieldsOf } from '@aztec/foundation/types'; | ||
|
||
import { | ||
CONTRACT_SUBTREE_SIBLING_PATH_LENGTH, | ||
MAX_NEW_NULLIFIERS_PER_TX, | ||
NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, | ||
NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, | ||
NULLIFIER_TREE_HEIGHT, | ||
PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, | ||
} from '../../constants.gen.js'; | ||
import { serializeToBuffer } from '../../utils/serialize.js'; | ||
import { MembershipWitness } from '../membership_witness.js'; | ||
import { NullifierLeafPreimage } from './nullifier_leaf/index.js'; | ||
|
||
/** | ||
* Hints used while proving state diff validity. | ||
*/ | ||
export class StateDiffHints { | ||
constructor( | ||
/** | ||
* The nullifiers which need to be updated to perform the batch insertion of the new nullifiers. | ||
* See `StandardIndexedTree.batchInsert` function for more details. | ||
*/ | ||
public nullifierPredecessorPreimages: Tuple<NullifierLeafPreimage, typeof MAX_NEW_NULLIFIERS_PER_TX>, | ||
/** | ||
* Membership witnesses for the nullifiers which need to be updated to perform the batch insertion of the new | ||
* nullifiers. | ||
*/ | ||
public nullifierPredecessorMembershipWitnesses: Tuple< | ||
MembershipWitness<typeof NULLIFIER_TREE_HEIGHT>, | ||
typeof MAX_NEW_NULLIFIERS_PER_TX | ||
>, | ||
/** | ||
* The nullifiers to be inserted in the tree, sorted high to low. | ||
*/ | ||
public sortedNullifiers: Tuple<Fr, typeof MAX_NEW_NULLIFIERS_PER_TX>, | ||
/** | ||
* The indexes of the sorted nullifiers to the original ones. | ||
*/ | ||
public sortedNullifierIndexes: Tuple<number, typeof MAX_NEW_NULLIFIERS_PER_TX>, | ||
/** | ||
* Sibling path "pointing to" where the new note hash subtree should be inserted into the note hash tree. | ||
*/ | ||
public noteHashSubtreeSiblingPath: Tuple<Fr, typeof NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH>, | ||
/** | ||
* Sibling path "pointing to" where the new nullifiers subtree should be inserted into the nullifier tree. | ||
*/ | ||
public nullifierSubtreeSiblingPath: Tuple<Fr, typeof NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH>, | ||
/** | ||
* Sibling path "pointing to" where the new contracts subtree should be inserted into the contract tree. | ||
*/ | ||
public contractSubtreeSiblingPath: Tuple<Fr, typeof CONTRACT_SUBTREE_SIBLING_PATH_LENGTH>, | ||
/** | ||
* Sibling path "pointing to" where the new public data subtree should be inserted into the public data tree. | ||
*/ | ||
public publicDataSiblingPath: Tuple<Fr, typeof PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH>, | ||
) {} | ||
|
||
static from(fields: FieldsOf<StateDiffHints>): StateDiffHints { | ||
return new StateDiffHints(...StateDiffHints.getFields(fields)); | ||
} | ||
|
||
static getFields(fields: FieldsOf<StateDiffHints>) { | ||
return [ | ||
fields.nullifierPredecessorPreimages, | ||
fields.nullifierPredecessorMembershipWitnesses, | ||
fields.sortedNullifiers, | ||
fields.sortedNullifierIndexes, | ||
fields.noteHashSubtreeSiblingPath, | ||
fields.nullifierSubtreeSiblingPath, | ||
fields.contractSubtreeSiblingPath, | ||
fields.publicDataSiblingPath, | ||
] as const; | ||
} | ||
|
||
toBuffer(): Buffer { | ||
return serializeToBuffer(...StateDiffHints.getFields(this)); | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/base.nr
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod base_rollup_inputs; | ||
mod state_diff_hints; | ||
|
||
use base_rollup_inputs::BaseRollupInputs; | ||
use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs; |
Oops, something went wrong.