@@ -16,8 +16,8 @@ import (
16
16
type PublicKey struct {
17
17
ChainCode []byte
18
18
ChildIndex uint32 // this is the Index-th child of its parent
19
- Data []byte
20
- Level uint8 // name so to avoid conflict with method Depth()
19
+ Data []byte // the serialized data in the compressed form
20
+ Level uint8 // name so to avoid conflict with method Depth()
21
21
ParentFP []byte
22
22
Version []byte
23
23
}
@@ -60,12 +60,11 @@ func (pub *PublicKey) Child(i uint32) (ExtendedKey, error) {
60
60
IL , chainCode := I [:len (I )/ 2 ], I [len (I )/ 2 :]
61
61
62
62
// Both derived public or private keys rely on treating the left 32-byte
63
- // sequence calculated above (Il ) as a 256-bit integer that must be
63
+ // sequence calculated above (IL ) as a 256-bit integer that must be
64
64
// within the valid range for a secp256k1 private key. There is a small
65
65
// chance (< 1 in 2^127) this condition will not hold, and in that case,
66
66
// a child extended key can't be created for this index and the caller
67
67
// should simply increment to the next index.
68
- //if !ScalarUsable(IL) {
69
68
if _ , ok := ToUsableScalar (IL ); ! ok {
70
69
return nil , ErrInvalidChild
71
70
}
@@ -152,14 +151,12 @@ func (pub *PublicKey) String() string {
152
151
// version (4) || depth (1) || parent fingerprint (4)) ||
153
152
// child num (4) || chain code (32) || key data (33)
154
153
str := make ([]byte , 0 , KeyLen - VersionLen )
155
- //str = append(str, pub.Version...)
156
154
str = append (str , pub .Level )
157
155
str = append (str , pub .ParentFP ... )
158
156
str = append (str , childIndex [:]... )
159
157
str = append (str , pub .ChainCode ... )
160
158
str = append (str , pub .Data ... )
161
159
162
- //return base58.CheckEncode()
163
160
return base58 .CheckEncodeX (str , pub .Version ... )
164
161
}
165
162
@@ -199,11 +196,8 @@ func ParsePublicKey(data58 string) (*PublicKey, error) {
199
196
// where the version has separated from decoded
200
197
201
198
// decompose the decoded payload into fields
202
- //a, b := 0, VersionLen
203
- //pub.Version = decoded[a:b]
204
199
pub .Version = version
205
200
206
- //a, b = b, b+DepthLen
207
201
a , b := 0 , DepthLen
208
202
pub .Level = decoded [a :b ][0 ]
209
203
0 commit comments