-
Notifications
You must be signed in to change notification settings - Fork 474
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
[Feature] Add BHP, Pedersen, and Poseidon hash function implementations to the Provable SDK. #989
base: mainnet
Are you sure you want to change the base?
Conversation
aleo-wasm
package.aleo-wasm
package.
aleo-wasm
package.wasm
package.
wasm
package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments
macro_rules! from_wasm_object_array { | ||
($input:expr, $wasm_type:ident) => {{ | ||
$input | ||
.to_vec() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can use .iter()
instead of .to_vec().into_iter()
macro_rules! from_js_typed_array { | ||
($input:expr, $method:ident, $_type:expr) => {{ | ||
$input | ||
.to_vec() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can use .iter()
instead of .to_vec().iter()
#[macro_export] | ||
macro_rules! to_bits_array_le { | ||
($self:expr) => {{ | ||
let array = js_sys::Array::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use .collect::<js_sys::Array>
instead of manually pushing.
Motivation
This PR adds BHP, Pedersen and Poseidon hash function impls to Provable SDK. This proposed functionality enables JS developers to use the Aleo implementations of these hash functions within their dapps.
These hash exports are useful (but not limited to) the following use-cases.
finalize
block, etc.Changelog
BHP256
,BHP512
,BHP768
,BHP1024
,Pedersen64
,Pedersen128
,Poseidon2
,Poseidon4
, andPoseidon8
. The current rationale behind this is to enable different domain separators to ensure dapps implementing these hash functions within offchain protocols in their dapp do not share a global domain (which may lead to vulnerabilities such as witness discovery).utilities
module that provides macros for convertingjs arrays
of protocol objects to vectors of corresponding objects inrust
&wasm
Ciphertext
object to enable decryption of ciphertexts from transition inputs or outputs by the keyViewKey
holder.Test Plan