-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Pedersen Hash & Commitment Gadgets (#95)
* [SQUASHED] Pedersen refactor into hash and commitment. Rename `crypto_pedersen` to `crypto_pedersen_hash` Rename. Pull generator data stuff out of pedersen crypto. Large refactor of pedersen native and stdlib. FIX everything. Get rid of unnecessary pedersen hash test. Its tricky to get this working: you need hash interface for byte array which is what we would like to avoid for pedersen_hash Fix cci. Enable ultra with different interfaces for: 1. pedersen hash 2. pedersen commitment Use lookup pedersen for merkle tree, fixed-base pedersen for commitments. Merkle tree test fixes. Circuit vk updates. * post rebase fixes. * js eg circuit size fix. --------- Co-authored-by: Suyash Bagad <[email protected]>
- Loading branch information
Showing
103 changed files
with
1,577 additions
and
708 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
barretenberg_module(crypto_generators ecc) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
barretenberg_module(crypto_pedersen_commitment ecc crypto_generators crypto_pedersen_hash) |
47 changes: 47 additions & 0 deletions
47
cpp/src/barretenberg/crypto/pedersen_commitment/c_bind.cpp
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,47 @@ | ||
#include "c_bind.hpp" | ||
#include "pedersen.hpp" | ||
#include "barretenberg/common/serialize.hpp" | ||
#include "barretenberg/common/timer.hpp" | ||
#include "barretenberg/common/mem.hpp" | ||
#include "barretenberg/common/streams.hpp" | ||
#define WASM_EXPORT __attribute__((visibility("default"))) | ||
|
||
extern "C" { | ||
|
||
WASM_EXPORT void pedersen__init() | ||
{ | ||
crypto::generators::init_generator_data(); | ||
} | ||
|
||
WASM_EXPORT void pedersen__compress(uint8_t const* inputs_buffer, uint8_t* output) | ||
{ | ||
std::vector<grumpkin::fq> to_compress; | ||
read(inputs_buffer, to_compress); | ||
auto r = crypto::pedersen_commitment::compress_native(to_compress); | ||
barretenberg::fr::serialize_to_buffer(r, output); | ||
} | ||
|
||
WASM_EXPORT void pedersen__compress_with_hash_index(uint8_t const* inputs_buffer, uint8_t* output, uint32_t hash_index) | ||
{ | ||
std::vector<grumpkin::fq> to_compress; | ||
read(inputs_buffer, to_compress); | ||
auto r = crypto::pedersen_commitment::compress_native(to_compress, hash_index); | ||
barretenberg::fr::serialize_to_buffer(r, output); | ||
} | ||
|
||
WASM_EXPORT void pedersen__commit(uint8_t const* inputs_buffer, uint8_t* output) | ||
{ | ||
std::vector<grumpkin::fq> to_compress; | ||
read(inputs_buffer, to_compress); | ||
grumpkin::g1::affine_element pedersen_hash = crypto::pedersen_commitment::commit_native(to_compress); | ||
|
||
write(output, pedersen_hash); | ||
} | ||
|
||
WASM_EXPORT void pedersen__buffer_to_field(uint8_t const* data, size_t length, uint8_t* r) | ||
{ | ||
std::vector<uint8_t> to_compress(data, data + length); | ||
auto output = crypto::pedersen_commitment::compress_native(to_compress); | ||
write(r, output); | ||
} | ||
} |
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.