Browse Source

update ed25519 address scheme (#112)

make PubKeyEd25519.Address() returns the first 20 bytes of the hash of the raw 32-byte pubkey, no amino required
pull/1782/head
Ethan Buchman 7 years ago
committed by Ismail Khoffi
parent
commit
e694c309ba
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      pub_key.go

+ 8
- 5
pub_key.go View File

@ -5,11 +5,16 @@ import (
"crypto/sha256"
"fmt"
"golang.org/x/crypto/ripemd160"
secp256k1 "github.com/btcsuite/btcd/btcec"
"github.com/tendermint/ed25519"
"github.com/tendermint/ed25519/extra25519"
cmn "github.com/tendermint/tmlibs/common"
"golang.org/x/crypto/ripemd160"
"github.com/tendermint/go-crypto/tmhash"
)
// An address is a []byte, but hex-encoded even in JSON.
@ -38,11 +43,9 @@ var _ PubKey = PubKeyEd25519{}
// Implements PubKeyInner
type PubKeyEd25519 [32]byte
// Address is the SHA256-20 of the raw pubkey bytes.
func (pubKey PubKeyEd25519) Address() Address {
// append type byte
hasher := ripemd160.New()
hasher.Write(pubKey.Bytes()) // does not error
return Address(hasher.Sum(nil))
return Address(tmhash.Sum(pubKey[:]))
}
func (pubKey PubKeyEd25519) Bytes() []byte {


Loading…
Cancel
Save