From d2df10d78036f6fb4e0dae5c7287e4523bd8b47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Tue, 7 May 2024 17:26:00 +0200 Subject: [PATCH] refactor: nuking `GrumpkinScalar` (#6240) All the aztec usecases were already replaced with a GrumpkinPrivateKey which is basically a duplicate of GrumpkinScalar. Fixes https://github.com/noir-lang/noir/issues/4968 --- .../aztec/src/keys/point_to_symmetric_key.nr | 2 +- .../abis/nullifier_key_validation_request.nr | 3 +-- .../crates/types/src/grumpkin_private_key.nr | 2 +- .../noir_stdlib/src/grumpkin_scalar.nr | 22 ------------------- noir/noir-repo/noir_stdlib/src/lib.nr | 1 - 5 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 noir/noir-repo/noir_stdlib/src/grumpkin_scalar.nr diff --git a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr index 905a049f9d5..1c80662dcb3 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{constants::GENERATOR_INDEX__SYMMETRIC_KEY, grumpkin_private_key::GrumpkinPrivateKey, grumpkin_point::GrumpkinPoint, utils::arr_copy_slice}; -use dep::std::{hash::sha256, grumpkin_scalar::GrumpkinScalar, embedded_curve_ops::multi_scalar_mul}; +use dep::std::{hash::sha256, embedded_curve_ops::multi_scalar_mul}; // TODO(#5726): This function is called deriveAESSecret in TS. I don't like point_to_symmetric_key name much since // point is not the only input of the function. Unify naming with TS once we have a better name. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_key_validation_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_key_validation_request.nr index 1a08e9f7a2f..bab8b642f09 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_key_validation_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_key_validation_request.nr @@ -3,12 +3,11 @@ use crate::{ address::AztecAddress, constants::{NULLIFIER_KEY_VALIDATION_REQUEST_CONTEXT_LENGTH, NULLIFIER_KEY_VALIDATION_REQUEST_LENGTH}, traits::{Empty, Serialize, Deserialize}, grumpkin_point::GrumpkinPoint, - grumpkin_private_key::GrumpkinPrivateKey }; struct NullifierKeyValidationRequest { master_nullifier_public_key: GrumpkinPoint, - app_nullifier_secret_key: Field, // not a GrumpkinScalar because it's output of poseidon2 + app_nullifier_secret_key: Field, // not a grumpkin scalar because it's output of poseidon2 } impl Eq for NullifierKeyValidationRequest { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr b/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr index 20b43f7aebc..79261ec4f20 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/grumpkin_private_key.nr @@ -1,4 +1,4 @@ -use dep::std::{cmp::Eq, grumpkin_scalar::GrumpkinScalar, embedded_curve_ops::fixed_base_scalar_mul}; +use dep::std::{cmp::Eq, embedded_curve_ops::fixed_base_scalar_mul}; use crate::{ grumpkin_point::GrumpkinPoint, traits::Empty diff --git a/noir/noir-repo/noir_stdlib/src/grumpkin_scalar.nr b/noir/noir-repo/noir_stdlib/src/grumpkin_scalar.nr deleted file mode 100644 index dd4b029d0a7..00000000000 --- a/noir/noir-repo/noir_stdlib/src/grumpkin_scalar.nr +++ /dev/null @@ -1,22 +0,0 @@ -// TODO(https://github.com/noir-lang/noir/issues/4968): move to aztec noir-protocol-circuits -struct GrumpkinScalar { - low: Field, - high: Field, -} - -impl GrumpkinScalar { - pub fn new(low: Field, high: Field) -> Self { - // TODO: check that the low and high value fit within the grumpkin modulus - GrumpkinScalar { low, high } - } -} - -global GRUMPKIN_SCALAR_SERIALIZED_LEN: Field = 2; - -pub fn deserialize_grumpkin_scalar(fields: [Field; GRUMPKIN_SCALAR_SERIALIZED_LEN]) -> GrumpkinScalar { - GrumpkinScalar { low: fields[0], high: fields[1] } -} - -pub fn serialize_grumpkin_scalar(scalar: GrumpkinScalar) -> [Field; GRUMPKIN_SCALAR_SERIALIZED_LEN] { - [scalar.low, scalar.high] -} diff --git a/noir/noir-repo/noir_stdlib/src/lib.nr b/noir/noir-repo/noir_stdlib/src/lib.nr index 73fc7a28417..900cacb3cb6 100644 --- a/noir/noir-repo/noir_stdlib/src/lib.nr +++ b/noir/noir-repo/noir_stdlib/src/lib.nr @@ -6,7 +6,6 @@ mod schnorr; mod ecdsa_secp256k1; mod ecdsa_secp256r1; mod eddsa; -mod grumpkin_scalar; mod embedded_curve_ops; mod sha256; mod sha512;