tendermint/keys/types.go

49 lines
1.2 KiB
Go
Raw Normal View History

package keys
import (
2017-11-02 16:32:12 -07:00
wire "github.com/tendermint/go-wire"
crypto "github.com/tendermint/go-crypto"
)
2017-02-28 09:52:52 -08:00
// Info is the public information about a key
type Info struct {
2017-11-01 14:38:11 -07:00
Name string `json:"name"`
PubKey crypto.PubKey `json:"pubkey"`
}
2017-11-02 16:45:37 -07:00
// Address is a helper function to calculate the address from the pubkey
func (i Info) Address() []byte {
return i.PubKey.Address()
}
2017-11-02 16:32:12 -07: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 14:46:10 -07:00
func info(name string, privKey crypto.PrivKey) Info {
return Info{
Name: name,
PubKey: privKey.PubKey(),
}
}
2017-11-01 14:38:11 -07:00
// Keybase allows simple CRUD on a keystore, as an aid to signing
type Keybase interface {
// Sign some bytes
2017-11-02 14:31:29 -07:00
Sign(name, passphrase string, msg []byte) (crypto.Signature, crypto.PubKey, error)
2017-11-01 14:38:11 -07:00
// Create a new keypair
2017-12-30 14:02:18 -08:00
Create(name, passphrase, algo string) (seedphrase string, _ Info, _ error)
2017-11-01 14:38:11 -07:00
// Recover takes a seedphrase and loads in the key
2017-12-30 14:02:18 -08:00
Recover(name, passphrase, algo, seedphrase string) (Info, error)
2017-11-02 14:31:29 -07:00
List() ([]Info, error)
2017-02-28 09:52:52 -08:00
Get(name string) (Info, error)
Update(name, oldpass, newpass string) error
Delete(name, passphrase string) error
}