ed25519_bip32/derivation/
common.rs

1#[derive(Debug, PartialEq, Eq)]
2pub enum DerivationType {
3    Soft(u32),
4    Hard(u32),
5}
6
7/// Derivation index is a 32 bits number representing
8/// a type of derivation and a 31 bits number.
9///
10/// The highest bit set represent a hard derivation,
11/// whereas the bit clear represent soft derivation.
12pub type DerivationIndex = u32;
13
14impl DerivationType {
15    pub fn from_index(index: DerivationIndex) -> Self {
16        if index >= 0x80000000 {
17            DerivationType::Hard(index)
18        } else {
19            DerivationType::Soft(index)
20        }
21    }
22}
23
24/// Ed25519-bip32 Scheme Derivation version
25///
26/// Only V2 is supported anymore, and this is
27/// left as an API compatibility type. V1 has
28/// been removed due to some shortcomings
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum DerivationScheme {
31    V2,
32}
33
34impl Default for DerivationScheme {
35    fn default() -> Self {
36        DerivationScheme::V2
37    }
38}