github.com/project-88388/tendermint-v0.34.14-terra.2@v1.0.0/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  	VerifySignature(msg []byte, sig []byte) bool
    26  	Equals(PubKey) bool
    27  	Type() string
    28  }
    29  
    30  type PrivKey interface {
    31  	Bytes() []byte
    32  	Sign(msg []byte) ([]byte, error)
    33  	PubKey() PubKey
    34  	Equals(PrivKey) bool
    35  	Type() string
    36  }
    37  
    38  type Symmetric interface {
    39  	Keygen() []byte
    40  	Encrypt(plaintext []byte, secret []byte) (ciphertext []byte)
    41  	Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error)
    42  }