Skip to content

Commit

Permalink
marking pedersen bindings deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 6, 2023
1 parent 7a58fe9 commit d0d7fa0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/abis/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions yarn-project/merkle-tree/src/pedersen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Buffer[]> {
return Promise.resolve(pedersenGetHashTree(this.wasm, leaves));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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++;
Expand Down

0 comments on commit d0d7fa0

Please sign in to comment.