-
Notifications
You must be signed in to change notification settings - Fork 598
feat: added indexes and a way to store/retrieve tagged secrets #9468
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4ea44f0
added indexes and a way to store/retrieve tagged secrets
Thunkar 7fd2702
fmt
Thunkar e56cd95
fix oracle args
Thunkar 700a161
Update noir-projects/aztec-nr/aztec/src/oracle/notes.nr
Thunkar d5bf858
fixes
Thunkar 9196ebc
Merge branch 'gj/fetch_app_siloed_tag_secrets_and_indexes' of github.…
Thunkar 5df35f7
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar bf41211
Merge branch 'master' into gj/fetch_app_siloed_tag_secrets_and_indexes
Thunkar 7896b35
Merge branch 'master' into gj/fetch_app_siloed_tag_secrets_and_indexes
Thunkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr
This file contains hidden or 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,10 @@ | ||
| use crate::traits::Deserialize; | ||
| use std::meta::derive; | ||
|
|
||
| pub global INDEXED_TAGGING_SECRET_LENGTH: u32 = 2; | ||
|
|
||
| #[derive(Deserialize)] | ||
| pub struct IndexedTaggingSecret { | ||
| secret: Field, | ||
| index: u32, | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
9 changes: 9 additions & 0 deletions
9
yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts
This file contains hidden or 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,9 @@ | ||
| import { Fr } from '@aztec/foundation/fields'; | ||
|
|
||
| export class IndexedTaggingSecret { | ||
| constructor(public secret: Fr, public index: number) {} | ||
|
|
||
| toFields(): Fr[] { | ||
| return [this.secret, new Fr(this.index)]; | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -66,6 +66,8 @@ export class KVPxeDatabase implements PxeDatabase { | |
| #notesByTxHashAndScope: Map<string, AztecMultiMap<string, string>>; | ||
| #notesByIvpkMAndScope: Map<string, AztecMultiMap<string, string>>; | ||
|
|
||
| #taggingSecretIndexes: AztecMap<string, number>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be good for this to mention whether this is the last index or the next index |
||
|
|
||
| constructor(private db: AztecKVStore) { | ||
| this.#db = db; | ||
|
|
||
|
|
@@ -111,6 +113,8 @@ export class KVPxeDatabase implements PxeDatabase { | |
| this.#notesByTxHashAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_tx_hash`)); | ||
| this.#notesByIvpkMAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_ivpk_m`)); | ||
| } | ||
|
|
||
| this.#taggingSecretIndexes = db.openMap('tagging_secret_indices'); | ||
| } | ||
|
|
||
| public async getContract( | ||
|
|
@@ -572,4 +576,20 @@ export class KVPxeDatabase implements PxeDatabase { | |
|
|
||
| return incomingNotesSize + outgoingNotesSize + treeRootsSize + authWitsSize + addressesSize; | ||
| } | ||
|
|
||
| async incrementTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<void> { | ||
Thunkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const indexes = await this.getTaggingSecretsIndexes(appTaggingSecrets); | ||
| await this.db.transaction(() => { | ||
| indexes.forEach(index => { | ||
| const nextIndex = index ? index + 1 : 1; | ||
| void this.#taggingSecretIndexes.set(appTaggingSecrets.toString(), nextIndex); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| getTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<number[]> { | ||
| return this.db.transaction(() => | ||
| appTaggingSecrets.map(secret => this.#taggingSecretIndexes.get(secret.toString()) ?? 0), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.