Skip to content

Commit

Permalink
core: Avoid code duplication in sk.owns by calling gen_note_sk
Browse files Browse the repository at this point in the history
Resolves #246
  • Loading branch information
moCello committed Sep 18, 2024
1 parent 8d70fac commit ea21daf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions core/src/keys/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() == &note_pk
}
Expand Down

0 comments on commit ea21daf

Please sign in to comment.