mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
Update key.go
This commit is contained in:
parent
4414e2833f
commit
49ab541ce1
1 changed files with 15 additions and 14 deletions
|
|
@ -146,6 +146,7 @@ func newKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
|
||||||
// into the Direct ICAP spec. for simplicity and easier compatibility with other libs, we
|
// into the Direct ICAP spec. for simplicity and easier compatibility with other libs, we
|
||||||
// retry until the first byte is 0.
|
// retry until the first byte is 0.
|
||||||
func NewKeyForDirectICAP(rand io.Reader) *Key {
|
func NewKeyForDirectICAP(rand io.Reader) *Key {
|
||||||
|
for {
|
||||||
randBytes := make([]byte, 64)
|
randBytes := make([]byte, 64)
|
||||||
_, err := rand.Read(randBytes)
|
_, err := rand.Read(randBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -157,10 +158,10 @@ func NewKeyForDirectICAP(rand io.Reader) *Key {
|
||||||
panic("key generation: ecdsa.GenerateKey failed: " + err.Error())
|
panic("key generation: ecdsa.GenerateKey failed: " + err.Error())
|
||||||
}
|
}
|
||||||
key := newKeyFromECDSA(privateKeyECDSA)
|
key := newKeyFromECDSA(privateKeyECDSA)
|
||||||
if !strings.HasPrefix(key.Address.Hex(), "0x00") {
|
if strings.HasPrefix(key.Address.Hex(), "0x00") {
|
||||||
return NewKeyForDirectICAP(rand)
|
|
||||||
}
|
|
||||||
return key
|
return key
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newKey(rand io.Reader) (*Key, error) {
|
func newKey(rand io.Reader) (*Key, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue