-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add ownability trait #200
Conversation
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; | ||
} |
There was a problem hiding this comment.
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.
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 | |
} | |
} |
There was a problem hiding this comment.
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`
There was a problem hiding this comment.
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.
Closing because |
Resolves: #146