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

refactor: no calls to pedersen from TS #2724

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Oct 6, 2023

Fixes #435

This PR doesn't really address the original issue that much. I have reasons for this:

  1. Most of the direct pedersen calls are used by the merkle tress. Given that the merkle trees will be fully replaced by an application in rust or C++ it doesn't make sense to invest time in that code.
  2. The remaining calls are performed in tests where we check whether some hash corresponds to the one computed in Noir. I feel like it doesn't really make sense to create specific bindings for tests. But I don't really have a strong opinion on this.

I marked the pedersen functions as deprecated with a message to not use it in production code. I think that's the best way to go about this at this point.

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@benesjan benesjan marked this pull request as draft October 6, 2023 11:53
@benesjan benesjan force-pushed the janb/no-direct-TS-calls-to-pedersen branch 2 times, most recently from 2f52953 to d0d7fa0 Compare October 6, 2023 12:03
@benesjan benesjan force-pushed the janb/no-direct-TS-calls-to-pedersen branch from e8099cc to 45b61e6 Compare October 10, 2023 07:01
@benesjan benesjan marked this pull request as ready for review October 10, 2023 09:06
@@ -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 in production code. Instead, create specific nicely-called WASM functions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @deprecated Don't call pedersen directly in production code. Instead, create specific nicely-called WASM functions.
* @deprecated Don't call pedersen directly in production code. Instead, create suitably-named functions for specific purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 4b722a5

@@ -3208,7 +3208,7 @@ export function abisComputeGlobalsHash(wasm: IWasmModule, arg0: GlobalVariables)
export function abisComputePublicDataTreeValue(wasm: IWasmModule, arg0: Fr): Fr {
return Fr.fromBuffer(callCbind(wasm, 'abis__compute_public_data_tree_value', [toBuffer(arg0)]));
}
export function abisComputePublicDataTreeIndex(wasm: IWasmModule, arg0: Fr, arg1: Fr): Fr {
export function abisComputePublicDataTreeIndex(wasm: IWasmModule, arg0: Address, arg1: Fr): Fr {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Address or AztecAddress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct because of this alias. There is no AztecAddress on the C++ side so I guess Adam set it up like this to make it work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@@ -9,22 +9,35 @@ import { Hasher } from '@aztec/types';

/**
* A helper class encapsulating Pedersen hash functionality.
* @deprecated Don't call pedersen directly in production code. Instead, create specific nicely-called WASM functions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 4b722a5

@benesjan benesjan requested a review from PhilWindle October 11, 2023 10:30
@PhilWindle PhilWindle merged commit 78e44c3 into master Oct 11, 2023
2 checks passed
@PhilWindle PhilWindle deleted the janb/no-direct-TS-calls-to-pedersen branch October 11, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Remove all calls to pedersen from TS
2 participants