github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/crypto/crypto.go (about) 1 package crypto 2 3 import ( 4 "github.com/tendermint/tendermint/crypto/tmhash" 5 "github.com/tendermint/tendermint/libs/bytes" 6 ) 7 8 const ( 9 // AddressSize is the size of a pubkey address. 10 AddressSize = tmhash.TruncatedSize 11 ) 12 13 // An address is a []byte, but hex-encoded even in JSON. 14 // []byte leaves us the option to change the address length. 15 // Use an alias so Unmarshal methods (with ptr receivers) are available too. 16 type Address = bytes.HexBytes 17 18 func AddressHash(bz []byte) Address { 19 return Address(tmhash.SumTruncated(bz)) 20 } 21 22 type PubKey interface { 23 Address() Address 24 Bytes() []byte 25 VerifyBytes(msg []byte, sig []byte) bool 26 Equals(PubKey) bool 27 } 28 29 type PrivKey interface { 30 Bytes() []byte 31 Sign(msg []byte) ([]byte, error) 32 PubKey() PubKey 33 Equals(PrivKey) bool 34 } 35 36 type Symmetric interface { 37 Keygen() []byte 38 Encrypt(plaintext []byte, secret []byte) (ciphertext []byte) 39 Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error) 40 }