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

Add ownability trait #200

Closed
wants to merge 1 commit into from
Closed

Add ownability trait #200

wants to merge 1 commit into from

Conversation

xevisalle
Copy link
Member

@xevisalle xevisalle commented Jun 10, 2024

Resolves: #146

Comment on lines +41 to +49
pub trait Ownability {
/// Checks if:
/// `note_pk ?= H(R · a) · G + B` for `ViewKey`
/// `note_pk ?= (H(R · a) + b) · G` for `SecretKey`
fn owns(&self, owner: &impl crate::Ownable) -> bool;

/// Checks if `k_sync ?= R_sync · a`
fn owns_unchecked(&self, owner: &impl crate::Ownable) -> bool;
}
Copy link
Member

@moCello moCello Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get away with only requiring a fn a function that returns the internal a.
owns and owns_unchecked can by computed from that, which means that the type that implements the Ownability trait doesn't need to re-compute the checks themselves.

Suggested change
pub trait Ownability {
/// Checks if:
/// `note_pk ?= H(R · a) · G + B` for `ViewKey`
/// `note_pk ?= (H(R · a) + b) · G` for `SecretKey`
fn owns(&self, owner: &impl crate::Ownable) -> bool;
/// Checks if `k_sync ?= R_sync · a`
fn owns_unchecked(&self, owner: &impl crate::Ownable) -> bool;
}
pub trait Ownability {
fn a(&self) -> JubJubScalar;
fn owns(&self, owner: &impl crate::Ownable) -> bool {
// implement owns here directly
}
fn owns_unchecked(&self, owner: &impl crate::Ownable) -> bool {
// implement owns_unchecked here directly
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the Ownability trait we should also let the function note.decrypt_data (and with that also note.value and note.blinding_factor) to take any type that implements Ownability. This means that we can also decrypt the value and blinding factor with a SecretKey`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moCello regarding your first comment: but then, how am I supposed to get b or B? In the end I still need two different ways to perform the check.

Regarding the decrypt data thing, I can look into it in a new commit.

@xevisalle
Copy link
Member Author

Closing because Ownable is no longer there.

@xevisalle xevisalle closed this Jun 17, 2024
@moCello moCello deleted the sk_own branch August 30, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SecretKey should be enough to verify note's ownership
2 participants