-
Notifications
You must be signed in to change notification settings - Fork 241
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
chore: rename pedersen typescript methods to be called hash
instead of compress
#3047
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
84c35f5
remove pedersen_buffer_to_field from cbinds
kevaundray d74eb76
regenerate bindings
kevaundray 7586a6d
remove test
kevaundray 53c65cd
use compressWIthHashIndex for redundant methods
kevaundray 4954a42
remove pedersenGetHash
kevaundray 3c16824
lint
kevaundray c3a54d0
add test to show that some methods are all the same
kevaundray 6798941
Merge remote-tracking branch 'origin/master' into kw/pedersen-cleanup…
kevaundray c1ebc73
rename compress -> hash
kevaundray 18a8e74
rename codebase to use hash
kevaundray 1841760
lint
kevaundray 1095911
fix typos
kevaundray 245e44b
fix typo
kevaundray 362f185
Empty commit
kevaundray 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 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 |
---|---|---|
|
@@ -22,7 +22,7 @@ import { | |
computeVarArgsHash, | ||
siloCommitment, | ||
} from '@aztec/circuits.js/abis'; | ||
import { pedersenCompressInputs } from '@aztec/circuits.js/barretenberg'; | ||
import { pedersenHashInputs } from '@aztec/circuits.js/barretenberg'; | ||
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. This is the main change in the PR, |
||
import { makeContractDeploymentData } from '@aztec/circuits.js/factories'; | ||
import { FunctionArtifact, FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; | ||
import { asyncMap } from '@aztec/foundation/async-map'; | ||
|
@@ -145,10 +145,10 @@ describe('Private Execution test suite', () => { | |
return trees[name]; | ||
}; | ||
|
||
const hash = (data: Buffer[]) => pedersenCompressInputs(circuitsWasm, data); | ||
const hash = (data: Buffer[]) => pedersenHashInputs(circuitsWasm, data); | ||
const hashFields = (data: Fr[]) => | ||
Fr.fromBuffer( | ||
pedersenCompressInputs( | ||
pedersenHashInputs( | ||
circuitsWasm, | ||
data.map(f => f.toBuffer()), | ||
), | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,53 +5,40 @@ import { Buffer } from 'buffer'; | |
import { deserializeArrayFromVector, deserializeField, serializeBufferArrayToVector } from '../../serialize.js'; | ||
|
||
/** | ||
* Compresses two 32-byte hashes. | ||
* Hashes two arrays. | ||
* @param wasm - The barretenberg module. | ||
* @param lhs - The first hash. | ||
* @param rhs - The second hash. | ||
* @param lhs - The first array. | ||
* @param rhs - The second array. | ||
* @returns The new 32-byte hash. | ||
* @deprecated Don't call pedersen directly in production code. Instead, create suitably-named functions for specific | ||
* purposes. | ||
*/ | ||
export function pedersenCompress(wasm: IWasmModule, lhs: Uint8Array, rhs: Uint8Array): Buffer { | ||
return pedersenCompressWithHashIndex(wasm, [Buffer.from(lhs), Buffer.from(rhs)], 0); | ||
export function pedersenHash(wasm: IWasmModule, lhs: Uint8Array, rhs: Uint8Array): Buffer { | ||
return pedersenHashWithHashIndex(wasm, [Buffer.from(lhs), Buffer.from(rhs)], 0); | ||
} | ||
|
||
/** | ||
* Combine an array of hashes using pedersen hash. | ||
* Computes the hash of an array of buffers. | ||
* @param wasm - The barretenberg module. | ||
* @param lhs - The first hash. | ||
* @param rhs - The second hash. | ||
* @param inputs - The array of buffers to hash. | ||
* @returns The new 32-byte hash. | ||
* @deprecated Don't call pedersen directly in production code. Instead, create suitably-named functions for specific | ||
* purposes. | ||
*/ | ||
export function pedersenHashInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer { | ||
return pedersenCompressWithHashIndex(wasm, inputs, 0); | ||
return pedersenHashWithHashIndex(wasm, inputs, 0); | ||
} | ||
|
||
/** | ||
* Compresses an array of buffers. | ||
* Hashes an array of buffers. | ||
* @param wasm - The barretenberg module. | ||
* @param inputs - The array of buffers to compress. | ||
* @returns The resulting 32-byte hash. | ||
* @deprecated Don't call pedersen directly in production code. Instead, create suitably-named functions for specific | ||
* purposes. | ||
*/ | ||
export function pedersenCompressInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer { | ||
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. Removed this as this is the same as pedersenHashInputs |
||
return pedersenCompressWithHashIndex(wasm, inputs, 0); | ||
} | ||
|
||
/** | ||
* Compresses an array of buffers. | ||
* @param wasm - The barretenberg module. | ||
* @param inputs - The array of buffers to compress. | ||
* @param inputs - The array of buffers to hash. | ||
* @param hashIndex - Hash index of the generator to use (See GeneratorIndex enum). | ||
* @returns The resulting 32-byte hash. | ||
* @deprecated Don't call pedersen directly in production code. Instead, create suitably-named functions for specific | ||
* purposes. | ||
*/ | ||
export function pedersenCompressWithHashIndex(wasm: IWasmModule, inputs: Buffer[], hashIndex: number): Buffer { | ||
export function pedersenHashWithHashIndex(wasm: IWasmModule, inputs: Buffer[], hashIndex: number): Buffer { | ||
// If not done already, precompute constants. | ||
wasm.call('pedersen__init'); | ||
const inputVectors = serializeBufferArrayToVector(inputs); | ||
|
@@ -66,7 +53,7 @@ export function pedersenCompressWithHashIndex(wasm: IWasmModule, inputs: Buffer[ | |
* | ||
* E.g. | ||
* Input: [1][2][3][4] | ||
* Output: [1][2][3][4][compress(1,2)][compress(3,4)][compress(5,6)]. | ||
* Output: [1][2][3][4][hash(1,2)][hash(3,4)][hash(5,6)]. | ||
* | ||
* @param wasm - The barretenberg module. | ||
* @param values - The 32 byte pedersen leaves. | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are a bunch of "crutch" tests that show that a lot of the pedersen methods are effectively the same or some are just supersets.
Once I remove the c_binds for them, these will also disappear since they won't be available anymore