Skip to content
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 31 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 25 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 Oct 25, 2023
d74eb76
regenerate bindings
kevaundray Oct 25, 2023
7586a6d
remove test
kevaundray Oct 25, 2023
53c65cd
use compressWIthHashIndex for redundant methods
kevaundray Oct 25, 2023
4954a42
remove pedersenGetHash
kevaundray Oct 25, 2023
3c16824
lint
kevaundray Oct 25, 2023
c3a54d0
add test to show that some methods are all the same
kevaundray Oct 25, 2023
6798941
Merge remote-tracking branch 'origin/master' into kw/pedersen-cleanup…
kevaundray Oct 25, 2023
c1ebc73
rename compress -> hash
kevaundray Oct 25, 2023
18a8e74
rename codebase to use hash
kevaundray Oct 25, 2023
1841760
lint
kevaundray Oct 25, 2023
1095911
fix typos
kevaundray Oct 25, 2023
245e44b
fix typo
kevaundray Oct 25, 2023
362f185
Empty commit
kevaundray Oct 25, 2023
ccd0c96
move output argument to last position to match c_bind_new and other c…
kevaundray Oct 26, 2023
ef27e71
modify calling code to:
kevaundray Oct 26, 2023
0a52d4f
optimize pedersenHash for wasm scratch space
kevaundray Oct 26, 2023
96d4ebd
lint
kevaundray Oct 26, 2023
8f7408a
Merge branch 'master' into kw/pedersen-cleanup-argument-ordering-fix
LeilaWang Oct 26, 2023
3deef57
charlie review: free the allocated input
kevaundray Oct 26, 2023
4a8f73b
Merge branch 'kw/pedersen-cleanup-argument-ordering-fix' into kw/pede…
kevaundray Oct 26, 2023
d8a6917
remove unused cbinds
kevaundray Oct 26, 2023
3aa048c
re-generate bindings
kevaundray Oct 26, 2023
e5c922e
update tests
kevaundray Oct 26, 2023
5a039cb
Merge remote-tracking branch 'origin/master' into kw/pedersen-cleanup…
kevaundray Oct 26, 2023
427d1d9
compress -> hash
kevaundray Oct 26, 2023
6723259
Merge branch 'master' into kw/pedersen-cleanup-remove-unused-cbinds
kevaundray Oct 26, 2023
55a7e87
make pedersen_hash look exactly like pedersen_compress
kevaundray Oct 26, 2023
8ce6c40
remove leftover function definitions from header
kevaundray Oct 26, 2023
36ffe57
Empty commit
kevaundray Oct 26, 2023
5e78f63
chore: remove pedersen getHashTree (#3069)
kevaundray Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,6 @@
#include "pedersen.hpp"

WASM_EXPORT void pedersen__init() {}
WASM_EXPORT void pedersen__compress_fields(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__compress(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__compress_with_hash_index(uint8_t const* inputs_buffer, uint32_t hash_index, uint8_t* output)
{
std::vector<grumpkin::fq> to_compress;
read(inputs_buffer, to_compress);
crypto::GeneratorContext<curve::Grumpkin> ctx; // todo fix
ctx.offset = static_cast<size_t>(hash_index);
auto r = crypto::pedersen_hash::hash(to_compress, ctx);
barretenberg::fr::serialize_to_buffer(r, output);
}

WASM_EXPORT void pedersen__commit(uint8_t const* inputs_buffer, uint8_t* output)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,6 @@ using namespace barretenberg;

WASM_EXPORT void pedersen___init() {}

WASM_EXPORT void pedersen___compress_fields(fr::in_buf left, fr::in_buf right, fr::out_buf 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___compress(fr::vec_in_buf inputs_buffer, fr::out_buf 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___compress_with_hash_index(fr::vec_in_buf inputs_buffer,
uint32_t const* hash_index,
fr::out_buf output)
{
std::vector<grumpkin::fq> to_compress;
read(inputs_buffer, to_compress);
const size_t generator_offset = ntohl(*hash_index);
crypto::GeneratorContext<curve::Grumpkin> ctx; // todo fix
ctx.offset = generator_offset;
auto r = crypto::pedersen_hash::hash(to_compress, ctx);
barretenberg::fr::serialize_to_buffer(r, output);
}

WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, fr::out_buf output)
{
std::vector<grumpkin::fq> to_compress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,5 @@ using namespace barretenberg;

WASM_EXPORT void pedersen___init();

WASM_EXPORT void pedersen___compress_fields(fr::in_buf left, fr::in_buf right, fr::out_buf result);

WASM_EXPORT void pedersen___compress(fr::vec_in_buf inputs_buffer, fr::out_buf output);

WASM_EXPORT void pedersen___compress_with_hash_index(fr::vec_in_buf inputs_buffer,
uint32_t const* hash_index,
fr::out_buf output);

WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, fr::out_buf output);
}
28 changes: 0 additions & 28 deletions barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ extern "C" {

WASM_EXPORT void pedersen_hash__init() {}

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_with_hash_index(uint8_t const* inputs_buffer,
uint32_t const* hash_index,
uint8_t* output)
Expand All @@ -25,26 +17,6 @@ WASM_EXPORT void pedersen__hash_with_hash_index(uint8_t const* inputs_buffer,
barretenberg::fr::serialize_to_buffer(r, output);
}

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.
Expand Down
10 changes: 0 additions & 10 deletions barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/c_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@ extern "C" {
using namespace barretenberg;

WASM_EXPORT void pedersen_hash_init();
WASM_EXPORT void pedersen_hash(fr::vec_in_buf inputs_buffer, fr::out_buf output);
WASM_EXPORT void pedersen_hash_with_hash_index(fr::vec_in_buf inputs_buffer,
uint32_t const* hash_index,
fr::out_buf output);

WASM_EXPORT void pedersen_hash_pair(fr::in_buf left, fr::in_buf right, fr::out_buf result);

WASM_EXPORT void pedersen_hash_multiple(fr::vec_in_buf inputs_buffer, fr::out_buf output);

WASM_EXPORT void pedersen_hash_multiple_with_hash_index(fr::vec_in_buf inputs_buffer,
uint32_t const* hash_index,
fr::out_buf 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

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_with_hash_index(uint8_t const* inputs_buffer,
uint32_t const* hash_index,
uint8_t* output)
Expand All @@ -24,26 +17,6 @@ WASM_EXPORT void pedersen_hash_with_hash_index(uint8_t const* inputs_buffer,

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.
Expand Down
128 changes: 0 additions & 128 deletions barretenberg/exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,6 @@
"outArgs": [],
"isAsync": false
},
{
"functionName": "pedersen___compress_fields",
"inArgs": [
{
"name": "left",
"type": "fr::in_buf"
},
{
"name": "right",
"type": "fr::in_buf"
}
],
"outArgs": [
{
"name": "result",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen___compress",
"inArgs": [
{
"name": "inputs_buffer",
"type": "fr::vec_in_buf"
}
],
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen___compress_with_hash_index",
"inArgs": [
{
"name": "inputs_buffer",
"type": "fr::vec_in_buf"
},
{
"name": "hash_index",
"type": "const uint32_t *"
}
],
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen___commit",
"inArgs": [
Expand All @@ -83,22 +27,6 @@
"outArgs": [],
"isAsync": false
},
{
"functionName": "pedersen_hash",
"inArgs": [
{
"name": "inputs_buffer",
"type": "fr::vec_in_buf"
}
],
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen_hash_with_hash_index",
"inArgs": [
Expand All @@ -119,62 +47,6 @@
],
"isAsync": false
},
{
"functionName": "pedersen_hash_pair",
"inArgs": [
{
"name": "left",
"type": "fr::in_buf"
},
{
"name": "right",
"type": "fr::in_buf"
}
],
"outArgs": [
{
"name": "result",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen_hash_multiple",
"inArgs": [
{
"name": "inputs_buffer",
"type": "fr::vec_in_buf"
}
],
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen_hash_multiple_with_hash_index",
"inArgs": [
{
"name": "inputs_buffer",
"type": "fr::vec_in_buf"
},
{
"name": "hash_index",
"type": "const uint32_t *"
}
],
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
}
],
"isAsync": false
},
{
"functionName": "pedersen_hash_to_tree",
"inArgs": [
Expand Down
43 changes: 0 additions & 43 deletions barretenberg/ts/src/barretenberg_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@ export class BarretenbergApi {
return;
}

async pedersenCompressFields(left: Fr, right: Fr): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen___compress_fields', [left, right], [Fr]);
return result[0];
}

async pedersenCompress(inputsBuffer: Fr[]): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen___compress', [inputsBuffer], [Fr]);
return result[0];
}

async pedersenCompressWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
const result = await this.binder.callWasmExport(
'pedersen___compress_with_hash_index',
[inputsBuffer, hashIndex],
[Fr],
);
return result[0];
}

async pedersenCommit(inputsBuffer: Fr[]): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen___commit', [inputsBuffer], [Fr]);
return result[0];
Expand All @@ -51,35 +32,11 @@ export class BarretenbergApi {
return;
}

async pedersenHash(inputsBuffer: Fr[]): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen_hash', [inputsBuffer], [Fr]);
return result[0];
}

async pedersenHashWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen_hash_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
return result[0];
}

async pedersenHashPair(left: Fr, right: Fr): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen_hash_pair', [left, right], [Fr]);
return result[0];
}

async pedersenHashMultiple(inputsBuffer: Fr[]): Promise<Fr> {
const result = await this.binder.callWasmExport('pedersen_hash_multiple', [inputsBuffer], [Fr]);
return result[0];
}

async pedersenHashMultipleWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
const result = await this.binder.callWasmExport(
'pedersen_hash_multiple_with_hash_index',
[inputsBuffer, hashIndex],
[Fr],
);
return result[0];
}

async pedersenHashToTree(data: Fr[]): Promise<Fr[]> {
const result = await this.binder.callWasmExport('pedersen_hash_to_tree', [data], [VectorDeserializer(Fr)]);
return result[0];
Expand Down
Loading