Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Nov 26, 2024
1 parent fa2291e commit 8a442fd
Show file tree
Hide file tree
Showing 238 changed files with 2,702 additions and 1,678 deletions.
14 changes: 14 additions & 0 deletions barretenberg/cpp/src/barretenberg/crypto/poseidon2/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ WASM_EXPORT void poseidon2_permutation(fr::vec_in_buf inputs_buffer, fr::vec_out
const std::vector<fr> results(results_array.begin(), results_array.end());
*output = to_heap_buffer(results);
}

WASM_EXPORT void poseidon2_hash_accumulate(fr::vec_in_buf inputs_buffer, fr::out_buf output)
{
std::vector<fr> to_hash;
read(inputs_buffer, to_hash);
const size_t numHashes = to_hash.size();
fr result = 0;
size_t count = 0;
while (count < numHashes) {
result = crypto::Poseidon2<crypto::Poseidon2Bn254ScalarFieldParams>::hash({ to_hash[count], result });
++count;
}
write(output, result);
}
12 changes: 12 additions & 0 deletions barretenberg/ts/src/barretenberg_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,18 @@ export class BarretenbergApiSync {
return out[0];
}

poseidon2HashAccumulate(inputsBuffer: Fr[]): Fr {
const inArgs = [inputsBuffer].map(serializeBufferable);
const outTypes: OutputType[] = [Fr];
const result = this.wasm.callWasmExport(
'poseidon2_hash_accumulate',
inArgs,
outTypes.map(t => t.SIZE_IN_BYTES),
);
const out = result.map((r, i) => outTypes[i].fromBuffer(r));
return out[0];
}

poseidon2Hashes(inputsBuffer: Fr[]): Fr {
const inArgs = [inputsBuffer].map(serializeBufferable);
const outTypes: OutputType[] = [Fr];
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"rollups",
"rushstack",
"sanitise",
"sanitised",
"schnorr",
"secp",
"SEMRESATTRS",
Expand Down
Loading

0 comments on commit 8a442fd

Please sign in to comment.