Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Avoid code duplication in sk.owns by calling gen_note_sk #247

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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