wallet

package
v0.0.0-...-fcbc9cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Key

type Key interface {
	Sign(id string, data []byte) (signature []byte, err error)
	Verify(crypto.PublicKey, []byte) (signature []byte, err error)
}

type KeyType

type KeyType string
const Ed25519VerificationKey2018Type KeyType = "Ed25519VerificationKey2018"

type Storage

type Storage interface {
	// contains filtered or unexported methods
}

func NewCouchDbStorage

func NewCouchDbStorage(dbname string) (Storage, error)

func NewInMemoryStorage

func NewInMemoryStorage() Storage

type Wallet

type Wallet interface {
	Create(id string, item interface{}) error
	Read(id string, out interface{}) error
	Update(id string, item interface{}) error
	Delete(id string) error

	CreateKey(typ KeyType) (string, error)
	DeleteKey(id string) error
	KeyExists(id string) bool

	Encrypt(id string, data []byte) (ciphertext []byte, err error)
	Decrypt(id string, ciphertext []byte) (data []byte, err error)

	Sign(id string, data []byte) ([]byte, error)
	Verify(id string, data []byte, sig []byte) bool

	Seal(message []byte, receiverKey, senderKey string) (encrypted []byte, nonce [24]byte, err error)
	SealAnonymous(message []byte, receiverKey string) (encrypted []byte, err error)
	Open(ciphertext []byte, nonce []byte, senderKey, receiverKey string) (plaintext []byte, res bool)
	OpenAnonymous(ciphertext []byte, receiverKey string) (plaintext []byte, res bool)
}

func NewWallet

func NewWallet(password string, s Storage) (Wallet, error)

func NewWalletWithWrapper

func NewWalletWithWrapper(password string, storage Storage, wrapper Wrapper) (Wallet, error)

type Wrapper

type Wrapper interface {
	Wrap(secret []byte) (wrappedSecret []byte)
	Unwrap(wrappedSecret []byte) (secret []byte)
}

Implementations of the Wrapper interface should wrap secrets by encrypting them with keys stored in a secure enclave or HSM.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL