PubKeyHash generates the account hash address for specified public key.
(pubKey *asymmetric.PublicKey)
| 26 | |
| 27 | // PubKeyHash generates the account hash address for specified public key. |
| 28 | func PubKeyHash(pubKey *asymmetric.PublicKey) (addr proto.AccountAddress, err error) { |
| 29 | if pubKey == nil { |
| 30 | err = errors.New("nil public key") |
| 31 | return |
| 32 | } |
| 33 | var enc []byte |
| 34 | |
| 35 | if enc, err = pubKey.MarshalHash(); err != nil { |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | addr = proto.AccountAddress(hash.THashH(enc)) |
| 40 | return |
| 41 | } |