Skip to content

Commit

Permalink
update ed25519 address scheme (cosmos#112)
Browse files Browse the repository at this point in the history
make PubKeyEd25519.Address() returns the first 20 bytes of the hash of the raw 32-byte pubkey, no amino required
  • Loading branch information
ebuchman authored and liamsi committed Jun 11, 2018
1 parent 66794a1 commit e694c30
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pub_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e694c30

Please sign in to comment.