@@ -19,11 +19,10 @@ extension UInt32 {
19
19
let byteArray = Array ( bytePtr)
20
20
return Data ( byteArray)
21
21
}
22
- static var maxIterationIndex = UInt32 ( 1 ) << 31
23
22
}
24
23
25
24
public class HDNode {
26
-
25
+ static var maxIterationIndex = UInt32 ( 1 ) << 31
27
26
private struct HDversion {
28
27
public static var privatePrefix : Data ? = Data . fromHex ( " 0x0488ADE4 " )
29
28
public static var publicPrefix : Data ? = Data . fromHex ( " 0x0488B21E " )
@@ -37,11 +36,11 @@ public class HDNode {
37
36
public var parentFingerprint : Data = Data ( repeating: 0 , count: 4 )
38
37
public var childNumber : UInt32 = UInt32 ( 0 )
39
38
public var isHardened : Bool {
40
- childNumber >= UInt32 . maxIterationIndex
39
+ childNumber >= Self . maxIterationIndex
41
40
}
42
41
public var index : UInt32 {
43
42
if self . isHardened {
44
- return childNumber - UInt32 . maxIterationIndex
43
+ return childNumber - Self . maxIterationIndex
45
44
} else {
46
45
return childNumber
47
46
}
@@ -113,7 +112,7 @@ public class HDNode {
113
112
public static var defaultPathPrefix : String = " m/44'/60'/0' "
114
113
public static var defaultPathMetamask : String = " m/44'/60'/0'/0/0 "
115
114
public static var defaultPathMetamaskPrefix : String = " m/44'/60'/0'/0 "
116
- public static var hardenedIndexPrefix : UInt32 = UInt32 . maxIterationIndex
115
+ public static var hardenedIndexPrefix : UInt32 { Self . maxIterationIndex }
117
116
}
118
117
119
118
extension HDNode {
@@ -127,7 +126,7 @@ extension HDNode {
127
126
128
127
public func deriveWithoutPrivateKey( index: UInt32 , hardened: Bool = false ) -> HDNode ? {
129
128
var entropy : [ UInt8 ] // derive public key when is itself public key
130
- if index >= UInt32 . maxIterationIndex || hardened {
129
+ if index >= Self . maxIterationIndex || hardened {
131
130
return nil // no derivation of hardened public key from extended public key
132
131
} else {
133
132
let hmac : Authenticator = HMAC ( key: self . chaincode. bytes, variant: . sha2( . sha512) )
@@ -181,10 +180,10 @@ extension HDNode {
181
180
}
182
181
var entropy : [ UInt8 ]
183
182
var trueIndex : UInt32
184
- if index >= UInt32 . maxIterationIndex || hardened {
183
+ if index >= Self . maxIterationIndex || hardened {
185
184
trueIndex = index
186
- if trueIndex < UInt32 . maxIterationIndex {
187
- trueIndex = trueIndex + UInt32 . maxIterationIndex
185
+ if trueIndex < Self . maxIterationIndex {
186
+ trueIndex = trueIndex + Self . maxIterationIndex
188
187
}
189
188
let hmac : Authenticator = HMAC ( key: self . chaincode. bytes, variant: . sha2( . sha512) )
190
189
var inputForHMAC = Data ( )
0 commit comments