File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ and this project adheres to Rust's notion of
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Added
11
+ - ` orchard::pczt::Zip32Derivation::extract_account_index `
12
+
10
13
### Changed
11
14
- Migrated to ` nonempty 0.11 ` .
12
15
Original file line number Diff line number Diff line change @@ -301,6 +301,35 @@ pub struct Zip32Derivation {
301
301
derivation_path : Vec < ChildIndex > ,
302
302
}
303
303
304
+ impl Zip32Derivation {
305
+ /// Extracts the ZIP 32 account index from this derivation path.
306
+ ///
307
+ /// Returns `None` if the seed fingerprints don't match, or if this is a non-standard
308
+ /// derivation path.
309
+ pub fn extract_account_index (
310
+ & self ,
311
+ seed_fp : & zip32:: fingerprint:: SeedFingerprint ,
312
+ expected_coin_type : zip32:: ChildIndex ,
313
+ ) -> Option < zip32:: AccountId > {
314
+ if self . seed_fingerprint == seed_fp. to_bytes ( ) {
315
+ match & self . derivation_path [ ..] {
316
+ [ purpose, coin_type, account_index]
317
+ if purpose == & zip32:: ChildIndex :: hardened ( 32 )
318
+ && coin_type == & expected_coin_type =>
319
+ {
320
+ Some (
321
+ zip32:: AccountId :: try_from ( account_index. index ( ) - ( 1 << 31 ) )
322
+ . expect ( "zip32::ChildIndex only supports hardened" ) ,
323
+ )
324
+ }
325
+ _ => None ,
326
+ }
327
+ } else {
328
+ None
329
+ }
330
+ }
331
+ }
332
+
304
333
#[ cfg( test) ]
305
334
mod tests {
306
335
use bridgetree:: BridgeTree ;
Original file line number Diff line number Diff line change @@ -56,8 +56,10 @@ impl super::Spend {
56
56
/// - `rho`
57
57
/// - `rseed`
58
58
///
59
+ /// In addition, at least one of the `fvk` field or `expected_fvk` must be provided.
60
+ ///
59
61
/// The provided [`FullViewingKey`] is ignored if the spent note is a dummy note.
60
- /// Otherwise, it will be checked against the `fvk` field (if set).
62
+ /// Otherwise, it will be checked against the `fvk` field (if both are set).
61
63
pub fn verify_nullifier (
62
64
& self ,
63
65
expected_fvk : Option < & FullViewingKey > ,
You can’t perform that action at this time.
0 commit comments