forked from zcash/orchard
-
Notifications
You must be signed in to change notification settings - Fork 0
Add a reference note for each first issuance #124
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
50db185
Add a reference note for each first issuance
ConstanceBeguier 58c98b3
Fix zsa_issue_and_transfer test
ConstanceBeguier 7db2e73
Take into account Pablo's review
ConstanceBeguier adb5664
Create verify_reference_note function
ConstanceBeguier c54506d
Add some reference note checks
ConstanceBeguier b6a67ff
Fix reference note tests
ConstanceBeguier ec3e9ff
Remove reference_notes from IssueBundle
ConstanceBeguier 7274efd
Add get_reference_notes
ConstanceBeguier f57f876
Update refrence keys description
ConstanceBeguier e627d5a
Merge branch 'zsa1' into add_reference_notes
ConstanceBeguier 81b63eb
Merge branch 'zsa1' into add_reference_notes
ConstanceBeguier d227857
Move verify_reference_note function into test section
ConstanceBeguier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| //! Orchard reference keys, including the spending key and recipient address, used for reference notes. | ||
| //! | ||
| //! The reference SpendingKey is a placeholder key with all bytes set to zero. | ||
| //! Using this SpendingKey, we derive the FullViewingKey, and the recipient address. | ||
| //! To avoid repeating the derivation process whenever the recipient address is required, we store | ||
| //! its raw encoding. | ||
|
|
||
| use crate::{ | ||
| address::Address, | ||
| keys::{FullViewingKey, SpendingKey}, | ||
| }; | ||
|
|
||
| /// Raw bytes representation of the reference recipient address. | ||
| pub const RAW_REFERENCE_RECIPIENT: [u8; 43] = [ | ||
| 204, 54, 96, 25, 89, 33, 59, 107, 12, 219, 150, 167, 92, 23, 195, 166, 104, 169, 127, 13, 106, | ||
| 140, 92, 225, 100, 165, 24, 234, 155, 169, 165, 14, 167, 81, 145, 253, 134, 27, 15, 241, 14, | ||
| 98, 176, | ||
| ]; | ||
|
|
||
| /// Reference keys (spending key and recipient address) are used for reference notes. | ||
| #[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
| pub struct ReferenceKeys; | ||
|
|
||
| impl ReferenceKeys { | ||
| /// Returns the spending key for reference notes. | ||
| pub fn sk() -> SpendingKey { | ||
| SpendingKey::from_bytes([0; 32]).unwrap() | ||
| } | ||
|
|
||
| /// Returns the recipient address for reference notes. | ||
| pub fn recipient() -> Address { | ||
| Address::from_raw_address_bytes(&RAW_REFERENCE_RECIPIENT).unwrap() | ||
| } | ||
|
|
||
| /// Returns the full viewing key for reference notes. | ||
| pub fn fvk() -> FullViewingKey { | ||
| FullViewingKey::from(&Self::sk()) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use crate::keys::{FullViewingKey, Scope}; | ||
|
|
||
| #[test] | ||
| fn recipient() { | ||
| let sk = SpendingKey::from_bytes([0; 32]).unwrap(); | ||
| let fvk = FullViewingKey::from(&sk); | ||
| let recipient = fvk.address_at(0u32, Scope::External); | ||
|
|
||
| assert_eq!(recipient, ReferenceKeys::recipient()); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.