Documentation ¶
Overview ¶
Package crypto provides key and address creation functions.
Index ¶
- Variables
- func BytesToPushKeyID(pk []byte) string
- func ConvertBase58PrivKeyToTMPrivKey(b58PrivKey string) (ed25519.PrivKey, error)
- func ConvertBase58PubKeyToTMPubKey(b58PubKey string) (ed25519.PubKey, error)
- func CreatePushKeyID(pk PublicKey) string
- func DecodeAddr(addr string) ([20]byte, error)
- func DecodeAddrOnly(addr string) ([20]byte, error)
- func IsValidPrivKey(privKey string) error
- func IsValidPubKey(pubKey string) error
- func IsValidPushAddr(addr string) error
- func IsValidUserAddr(addr string) error
- func MustBase58FromPubKeyBytes(pk []byte) string
- func RIPEMD160ToAddr(hash [20]byte) util.String
- func ToBase58PubKey(bz util.Bytes32) string
- type FilePV
- type Key
- type PrivKey
- func (p *PrivKey) BLSKey() *bdn.PrivateKey
- func (p *PrivKey) Base58() string
- func (p *PrivKey) Bytes() ([]byte, error)
- func (p *PrivKey) Bytes64() (util.Bytes64, error)
- func (p *PrivKey) Key() crypto.PrivKey
- func (p *PrivKey) Marshal() ([]byte, error)
- func (p *PrivKey) MustBytes() []byte
- func (p *PrivKey) MustSign(data []byte) []byte
- func (p *PrivKey) Sign(data []byte) ([]byte, error)
- func (p *PrivKey) VRFKey() vrf.PrivateKey
- type PubKey
- func (p *PubKey) Addr() identifier.Address
- func (p *PubKey) AddrRaw() []byte
- func (p *PubKey) Base58() string
- func (p *PubKey) Bytes() ([]byte, error)
- func (p *PubKey) Hex() string
- func (p *PubKey) MustBytes() []byte
- func (p *PubKey) MustBytes32() util.Bytes32
- func (p *PubKey) PushAddr() identifier.Address
- func (p *PubKey) ToPublicKey() PublicKey
- func (p *PubKey) Verify(data, sig []byte) (bool, error)
- type PublicKey
- func (pk PublicKey) Bytes() []byte
- func (pk PublicKey) Equal(o PublicKey) bool
- func (pk PublicKey) Hex() []byte
- func (pk PublicKey) HexStr() string
- func (pk PublicKey) IsEmpty() bool
- func (pk PublicKey) MarshalJSON() ([]byte, error)
- func (pk PublicKey) MustAddress() identifier.Address
- func (pk PublicKey) MustAddressRaw() []byte
- func (pk PublicKey) MustPushKeyAddress() identifier.Address
- func (pk PublicKey) String() string
- func (pk PublicKey) ToBytes32() util.Bytes32
- type PushKey
Constants ¶
This section is empty.
Variables ¶
var EmptyPublicKey = PublicKey([util.Length32]byte{})
EmptyPublicKey is an empty PublicKey
Functions ¶
func BytesToPushKeyID ¶
BytesToPushKeyID returns bech32 address corresponding to a push key. Panics if pk is not a valid ed25519 public key
func ConvertBase58PrivKeyToTMPrivKey ¶
ConvertBase58PrivKeyToTMPrivKey converts base58 private key to tendermint's ed25519.PrivKeyEd25519
func ConvertBase58PubKeyToTMPubKey ¶
ConvertBase58PubKeyToTMPubKey converts base58 public key to tendermint's ed25519.PubKeyEd25519
func CreatePushKeyID ¶
CreatePushKeyID returns bech32 address corresponding to a push key. Panics if pk is not a valid ed25519 public key
func DecodeAddr ¶
DecodeAddr validates an address, decodes it and returns raw encoded 20-bytes address
func DecodeAddrOnly ¶
DecodeAddrOnly is like DecodeAddr except it does not validate the address
func IsValidPrivKey ¶
IsValidPrivKey checks whether a private key is valid
func IsValidPubKey ¶
IsValidPubKey checks whether a public key is valid
func IsValidPushAddr ¶
IsValidPushAddr checks whether addr is a valid network push address
func IsValidUserAddr ¶
IsValidUserAddr checks whether addr is a valid user account address
func MustBase58FromPubKeyBytes ¶
MustBase58FromPubKeyBytes takes a raw public key bytes and returns its base58 encoded version. It panics if pk is invalid
func RIPEMD160ToAddr ¶
RIPEMD160ToAddr returns a 20 byte slice to an address
func ToBase58PubKey ¶
ToBase58PubKey tries to convert the bytes to a base58-encoded public key. Panics if unable to convert.
Types ¶
type FilePV ¶
FilePV wraps and extends tendermint's privval.FilePV
func GenerateWrappedPV ¶
GenerateWrappedPV generate a wrapped tendermint private validator key
type Key ¶
type Key struct { Meta map[string]interface{} // contains filtered or unexported fields }
Key includes a wrapped Ed25519 private key and convenient methods to get the corresponding public key and transaction address.
func NewKeyFromIntSeed ¶
NewKeyFromIntSeed is like NewKey but accepts seed of type Int and casts to Int64.
func NewKeyFromPrivKey ¶
NewKeyFromPrivKey creates a new Key instance from a PrivKey
func (*Key) Addr ¶
func (k *Key) Addr() identifier.Address
Addr returns the network account address corresponding the key
func (*Key) PushAddr ¶
func (k *Key) PushAddr() identifier.Address
PushAddr returns the network pusher address corresponding the key
type PrivKey ¶
type PrivKey struct {
// contains filtered or unexported fields
}
PrivKey represents a private key
func PrivKeyFromBase58 ¶
PrivKeyFromBase58 decodes a base58 encoded private key
func PrivKeyFromBytes ¶
PrivKeyFromBytes returns a PrivKey instance from a 64 bytes private key
func PrivKeyFromTMPrivateKey ¶
PrivKeyFromTMPrivateKey encodes a tendermint private key to PrivKey
func (*PrivKey) BLSKey ¶
func (p *PrivKey) BLSKey() *bdn.PrivateKey
BLSKey derives a BLS key using the PrivKey as seed. It uses the first 32 bytes of the private key to seed the BLS key generator. TODO: Use actual BLS private key instead of BN256
func (*PrivKey) VRFKey ¶
func (p *PrivKey) VRFKey() vrf.PrivateKey
VRFKey derives a VRF key using the PrivKey as seed.
type PubKey ¶
type PubKey struct {
// contains filtered or unexported fields
}
PubKey represents a public key
func MustPubKeyFromBytes ¶
MustPubKeyFromBytes is like PubKeyFromBytes, except it panics if pk is invalid
func PubKeyFromBase58 ¶
PubKeyFromBase58 decodes a base58 encoded public key
func PubKeyFromBytes ¶
PubKeyFromBytes returns a PubKey instance from a 32 bytes public key
func (*PubKey) Addr ¶
func (p *PubKey) Addr() identifier.Address
Addr returns the bech32 account address
func (*PubKey) MustBytes32 ¶
MustBytes32 is like Bytes but panics on error
func (*PubKey) PushAddr ¶
func (p *PubKey) PushAddr() identifier.Address
PushAddr returns a bech32 pusher address
func (*PubKey) ToPublicKey ¶
ToPublicKey returns the public key wrap in PublicKey
type PublicKey ¶
PublicKey represents a 32-byte ED25519 public key
func BytesToPublicKey ¶
BytesToPublicKey copies b to a PublicKey
func StrToPublicKey ¶
StrToPublicKey converts a string to a PublicKey
func (PublicKey) MarshalJSON ¶
func (PublicKey) MustAddress ¶
func (pk PublicKey) MustAddress() identifier.Address
MustAddress derives an address from the key. Panics on failure.
func (PublicKey) MustAddressRaw ¶ added in v0.0.29
MustAddressRaw derives a raw address from the key. Panics on failure.
func (PublicKey) MustPushKeyAddress ¶
func (pk PublicKey) MustPushKeyAddress() identifier.Address
MustPushKeyAddress derives a push key address from the key. Panics on failure.