Skip to content

Commit bd491c9

Browse files
author
sammyne
committed
docs(PublicKey): clean up some redundant codes
1 parent 73c380f commit bd491c9

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

public_key.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
type PublicKey struct {
1717
ChainCode []byte
1818
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()
2121
ParentFP []byte
2222
Version []byte
2323
}
@@ -60,12 +60,11 @@ func (pub *PublicKey) Child(i uint32) (ExtendedKey, error) {
6060
IL, chainCode := I[:len(I)/2], I[len(I)/2:]
6161

6262
// 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
6464
// within the valid range for a secp256k1 private key. There is a small
6565
// chance (< 1 in 2^127) this condition will not hold, and in that case,
6666
// a child extended key can't be created for this index and the caller
6767
// should simply increment to the next index.
68-
//if !ScalarUsable(IL) {
6968
if _, ok := ToUsableScalar(IL); !ok {
7069
return nil, ErrInvalidChild
7170
}
@@ -152,14 +151,12 @@ func (pub *PublicKey) String() string {
152151
// version (4) || depth (1) || parent fingerprint (4)) ||
153152
// child num (4) || chain code (32) || key data (33)
154153
str := make([]byte, 0, KeyLen-VersionLen)
155-
//str = append(str, pub.Version...)
156154
str = append(str, pub.Level)
157155
str = append(str, pub.ParentFP...)
158156
str = append(str, childIndex[:]...)
159157
str = append(str, pub.ChainCode...)
160158
str = append(str, pub.Data...)
161159

162-
//return base58.CheckEncode()
163160
return base58.CheckEncodeX(str, pub.Version...)
164161
}
165162

@@ -199,11 +196,8 @@ func ParsePublicKey(data58 string) (*PublicKey, error) {
199196
// where the version has separated from decoded
200197

201198
// decompose the decoded payload into fields
202-
//a, b := 0, VersionLen
203-
//pub.Version = decoded[a:b]
204199
pub.Version = version
205200

206-
//a, b = b, b+DepthLen
207201
a, b := 0, DepthLen
208202
pub.Level = decoded[a:b][0]
209203

0 commit comments

Comments
 (0)