-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
import { IndexedTaggingSecret } from '@aztec/circuits.js'; | ||
|
||
// Half the size of the window we slide over the tagging secret indexes. | ||
export const WINDOW_HALF_SIZE = 10; | ||
|
||
export function getLeftMostIndexedTaggingSecrets(indexedTaggingSecrets: IndexedTaggingSecret[]): IndexedTaggingSecret[] { | ||
return indexedTaggingSecrets.map(indexedTaggingSecret => | ||
new IndexedTaggingSecret( | ||
indexedTaggingSecret.appTaggingSecret, | ||
Math.max(0, indexedTaggingSecret.index - WINDOW_HALF_SIZE) | ||
) | ||
export function getLeftMostIndexedTaggingSecrets( | ||
indexedTaggingSecrets: IndexedTaggingSecret[], | ||
): IndexedTaggingSecret[] { | ||
return indexedTaggingSecrets.map( | ||
indexedTaggingSecret => | ||
new IndexedTaggingSecret( | ||
indexedTaggingSecret.appTaggingSecret, | ||
Math.max(0, indexedTaggingSecret.index - WINDOW_HALF_SIZE), | ||
), | ||
); | ||
} | ||
|
||
export function getRightMostIndexes(indexedTaggingSecrets: IndexedTaggingSecret[]): { [k: string]: number } { | ||
const maxIndexesToCheck: { [k: string]: number } = {}; | ||
const rightMostIndexes: { [k: string]: number } = {}; | ||
|
||
for (const indexedTaggingSecret of indexedTaggingSecrets) { | ||
maxIndexesToCheck[indexedTaggingSecret.appTaggingSecret.toString()] = indexedTaggingSecret.index + WINDOW_HALF_SIZE; | ||
rightMostIndexes[indexedTaggingSecret.appTaggingSecret.toString()] = indexedTaggingSecret.index + WINDOW_HALF_SIZE; | ||
} | ||
|
||
return maxIndexesToCheck; | ||
return rightMostIndexes; | ||
} | ||
|
||
export function getInitialSecretIndexes(indexedTaggingSecrets: IndexedTaggingSecret[]): { [k: string]: number } { | ||
const initialSecretIndexes: { [k: string]: number } = {}; | ||
export function getInitialIndexes(indexedTaggingSecrets: IndexedTaggingSecret[]): { [k: string]: number } { | ||
const initialIndexes: { [k: string]: number } = {}; | ||
|
||
for (const indexedTaggingSecret of indexedTaggingSecrets) { | ||
initialSecretIndexes[indexedTaggingSecret.appTaggingSecret.toString()] = indexedTaggingSecret.index; | ||
initialIndexes[indexedTaggingSecret.appTaggingSecret.toString()] = indexedTaggingSecret.index; | ||
} | ||
|
||
return initialSecretIndexes; | ||
} | ||
return initialIndexes; | ||
} |