-
Notifications
You must be signed in to change notification settings - Fork 234
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: Remove unused pedersen c_binds #3058
Merged
Merged
Changes from all commits
Commits
Show all changes
31 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 ccd0c96
move output argument to last position to match c_bind_new and other c…
kevaundray ef27e71
modify calling code to:
kevaundray 0a52d4f
optimize pedersenHash for wasm scratch space
kevaundray 96d4ebd
lint
kevaundray 8f7408a
Merge branch 'master' into kw/pedersen-cleanup-argument-ordering-fix
LeilaWang 3deef57
charlie review: free the allocated input
kevaundray 4a8f73b
Merge branch 'kw/pedersen-cleanup-argument-ordering-fix' into kw/pede…
kevaundray d8a6917
remove unused cbinds
kevaundray 3aa048c
re-generate bindings
kevaundray e5c922e
update tests
kevaundray 5a039cb
Merge remote-tracking branch 'origin/master' into kw/pedersen-cleanup…
kevaundray 427d1d9
compress -> hash
kevaundray 6723259
Merge branch 'master' into kw/pedersen-cleanup-remove-unused-cbinds
kevaundray 55a7e87
make pedersen_hash look exactly like pedersen_compress
kevaundray 8ce6c40
remove leftover function definitions from header
kevaundray 36ffe57
Empty commit
kevaundray 5e78f63
chore: remove pedersen getHashTree (#3069)
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
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,13 +5,8 @@ | |
|
||
extern "C" { | ||
|
||
WASM_EXPORT void pedersen_hash(uint8_t const* inputs_buffer, uint8_t* output) | ||
{ | ||
std::vector<grumpkin::fq> to_compress; | ||
read(inputs_buffer, to_compress); | ||
auto r = crypto::pedersen_hash::hash(to_compress); | ||
barretenberg::fr::serialize_to_buffer(r, output); | ||
} | ||
WASM_EXPORT void pedersen_hash_init() {} | ||
|
||
Comment on lines
+8
to
+9
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. I just moved this to be above |
||
WASM_EXPORT void pedersen_hash_with_hash_index(uint8_t const* inputs_buffer, | ||
uint32_t const* hash_index, | ||
uint8_t* output) | ||
|
@@ -21,47 +16,4 @@ WASM_EXPORT void pedersen_hash_with_hash_index(uint8_t const* inputs_buffer, | |
auto r = crypto::pedersen_hash::hash(to_compress, ntohl(*hash_index)); | ||
barretenberg::fr::serialize_to_buffer(r, output); | ||
} | ||
|
||
WASM_EXPORT void pedersen_hash_init() {} | ||
|
||
WASM_EXPORT void pedersen_hash_pair(uint8_t const* left, uint8_t const* right, uint8_t* result) | ||
{ | ||
auto lhs = barretenberg::fr::serialize_from_buffer(left); | ||
auto rhs = barretenberg::fr::serialize_from_buffer(right); | ||
auto r = crypto::pedersen_hash::hash({ lhs, rhs }); | ||
barretenberg::fr::serialize_to_buffer(r, result); | ||
} | ||
|
||
WASM_EXPORT void pedersen_hash_multiple(uint8_t const* inputs_buffer, uint8_t* output) | ||
{ | ||
pedersen_hash(inputs_buffer, output); | ||
} | ||
|
||
WASM_EXPORT void pedersen_hash_multiple_with_hash_index(uint8_t const* inputs_buffer, | ||
uint32_t const* hash_index, | ||
uint8_t* output) | ||
{ | ||
pedersen_hash_with_hash_index(inputs_buffer, hash_index, output); | ||
} | ||
|
||
/** | ||
* Given a buffer containing 32 byte pedersen leaves, return a new buffer containing the leaves and all pairs of | ||
* nodes that define a merkle tree. | ||
* e.g. | ||
* input: [1][2][3][4] | ||
* output: [1][2][3][4][compress(1,2)][compress(3,4)][compress(5,6)] | ||
* | ||
*/ | ||
WASM_EXPORT void pedersen_hash_to_tree(fr::vec_in_buf data, fr::vec_out_buf out) | ||
{ | ||
auto fields = from_buffer<std::vector<grumpkin::fq>>(data); | ||
auto num_outputs = fields.size() * 2 - 1; | ||
fields.reserve(num_outputs); | ||
|
||
for (size_t i = 0; fields.size() < num_outputs; i += 2) { | ||
fields.push_back(crypto::pedersen_hash::hash({ fields[i], fields[i + 1] })); | ||
} | ||
|
||
*out = to_heap_buffer(fields); | ||
} | ||
} |
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.
The previous
pedersen__hash_with_hash_index
was usinguint32_t const* hash_index
whereas the previouspedersen__compress_with_hash_index
was usinguint32_t const hash_index
-- I set this to match the compress variant, though note its now different to the c_bind_new because they are usinguint32_t const*