Skip to content

Commit

Permalink
Merge pull request #129 from zcash/release-0.1.2
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
str4d authored Mar 8, 2024
2 parents f221946 + 291a1ac commit 2122dbe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
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

0 comments on commit 2122dbe

Please sign in to comment.