From 1b6c57c9e0d76f37cdb38df11d418a9652469f0c Mon Sep 17 00:00:00 2001 From: Suyash Bagad Date: Fri, 21 Apr 2023 15:22:23 +0000 Subject: [PATCH] Change pedersen hash c_bind to use `pedersen_hash::lookup`. --- cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp b/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp index fc28d6fff0..ffffc314dc 100644 --- a/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp +++ b/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp @@ -11,6 +11,7 @@ extern "C" { WASM_EXPORT void pedersen_hash__init() { + // TODO: do we need this if we are using lookup-pedersen in merkle trees? crypto::generators::init_generator_data(); } @@ -18,7 +19,7 @@ WASM_EXPORT void pedersen__hash_pair(uint8_t const* left, uint8_t const* right, { auto lhs = barretenberg::fr::serialize_from_buffer(left); auto rhs = barretenberg::fr::serialize_from_buffer(right); - auto r = crypto::pedersen_hash::hash_multiple({ lhs, rhs }); + auto r = crypto::pedersen_hash::lookup::hash_multiple({ lhs, rhs }); barretenberg::fr::serialize_to_buffer(r, result); } @@ -26,7 +27,7 @@ WASM_EXPORT void pedersen__hash_multiple(uint8_t const* inputs_buffer, uint8_t* { std::vector to_compress; read(inputs_buffer, to_compress); - auto r = crypto::pedersen_hash::hash_multiple(to_compress); + auto r = crypto::pedersen_hash::lookup::hash_multiple(to_compress); barretenberg::fr::serialize_to_buffer(r, output); } @@ -36,7 +37,7 @@ WASM_EXPORT void pedersen__hash_multiple_with_hash_index(uint8_t const* inputs_b { std::vector to_compress; read(inputs_buffer, to_compress); - auto r = crypto::pedersen_hash::hash_multiple(to_compress, hash_index); + auto r = crypto::pedersen_hash::lookup::hash_multiple(to_compress, hash_index); barretenberg::fr::serialize_to_buffer(r, output); } @@ -54,7 +55,7 @@ WASM_EXPORT uint8_t* pedersen__hash_to_tree(uint8_t const* data) fields.reserve(num_outputs); for (size_t i = 0; fields.size() < num_outputs; i += 2) { - fields.push_back(crypto::pedersen_hash::hash_multiple({ fields[i], fields[i + 1] })); + fields.push_back(crypto::pedersen_hash::lookup::hash_multiple({ fields[i], fields[i + 1] })); } auto buf_size = 4 + num_outputs * sizeof(grumpkin::fq);