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

Release 0.1.2 #129

Merged
merged 2 commits into from
Mar 8, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this library adheres to Rust's notion of

## [Unreleased]

## Added
## [0.1.2] - 2024-03-08
### Added
- `sapling_crypto::zip32::IncomingViewingKey`
- `sapling_crypto::zip32::DiversifiableFullViewingKey::to_external_ivk`

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sapling-crypto"
version = "0.1.1"
version = "0.1.2"
authors = [
"Sean Bowe <[email protected]>",
"Jack Grigg <[email protected]>",
Expand Down
29 changes: 29 additions & 0 deletions src/zip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,25 @@ mod tests {
assert_eq!(dfvk_parsed.to_bytes(), dfvk_bytes);
}

#[test]
fn ivk_round_trip() {
let ivk = {
let extsk = ExtendedSpendingKey::master(&[]);
#[allow(deprecated)]
let extfvk = extsk.to_extended_full_viewing_key();
DiversifiableFullViewingKey::from(extfvk).to_external_ivk()
};

// Check value -> bytes -> parsed round trip.
let ivk_bytes = ivk.to_bytes();
let ivk_parsed = IncomingViewingKey::from_bytes(&ivk_bytes).unwrap();
assert_eq!(ivk_parsed.dk, ivk.dk);
assert_eq!(ivk_parsed.ivk.0, ivk.ivk.0);

// Check bytes -> parsed -> bytes round trip.
assert_eq!(ivk_parsed.to_bytes(), ivk_bytes);
}

#[test]
fn address() {
let seed = [0; 32];
Expand Down Expand Up @@ -1818,6 +1837,16 @@ mod tests {
internal_xfvk.write(&mut ser).unwrap();
assert_eq!(&ser[..], &tv.internal_xfvk[..]);
assert_eq!(FvkFingerprint::from(&internal_xfvk.fvk).0, tv.internal_fp);

let dfvk = xfvk.to_diversifiable_full_viewing_key();
let ivk = dfvk.to_external_ivk();
let ivk_bytes = ivk.to_bytes();
assert_eq!(&ivk_bytes[..32], tv.dk);
assert_eq!(&ivk_bytes[32..], tv.ivk);

let ivk_rt = IncomingViewingKey::from_bytes(&ivk_bytes).unwrap();
assert_eq!(ivk.dk, ivk_rt.dk);
assert_eq!(ivk.ivk.0, ivk_rt.ivk.0);
}
}
}
Expand Down