Browse Source

Revert Address() scheme change

pull/1782/head
Jae Kwon 8 years ago
parent
commit
8152c18c35
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      pub_key.go

+ 8
- 2
pub_key.go View File

@ -41,9 +41,15 @@ func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error) {
type PubKeyEd25519 [32]byte
func (pubKey PubKeyEd25519) Address() []byte {
pubKeyBytes := pubKey.Bytes()
w, n, err := new(bytes.Buffer), new(int), new(error)
wire.WriteBinary(pubKey[:], w, n, err)
if *err != nil {
PanicCrisis(*err)
}
// append type byte
encodedPubkey := append([]byte{1}, w.Bytes()...)
hasher := ripemd160.New()
hasher.Write(pubKeyBytes) // does not error
hasher.Write(encodedPubkey) // does not error
return hasher.Sum(nil)
}


Loading…
Cancel
Save