Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
3e13a8d
remove getHashTree and leftover buffer_to_field
kevaundray Oct 26, 2023
5e68a76
regenerate bindings
kevaundray Oct 26, 2023
92d455c
refactor test
kevaundray Oct 26, 2023
c417b64
remove hashTo Tree from interface
kevaundray Oct 26, 2023
aaf8d99
remove pedersenGetHashTree
kevaundray Oct 26, 2023
f342f9b
test file was only testing pedersenGetHashTree, so we can remove it
kevaundray Oct 26, 2023
752fb67
lint
kevaundray Oct 26, 2023
5e78f63
chore: remove pedersen getHashTree (#3069)
kevaundray Oct 26, 2023
d7cf562
change c-bind type from an Fr element to a point
kevaundray Oct 26, 2023
5b6aa55
regenerate bindings
kevaundray Oct 26, 2023
e5764e5
refactor tests to also check for the y coordinate
kevaundray Oct 26, 2023
bdedbe4
Empty commit
kevaundray Oct 26, 2023
88f2ae8
Merge remote-tracking branch 'origin/master' into kw/pedersen-finaliz…
kevaundray Oct 26, 2023
56763f8
Empty message
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 @@ -9,7 +9,7 @@ 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);
grumpkin::g1::affine_element pedersen_commitment = crypto::pedersen_commitment::commit_native(to_compress);

serialize::write(output, pedersen_hash);
serialize::write(output, pedersen_commitment);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "c_bind_new.hpp"
#include "../pedersen_hash/pedersen.hpp"
#include "barretenberg/common/serialize.hpp"
#include "c_bind.hpp"
#include "pedersen.hpp"

extern "C" {
Expand All @@ -9,12 +9,12 @@ using namespace barretenberg;

WASM_EXPORT void pedersen___init() {}

WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, fr::out_buf output)
WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, affine_element::out_buf 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);
grumpkin::g1::affine_element pedersen_commitment = crypto::pedersen_commitment::commit_native(to_compress);

serialize::write(output, pedersen_hash);
serialize::write(output, pedersen_commitment);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once
#include "barretenberg/common/wasm_export.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"

extern "C" {

using namespace barretenberg;
using affine_element = grumpkin::g1::affine_element;

WASM_EXPORT void pedersen___init();

WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, fr::out_buf output);
WASM_EXPORT void pedersen___commit(fr::vec_in_buf inputs_buffer, affine_element::out_buf output);
}
2 changes: 1 addition & 1 deletion barretenberg/exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"outArgs": [
{
"name": "output",
"type": "fr::out_buf"
"type": "affine_element::out_buf"
}
],
"isAsync": false
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/ts/src/barretenberg_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class BarretenbergApi {
return;
}

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

Expand Down
9 changes: 7 additions & 2 deletions barretenberg/ts/src/barretenberg_api/pedersen.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Barretenberg } from '../barretenberg/index.js';
import { Fr } from '../types/index.js';
import { Fr, Point } from '../types/index.js';

describe('pedersen', () => {
let api: Barretenberg;
Expand All @@ -20,6 +20,11 @@ describe('pedersen', () => {

it('pedersenCommit', async () => {
const result = await api.pedersenCommit([new Fr(4n), new Fr(8n), new Fr(12n)]);
expect(result).toEqual(new Fr(18374309251862457296563484909553154519357910650678202211610516068880120638872n));
expect(result).toEqual(
new Point(
new Fr(18374309251862457296563484909553154519357910650678202211610516068880120638872n),
new Fr(2572141322478528249692953821523229170092797347760799983831061874108357705739n),
),
);
});
});