From d0d7fa0dae333e94d146e9a5bae0dd67db510abd Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 6 Oct 2023 11:52:59 +0000 Subject: [PATCH] marking pedersen bindings deprecated --- yarn-project/circuits.js/src/abis/abis.ts | 2 +- .../src/barretenberg/crypto/pedersen/pedersen.ts | 9 +++++++++ yarn-project/merkle-tree/src/pedersen.ts | 13 +++++++++++++ .../src/test/utils/pedersen_with_counter.ts | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index f24e6c54471..459f8468119 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -252,7 +252,7 @@ export function siloCommitment(wasm: IWasmModule, contract: AztecAddress, innerC } /** - * Computes a unique commitment. It includes a nonce which contains data that guarantees the commiment will be unique. + * Computes a unique commitment. It includes a nonce which contains data that guarantees the commitment will be unique. * @param wasm - A module providing low-level wasm access. * @param nonce - The contract address. * @param siloedCommitment - An siloed commitment. diff --git a/yarn-project/circuits.js/src/barretenberg/crypto/pedersen/pedersen.ts b/yarn-project/circuits.js/src/barretenberg/crypto/pedersen/pedersen.ts index 485fb6ac7ba..7013aabc78c 100644 --- a/yarn-project/circuits.js/src/barretenberg/crypto/pedersen/pedersen.ts +++ b/yarn-project/circuits.js/src/barretenberg/crypto/pedersen/pedersen.ts @@ -10,6 +10,7 @@ import { deserializeArrayFromVector, deserializeField, serializeBufferArrayToVec * @param lhs - The first hash. * @param rhs - The second hash. * @returns The new 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenCompress(wasm: IWasmModule, lhs: Uint8Array, rhs: Uint8Array): Buffer { // If not done already, precompute constants. @@ -29,6 +30,7 @@ export function pedersenCompress(wasm: IWasmModule, lhs: Uint8Array, rhs: Uint8A * @param lhs - The first hash. * @param rhs - The second hash. * @returns The new 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenHashInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer { // If not done already, precompute constants. @@ -44,6 +46,7 @@ export function pedersenHashInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer * @param wasm - The barretenberg module. * @param inputs - The array of buffers to compress. * @returns The resulting 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenCompressInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer { // If not done already, precompute constants. @@ -59,6 +62,7 @@ export function pedersenCompressInputs(wasm: IWasmModule, inputs: Buffer[]): Buf * @param wasm - The barretenberg module. * @param inputs - The array of buffers to compress. * @returns The resulting 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenPlookupCommitInputs(wasm: IWasmModule, inputs: Buffer[]): Buffer { // If not done already, precompute constants. @@ -75,6 +79,7 @@ export function pedersenPlookupCommitInputs(wasm: IWasmModule, inputs: Buffer[]) * @param inputs - The array of buffers to compress. * @param hashIndex - Hash index of the generator to use (See GeneratorIndex enum). * @returns The resulting 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenPlookupCommitWithHashIndex(wasm: IWasmModule, inputs: Buffer[], hashIndex: number): Buffer { // If not done already, precompute constants. @@ -91,6 +96,7 @@ export function pedersenPlookupCommitWithHashIndex(wasm: IWasmModule, inputs: Bu * @param inputs - The array of buffers to compress. * @param hashIndex - Hash index of the generator to use (See GeneratorIndex enum). * @returns The resulting 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenCompressWithHashIndex(wasm: IWasmModule, inputs: Buffer[], hashIndex: number): Buffer { // If not done already, precompute constants. @@ -107,6 +113,7 @@ export function pedersenCompressWithHashIndex(wasm: IWasmModule, inputs: Buffer[ * @param inputs - The array of buffers to compress. * @param hashIndex - Hash index of the generator to use (See GeneratorIndex enum). * @returns The resulting 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenPlookupCompressWithHashIndex(wasm: IWasmModule, inputs: Buffer[], hashIndex: number): Buffer { // If not done already, precompute constants. @@ -122,6 +129,7 @@ export function pedersenPlookupCompressWithHashIndex(wasm: IWasmModule, inputs: * @param wasm - The barretenberg module. * @param data - The data buffer. * @returns The hash buffer. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenGetHash(wasm: IWasmModule, data: Buffer): Buffer { // If not done already, precompute constants. @@ -144,6 +152,7 @@ export function pedersenGetHash(wasm: IWasmModule, data: Buffer): Buffer { * @param wasm - The barretenberg module. * @param values - The 32 byte pedersen leaves. * @returns A tree represented by an array. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export function pedersenGetHashTree(wasm: IWasmModule, values: Buffer[]) { // If not done already, precompute constants. diff --git a/yarn-project/merkle-tree/src/pedersen.ts b/yarn-project/merkle-tree/src/pedersen.ts index 376f2708d3a..1f26a812706 100644 --- a/yarn-project/merkle-tree/src/pedersen.ts +++ b/yarn-project/merkle-tree/src/pedersen.ts @@ -9,22 +9,35 @@ import { Hasher } from '@aztec/types'; /** * A helper class encapsulating Pedersen hash functionality. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export class Pedersen implements Hasher { constructor(private wasm: IWasmModule) {} + /* + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. + */ public compress(lhs: Uint8Array, rhs: Uint8Array): Buffer { return pedersenCompress(this.wasm, lhs, rhs); } + /* + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. + */ public compressInputs(inputs: Buffer[]): Buffer { return pedersenHashInputs(this.wasm, inputs); } + /* + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. + */ public hashToField(data: Uint8Array): Buffer { return pedersenGetHash(this.wasm, Buffer.from(data)); } + /* + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. + */ public hashToTree(leaves: Buffer[]): Promise { return Promise.resolve(pedersenGetHashTree(this.wasm, leaves)); } diff --git a/yarn-project/merkle-tree/src/test/utils/pedersen_with_counter.ts b/yarn-project/merkle-tree/src/test/utils/pedersen_with_counter.ts index b5e26783954..79eaab79214 100644 --- a/yarn-project/merkle-tree/src/test/utils/pedersen_with_counter.ts +++ b/yarn-project/merkle-tree/src/test/utils/pedersen_with_counter.ts @@ -2,6 +2,7 @@ import { Pedersen } from '../../index.js'; /** * A test utility allowing us to count the number of times the compress function has been called. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ export class PedersenWithCounter extends Pedersen { /** @@ -14,6 +15,7 @@ export class PedersenWithCounter extends Pedersen { * @param lhs - The first hash. * @param rhs - The second hash. * @returns The new 32-byte hash. + * @deprecated Don't call pedersen directly. Create specific nicely-called WASM functions for your use-case. */ public compress(lhs: Uint8Array, rhs: Uint8Array): Buffer { this.compressCounter++;