keys

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost     = "localhost"
	DefaultPort     = "10997"
	DefaultHashType = "sha256"
	DefaultKeysDir  = ".keys"
	TestPort        = "7674"
)
View Source
const (
	CryptoNone    = "none"
	CryptoAESGCM  = "scrypt-aes-gcm"
	HashEd25519   = "go-crypto-0.5.0"
	HashSecp256k1 = "btc"
)

Variables

This section is empty.

Functions

func GetAllAddresses added in v0.19.0

func GetAllAddresses(dataDirPath string) (addresses [][]byte, err error)

func IsValidKeyJson added in v0.19.0

func IsValidKeyJson(j []byte) []byte

returns the address if valid, nil otherwise

func StartStandAloneServer added in v0.19.0

func StartStandAloneServer(keysDir, host, port string, AllowBadFilePermissions bool, logger *logging.Logger) error

func WriteKeyFile added in v0.19.0

func WriteKeyFile(addr []byte, dataDirPath string, content []byte) (err error)

Types

type Key added in v0.19.0

type Key struct {
	CurveType  crypto.CurveType
	Address    crypto.Address
	PublicKey  crypto.PublicKey
	PrivateKey crypto.PrivateKey
}

func DecryptKey added in v0.19.0

func DecryptKey(passphrase string, keyProtected *keyJSON) (*Key, error)

func NewKey added in v0.19.0

func NewKey(typ crypto.CurveType) (*Key, error)

func NewKeyFromPriv added in v0.19.0

func NewKeyFromPriv(curveType crypto.CurveType, PrivKeyBytes []byte) (*Key, error)

func NewKeyFromPub added in v0.19.0

func NewKeyFromPub(curveType crypto.CurveType, PubKeyBytes []byte) (*Key, error)

func (*Key) MarshalJSON added in v0.19.0

func (k *Key) MarshalJSON() (j []byte, err error)

func (*Key) Pubkey added in v0.19.0

func (k *Key) Pubkey() []byte

func (*Key) Sign added in v0.19.0

func (k *Key) Sign(hash []byte) ([]byte, error)

func (*Key) UnmarshalJSON added in v0.19.0

func (k *Key) UnmarshalJSON(j []byte) (err error)

type KeyClient

type KeyClient interface {
	// Sign returns the signature bytes for given message signed with the key associated with signAddress
	Sign(signAddress crypto.Address, message []byte) (signature crypto.Signature, err error)

	// PublicKey returns the public key associated with a given address
	PublicKey(address crypto.Address) (publicKey crypto.PublicKey, err error)

	// Generate requests that a key be generate within the keys instance and returns the address
	Generate(keyName string, keyType crypto.CurveType) (keyAddress crypto.Address, err error)

	// Returns nil if the keys instance is healthy, error otherwise
	HealthCheck() error
}

func NewLocalKeyClient added in v0.19.0

func NewLocalKeyClient(ks *KeyStore, logger *logging.Logger) KeyClient

func NewRemoteKeyClient added in v0.19.0

func NewRemoteKeyClient(rpcAddress string, logger *logging.Logger) (KeyClient, error)

keyClient.New returns a new monax-keys client for provided rpc location Monax-keys connects over http request-responses

type KeyStore added in v0.19.0

type KeyStore struct {
	sync.Mutex
	AllowBadFilePermissions bool
	// contains filtered or unexported fields
}

func NewKeyStore added in v0.19.0

func NewKeyStore(dir string, AllowBadFilePermissions bool, logger *logging.Logger) *KeyStore

func (*KeyStore) AddName added in v0.19.0

func (*KeyStore) AllKeys added in v0.19.0

func (ks *KeyStore) AllKeys() ([]*Key, error)

func (*KeyStore) DeleteKey added in v0.19.0

func (ks *KeyStore) DeleteKey(passphrase string, keyAddr []byte) (err error)

func (*KeyStore) Export added in v0.19.0

func (*KeyStore) Gen added in v0.19.0

func (ks *KeyStore) Gen(passphrase string, curveType crypto.CurveType) (key *Key, err error)

func (*KeyStore) GenerateKey added in v0.19.0

func (k *KeyStore) GenerateKey(ctx context.Context, in *pbkeys.GenRequest) (*pbkeys.GenResponse, error)

func (*KeyStore) GetAllAddresses added in v0.19.0

func (ks *KeyStore) GetAllAddresses() (addresses [][]byte, err error)

func (*KeyStore) GetAllNames added in v0.19.0

func (ks *KeyStore) GetAllNames() (map[string]string, error)

func (*KeyStore) GetKey added in v0.19.0

func (ks *KeyStore) GetKey(passphrase string, keyAddr []byte) (*Key, error)

func (*KeyStore) GetKeyFile added in v0.19.0

func (ks *KeyStore) GetKeyFile(dataDirPath string, keyAddr []byte) (fileContent []byte, err error)

func (*KeyStore) Hash added in v0.19.0

func (*KeyStore) Import added in v0.19.0

func (*KeyStore) ImportJSON added in v0.19.0

func (*KeyStore) List added in v0.19.0

func (*KeyStore) PublicKey added in v0.19.0

func (k *KeyStore) PublicKey(ctx context.Context, in *pbkeys.PubRequest) (*pbkeys.PubResponse, error)

func (*KeyStore) RemoveName added in v0.19.0

func (*KeyStore) Sign added in v0.19.0

func (*KeyStore) StoreKey added in v0.19.0

func (ks *KeyStore) StoreKey(passphrase string, key *Key) error

func (*KeyStore) StoreKeyEncrypted added in v0.19.0

func (ks *KeyStore) StoreKeyEncrypted(passphrase string, key *Key) error

func (*KeyStore) StoreKeyPlain added in v0.19.0

func (ks *KeyStore) StoreKeyPlain(key *Key) (err error)

func (*KeyStore) Verify added in v0.19.0

type KeysConfig added in v0.18.0

type KeysConfig struct {
	GRPCServiceEnabled      bool
	AllowBadFilePermissions bool
	RemoteAddress           string
	KeysDirectory           string
}

func DefaultKeysConfig added in v0.18.0

func DefaultKeysConfig() *KeysConfig

type Signer added in v0.18.0

type Signer struct {
	// contains filtered or unexported fields
}

func AddressableSigner added in v0.19.0

func AddressableSigner(keyClient KeyClient, address crypto.Address) (*Signer, error)

Creates a AddressableSigner that assumes the address holds an Ed25519 key

func (*Signer) Address added in v0.19.0

func (ms *Signer) Address() crypto.Address

func (*Signer) PublicKey added in v0.19.0

func (ms *Signer) PublicKey() crypto.PublicKey

func (*Signer) Sign added in v0.19.0

func (ms *Signer) Sign(messsage []byte) (crypto.Signature, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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