github.com/tickstep/library-go@v0.1.1/crypto/crypto.go (about)

     1  package crypto
     2  
     3  import (
     4  	"github.com/tickstep/library-go/bytes"
     5  )
     6  
     7  // An address is a []byte, but hex-encoded even in JSON.
     8  // []byte leaves us the option to change the address length.
     9  // Use an alias so Unmarshal methods (with ptr receivers) are available too.
    10  type Address = bytes.HexBytes
    11  
    12  type PubKey interface {
    13  	Address() Address
    14  	Bytes() []byte
    15  	VerifySignature(msg []byte, sig []byte) bool
    16  	Equals(PubKey) bool
    17  	Type() string
    18  }
    19  
    20  type PrivKey interface {
    21  	Bytes() []byte
    22  	Sign(msg []byte) ([]byte, error)
    23  	PubKey() PubKey
    24  	Equals(PrivKey) bool
    25  	Type() string
    26  }
    27  
    28  type Symmetric interface {
    29  	Keygen() []byte
    30  	Encrypt(plaintext []byte, secret []byte) (ciphertext []byte)
    31  	Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error)
    32  }