diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index dfc0008..58b07e8 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Call `gen_note_sk` in `SecretKey::owns` to avoid code duplication [#246] + ## [0.32.0] - 2024-08-14 ### Changed diff --git a/core/src/keys/secret.rs b/core/src/keys/secret.rs index 83d97e2..82049f0 100644 --- a/core/src/keys/secret.rs +++ b/core/src/keys/secret.rs @@ -89,11 +89,9 @@ impl SecretKey { /// Checks if `note_pk ?= (H(R · a) + b) · G` pub fn owns(&self, stealth_address: &StealthAddress) -> bool { - let aR = stealth_address.R() * self.a(); - let hash_aR = hash(&aR); - let note_sk = hash_aR + self.b(); + let note_sk = self.gen_note_sk(stealth_address); - let note_pk = GENERATOR_EXTENDED * note_sk; + let note_pk = GENERATOR_EXTENDED * note_sk.as_ref(); stealth_address.note_pk().as_ref() == ¬e_pk }