diff --git a/src/fingerprint.rs b/src/fingerprint.rs index 8c4cffb..e6acfeb 100644 --- a/src/fingerprint.rs +++ b/src/fingerprint.rs @@ -1,18 +1,21 @@ //! Seed Fingerprints according to ZIP 32 //! -//! Implements section `Seed Fingerprints` of Shielded Hierarchical Deterministic Wallets (ZIP 32) +//! Implements section [Seed Fingerprints] of Shielded Hierarchical Deterministic Wallets (ZIP 32). //! -//! [Section Seed Fingerprints]: https://zips.z.cash/zip-0032#seed-fingerprints +//! [Seed Fingerprints]: https://zips.z.cash/zip-0032#seed-fingerprints use blake2b_simd::Params as Blake2bParams; -pub const ZIP32_SEED_FP_PERSONALIZATION: &[u8; 16] = b"Zcash_HD_Seed_FP"; +const ZIP32_SEED_FP_PERSONALIZATION: &[u8; 16] = b"Zcash_HD_Seed_FP"; + +/// The fingerprint for a wallet's seed bytes, as defined in [ZIP 32]. +/// +/// [ZIP 32]: https://zips.z.cash/zip-0032#seed-fingerprints pub struct SeedFingerprint([u8; 32]); impl SeedFingerprint { - /// Return the seed fingerprint of the wallet as defined in - /// or None - /// if the length of `seed_bytes` is less than 32 or - /// greater than 252. + /// Derives the fingerprint of the given seed bytes. + /// + /// Returns `None` if the length of `seed_bytes` is less than 32 or greater than 252. pub fn from_seed(seed_bytes: &[u8]) -> Option { let seed_len = seed_bytes.len(); diff --git a/src/lib.rs b/src/lib.rs index 5e3357f..0dc5b44 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,8 @@ //! //! [ZIP 32]: https://zips.z.cash/zip-0032 +#![deny(missing_docs)] +#![deny(unsafe_code)] #![deny(rustdoc::broken_intra_doc_links)] use memuse::{self, DynamicUsage}; @@ -94,6 +96,7 @@ impl ChainCode { } } +/// The index for a particular diversifier. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct DiversifierIndex(pub [u8; 11]); @@ -128,10 +131,12 @@ impl TryFrom for u32 { } impl DiversifierIndex { + /// Constructs the zero index. pub fn new() -> Self { DiversifierIndex([0; 11]) } + /// Increments this index, failing on overflow. pub fn increment(&mut self) -> Result<(), ()> { for k in 0..11 { self.0[k] = self.0[k].wrapping_add(1);