From 6efc007d3f53cf0ab52491e73c7bb9e2520938e0 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 4 Sep 2023 10:54:27 +0100 Subject: [PATCH] chore(stdlib)!: Rename `fixed_base_scalar_mul` to be more descriptive (#2488) Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> Co-authored-by: Maxim Vezenov --- .../tests/compile_success_empty/intrinsic_die/src/main.nr | 2 +- .../execution_success/brillig_scalar_mul/src/main.nr | 2 +- .../tests/execution_success/scalar_mul/src/main.nr | 2 +- .../tests/execution_success/simple_shield/src/main.nr | 2 +- noir_stdlib/src/scalar_mul.nr | 8 +++++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr b/crates/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr index 2762baf929c..1bd5f5a43f3 100644 --- a/crates/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr +++ b/crates/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr @@ -6,6 +6,6 @@ fn main(x: Field) { let bytes = x.to_be_bytes(32); let hash = std::hash::pedersen([x]); - let _p1 = std::scalar_mul::fixed_base(x); + let _p1 = std::scalar_mul::fixed_base_embedded_curve(x); } diff --git a/crates/nargo_cli/tests/execution_success/brillig_scalar_mul/src/main.nr b/crates/nargo_cli/tests/execution_success/brillig_scalar_mul/src/main.nr index 7941765a327..d3965188950 100644 --- a/crates/nargo_cli/tests/execution_success/brillig_scalar_mul/src/main.nr +++ b/crates/nargo_cli/tests/execution_success/brillig_scalar_mul/src/main.nr @@ -16,7 +16,7 @@ unconstrained fn main( pub_x = b_pub_x; pub_y = b_pub_y; } - let res = std::scalar_mul::fixed_base(priv_key); + let res = std::scalar_mul::fixed_base_embedded_curve(priv_key); assert(res[0] == pub_x); assert(res[1] == pub_y); } diff --git a/crates/nargo_cli/tests/execution_success/scalar_mul/src/main.nr b/crates/nargo_cli/tests/execution_success/scalar_mul/src/main.nr index d9d267f1dcd..2ff13d9f5ec 100644 --- a/crates/nargo_cli/tests/execution_success/scalar_mul/src/main.nr +++ b/crates/nargo_cli/tests/execution_success/scalar_mul/src/main.nr @@ -16,7 +16,7 @@ fn main( pub_x = b_pub_x; pub_y = b_pub_y; } - let res = std::scalar_mul::fixed_base(priv_key); + let res = std::scalar_mul::fixed_base_embedded_curve(priv_key); assert(res[0] == pub_x); assert(res[1] == pub_y); } diff --git a/crates/nargo_cli/tests/execution_success/simple_shield/src/main.nr b/crates/nargo_cli/tests/execution_success/simple_shield/src/main.nr index 18fccd862b5..88cf6091852 100644 --- a/crates/nargo_cli/tests/execution_success/simple_shield/src/main.nr +++ b/crates/nargo_cli/tests/execution_success/simple_shield/src/main.nr @@ -15,7 +15,7 @@ fn main( to_pubkey_y: Field, ) -> pub [Field; 2] { // Compute public key from private key to show ownership - let pubkey = std::scalar_mul::fixed_base(priv_key); + let pubkey = std::scalar_mul::fixed_base_embedded_curve(priv_key); let pubkey_x = pubkey[0]; let pubkey_y = pubkey[1]; diff --git a/noir_stdlib/src/scalar_mul.nr b/noir_stdlib/src/scalar_mul.nr index 8399284f149..482edb35e9f 100644 --- a/noir_stdlib/src/scalar_mul.nr +++ b/noir_stdlib/src/scalar_mul.nr @@ -1,2 +1,8 @@ +// Computes a fixed base scalar multiplication over the embedded curve. +// For bn254, We have Grumpkin and Baby JubJub. +// For bls12-381, we have JubJub and Bandersnatch. +// +// The embedded curve being used is decided by the +// underlying proof system. #[foreign(fixed_base_scalar_mul)] -fn fixed_base(_input : Field) -> [Field; 2] {} +fn fixed_base_embedded_curve(_input : Field) -> [Field; 2] {}