From ff7287e3929fde7da517a49273e7e97e3dcf8b90 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Fri, 23 Feb 2024 22:06:10 -0700 Subject: [PATCH 1/3] Add `impl subtle::ConstantTimeEq for note::Nullifier` --- CHANGELOG.md | 3 +++ src/note/nullifier.rs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 445a7a3e4..07637e071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to Rust's notion of ## [Unreleased] +### Added +- `impl subtle::ConstantTimeEq for note::Nullifier` + ## [0.7.0] - 2024-01-26 ### Licensing - The license for this crate is now "MIT OR Apache-2.0". The license diff --git a/src/note/nullifier.rs b/src/note/nullifier.rs index a18e77fef..7fa972303 100644 --- a/src/note/nullifier.rs +++ b/src/note/nullifier.rs @@ -3,7 +3,7 @@ use halo2_proofs::arithmetic::CurveExt; use memuse::DynamicUsage; use pasta_curves::pallas; use rand::RngCore; -use subtle::CtOption; +use subtle::{CtOption, ConstantTimeEq}; use super::NoteCommitment; use crate::{ @@ -62,6 +62,12 @@ impl Nullifier { } } +impl ConstantTimeEq for Nullifier { + fn ct_eq(&self, other: &Self) -> subtle::Choice { + self.0.ct_eq(&other.0) + } +} + /// Generators for property testing. #[cfg(any(test, feature = "test-dependencies"))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] From 8cc96b542046d40a852073a14424688bf05257e7 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Mon, 26 Feb 2024 09:44:02 -0700 Subject: [PATCH 2/3] Add `impl Clone for note_encryption::CompactAction` --- CHANGELOG.md | 1 + src/note/nullifier.rs | 2 +- src/note_encryption.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07637e071..7a562d95b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to Rust's notion of ### Added - `impl subtle::ConstantTimeEq for note::Nullifier` +- `impl Clone for note_encryption::CompactAction` ## [0.7.0] - 2024-01-26 ### Licensing diff --git a/src/note/nullifier.rs b/src/note/nullifier.rs index 7fa972303..bde133995 100644 --- a/src/note/nullifier.rs +++ b/src/note/nullifier.rs @@ -3,7 +3,7 @@ use halo2_proofs::arithmetic::CurveExt; use memuse::DynamicUsage; use pasta_curves::pallas; use rand::RngCore; -use subtle::{CtOption, ConstantTimeEq}; +use subtle::{ConstantTimeEq, CtOption}; use super::NoteCommitment; use crate::{ diff --git a/src/note_encryption.rs b/src/note_encryption.rs index dc0766f04..00a6a17fa 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -269,6 +269,7 @@ impl ShieldedOutput for Action { } /// A compact Action for light clients. +#[derive(Clone)] pub struct CompactAction { nullifier: Nullifier, cmx: ExtractedNoteCommitment, From 9729cd8d266a6121bd8c7f3b43053440b787d413 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Mon, 26 Feb 2024 10:03:16 -0700 Subject: [PATCH 3/3] Add note_encryption::CompactAction::cmx --- CHANGELOG.md | 1 + src/note_encryption.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a562d95b..66a65dde3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to Rust's notion of ### Added - `impl subtle::ConstantTimeEq for note::Nullifier` - `impl Clone for note_encryption::CompactAction` +- `note_encryption::CompactAction::cmx` ## [0.7.0] - 2024-01-26 ### Licensing diff --git a/src/note_encryption.rs b/src/note_encryption.rs index 00a6a17fa..27da4724a 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -326,10 +326,15 @@ impl CompactAction { } } - ///Returns the nullifier of the note being spent. + /// Returns the nullifier of the note being spent. pub fn nullifier(&self) -> Nullifier { self.nullifier } + + /// Returns the commitment to the new note being created. + pub fn cmx(&self) -> ExtractedNoteCommitment { + self.cmx + } } #[cfg(test)]