tendermint/keys/types.go

44 lines
1.1 KiB
Go
Raw Normal View History

package keys
import (
2017-11-02 18:32:12 -05:00
wire "github.com/tendermint/go-wire"
crypto "github.com/tendermint/go-crypto"
)
2017-02-28 18:52:52 +01:00
// Info is the public information about a key
type Info struct {
2017-11-01 16:38:11 -05:00
Name string `json:"name"`
PubKey crypto.PubKey `json:"pubkey"`
}
2017-11-02 18:32:12 -05:00
func (i Info) bytes() []byte {
return wire.BinaryBytes(i)
}
func readInfo(bs []byte) (info Info, err error) {
err = wire.ReadBinaryBytes(bs, &info)
return
}
2017-11-02 16:46:10 -05:00
func info(name string, privKey crypto.PrivKey) Info {
return Info{
Name: name,
PubKey: privKey.PubKey(),
}
}
2017-11-01 16:38:11 -05:00
// Keybase allows simple CRUD on a keystore, as an aid to signing
type Keybase interface {
// Sign some bytes
2017-11-02 16:31:29 -05:00
Sign(name, passphrase string, msg []byte) (crypto.Signature, crypto.PubKey, error)
2017-11-01 16:38:11 -05:00
// Create a new keypair
Create(name, passphrase, algo string) (_ Info, seedphrase string, _ error)
// Recover takes a seedphrase and loads in the key
Recover(name, passphrase, seedphrase string) (Info, error)
2017-11-02 16:31:29 -05:00
List() ([]Info, error)
2017-02-28 18:52:52 +01:00
Get(name string) (Info, error)
Update(name, oldpass, newpass string) error
Delete(name, passphrase string) error
}