Documentation ¶
Index ¶
- Constants
- func CRandBytes(numBytes int) []byte
- func CRandHex(numDigits int) string
- func CReader() io.Reader
- func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error)
- func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error)
- func EncodeArmor(blockType string, headers map[string]string, data []byte) string
- func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte)
- func MixEntropy(seedBytes []byte)
- func Ripemd160(bytes []byte) []byte
- func Sha256(bytes []byte) []byte
- type PrivKey
- type PrivKeyEd25519
- func (privKey *PrivKeyEd25519) Bytes() []byte
- func (privKey *PrivKeyEd25519) Equals(other PrivKey) bool
- func (privKey *PrivKeyEd25519) KeyString() string
- func (privKey *PrivKeyEd25519) MarshalJSON() ([]byte, error)
- func (privKey *PrivKeyEd25519) PubKey() PubKey
- func (privKey *PrivKeyEd25519) Sign(msg []byte) Signature
- func (privKey *PrivKeyEd25519) String() string
- func (privKey *PrivKeyEd25519) ToCurve25519() *[32]byte
- func (privKey *PrivKeyEd25519) UnmarshalJSON(data []byte) error
- type PrivKeySecp256k1
- func (privKey *PrivKeySecp256k1) Bytes() []byte
- func (privKey *PrivKeySecp256k1) Equals(other PrivKey) bool
- func (privKey *PrivKeySecp256k1) KeyString() string
- func (privKey *PrivKeySecp256k1) MarshalJSON() ([]byte, error)
- func (privKey *PrivKeySecp256k1) PubKey() PubKey
- func (privKey *PrivKeySecp256k1) Sign(msg []byte) Signature
- func (privKey *PrivKeySecp256k1) String() string
- func (privKey *PrivKeySecp256k1) UnmarshalJSON(data []byte) error
- type PubKey
- type PubKeyEd25519
- func (pubKey *PubKeyEd25519) Address() []byte
- func (pubKey *PubKeyEd25519) Bytes() []byte
- func (pubKey *PubKeyEd25519) Equals(other PubKey) bool
- func (pubKey *PubKeyEd25519) KeyString() string
- func (pubKey *PubKeyEd25519) MarshalJSON() ([]byte, error)
- func (pubKey *PubKeyEd25519) String() string
- func (pubKey *PubKeyEd25519) ToCurve25519() *[32]byte
- func (pubKey *PubKeyEd25519) UnmarshalJSON(data []byte) error
- func (pubKey *PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
- type PubKeySecp256k1
- func (pubKey *PubKeySecp256k1) Address() []byte
- func (pubKey *PubKeySecp256k1) Bytes() []byte
- func (pubKey *PubKeySecp256k1) Equals(other PubKey) bool
- func (pubKey *PubKeySecp256k1) KeyString() string
- func (pubKey *PubKeySecp256k1) MarshalJSON() ([]byte, error)
- func (pubKey *PubKeySecp256k1) String() string
- func (pubKey *PubKeySecp256k1) UnmarshalJSON(data []byte) error
- func (pubKey *PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
- type Signature
- type SignatureEd25519
- func (sig *SignatureEd25519) Bytes() []byte
- func (sig *SignatureEd25519) Equals(other Signature) bool
- func (sig *SignatureEd25519) IsZero() bool
- func (sig *SignatureEd25519) MarshalJSON() ([]byte, error)
- func (sig *SignatureEd25519) String() string
- func (sig *SignatureEd25519) UnmarshalJSON(data []byte) error
- type SignatureSecp256k1
- func (sig *SignatureSecp256k1) Bytes() []byte
- func (sig *SignatureSecp256k1) Equals(other Signature) bool
- func (sig *SignatureSecp256k1) IsZero() bool
- func (sig *SignatureSecp256k1) MarshalJSON() ([]byte, error)
- func (sig *SignatureSecp256k1) String() string
- func (sig *SignatureSecp256k1) UnmarshalJSON(data []byte) error
- type StPrivKey
- type StPubKey
- type StSignature
Constants ¶
const ( PrivKeyTypeEd25519 = byte(0x01) PrivKeyTypeSecp256k1 = byte(0x02) )
Types of PrivKey implementations
const ( PubKeyTypeEd25519 = byte(0x01) PubKeyTypeSecp256k1 = byte(0x02) )
Types of PubKey implementations
const ( SignatureTypeEd25519 = byte(0x01) SignatureTypeSecp256k1 = byte(0x02) PSignatureTypeEd25519 = byte(0x03) PSignatureTypeSecp256k1 = byte(0x04) )
Types of Signature implementations
Variables ¶
This section is empty.
Functions ¶
func DecodeArmor ¶
func DecryptSymmetric ¶
secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
func EncodeArmor ¶
func EncryptSymmetric ¶
secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. NOTE: call crypto.MixEntropy() first.
func MixEntropy ¶
func MixEntropy(seedBytes []byte)
Mix additional bytes of randomness, e.g. from hardware, user-input, etc. It is OK to call it multiple times. It does not diminish security.
Types ¶
type PrivKey ¶
type PrivKey interface { Bytes() []byte Sign(msg []byte) Signature PubKey() PubKey Equals(PrivKey) bool KeyString() string String() string json.Marshaler json.Unmarshaler }
PrivKey is part of PrivAccount and state.PrivValidator.
type PrivKeyEd25519 ¶
type PrivKeyEd25519 [64]byte
Implements PrivKey
func GenPrivKeyEd25519 ¶
func GenPrivKeyEd25519() PrivKeyEd25519
func GenPrivKeyEd25519FromSecret ¶
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (*PrivKeyEd25519) Bytes ¶
func (privKey *PrivKeyEd25519) Bytes() []byte
func (*PrivKeyEd25519) Equals ¶
func (privKey *PrivKeyEd25519) Equals(other PrivKey) bool
func (*PrivKeyEd25519) KeyString ¶
func (privKey *PrivKeyEd25519) KeyString() string
func (*PrivKeyEd25519) MarshalJSON ¶
func (privKey *PrivKeyEd25519) MarshalJSON() ([]byte, error)
func (*PrivKeyEd25519) PubKey ¶
func (privKey *PrivKeyEd25519) PubKey() PubKey
func (*PrivKeyEd25519) Sign ¶
func (privKey *PrivKeyEd25519) Sign(msg []byte) Signature
func (*PrivKeyEd25519) String ¶
func (privKey *PrivKeyEd25519) String() string
func (*PrivKeyEd25519) ToCurve25519 ¶
func (privKey *PrivKeyEd25519) ToCurve25519() *[32]byte
func (*PrivKeyEd25519) UnmarshalJSON ¶
func (privKey *PrivKeyEd25519) UnmarshalJSON(data []byte) error
type PrivKeySecp256k1 ¶
type PrivKeySecp256k1 [32]byte
Implements PrivKey
func GenPrivKeySecp256k1 ¶
func GenPrivKeySecp256k1() PrivKeySecp256k1
func GenPrivKeySecp256k1FromSecret ¶
func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (*PrivKeySecp256k1) Bytes ¶
func (privKey *PrivKeySecp256k1) Bytes() []byte
func (*PrivKeySecp256k1) Equals ¶
func (privKey *PrivKeySecp256k1) Equals(other PrivKey) bool
func (*PrivKeySecp256k1) KeyString ¶
func (privKey *PrivKeySecp256k1) KeyString() string
func (*PrivKeySecp256k1) MarshalJSON ¶
func (privKey *PrivKeySecp256k1) MarshalJSON() ([]byte, error)
func (*PrivKeySecp256k1) PubKey ¶
func (privKey *PrivKeySecp256k1) PubKey() PubKey
func (*PrivKeySecp256k1) Sign ¶
func (privKey *PrivKeySecp256k1) Sign(msg []byte) Signature
func (*PrivKeySecp256k1) String ¶
func (privKey *PrivKeySecp256k1) String() string
func (*PrivKeySecp256k1) UnmarshalJSON ¶
func (privKey *PrivKeySecp256k1) UnmarshalJSON(data []byte) error
type PubKey ¶
type PubKey interface { Address() []byte Bytes() []byte KeyString() string VerifyBytes(msg []byte, sig Signature) bool Equals(PubKey) bool String() string json.Marshaler json.Unmarshaler }
PubKey is part of Account and Validator.
type PubKeyEd25519 ¶
type PubKeyEd25519 [32]byte
Implements PubKey
func (*PubKeyEd25519) Address ¶
func (pubKey *PubKeyEd25519) Address() []byte
func (*PubKeyEd25519) Bytes ¶
func (pubKey *PubKeyEd25519) Bytes() []byte
func (*PubKeyEd25519) Equals ¶
func (pubKey *PubKeyEd25519) Equals(other PubKey) bool
func (*PubKeyEd25519) KeyString ¶
func (pubKey *PubKeyEd25519) KeyString() string
Must return the full bytes in hex. Used for map keying, etc.
func (*PubKeyEd25519) MarshalJSON ¶
func (pubKey *PubKeyEd25519) MarshalJSON() ([]byte, error)
func (*PubKeyEd25519) String ¶
func (pubKey *PubKeyEd25519) String() string
func (*PubKeyEd25519) ToCurve25519 ¶
func (pubKey *PubKeyEd25519) ToCurve25519() *[32]byte
For use with golang/crypto/nacl/box If error, returns nil.
func (*PubKeyEd25519) UnmarshalJSON ¶
func (pubKey *PubKeyEd25519) UnmarshalJSON(data []byte) error
func (*PubKeyEd25519) VerifyBytes ¶
func (pubKey *PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
type PubKeySecp256k1 ¶
type PubKeySecp256k1 [64]byte
Implements PubKey
func (*PubKeySecp256k1) Address ¶
func (pubKey *PubKeySecp256k1) Address() []byte
func (*PubKeySecp256k1) Bytes ¶
func (pubKey *PubKeySecp256k1) Bytes() []byte
func (*PubKeySecp256k1) Equals ¶
func (pubKey *PubKeySecp256k1) Equals(other PubKey) bool
func (*PubKeySecp256k1) KeyString ¶
func (pubKey *PubKeySecp256k1) KeyString() string
Must return the full bytes in hex. Used for map keying, etc.
func (*PubKeySecp256k1) MarshalJSON ¶
func (pubKey *PubKeySecp256k1) MarshalJSON() ([]byte, error)
func (*PubKeySecp256k1) String ¶
func (pubKey *PubKeySecp256k1) String() string
func (*PubKeySecp256k1) UnmarshalJSON ¶
func (pubKey *PubKeySecp256k1) UnmarshalJSON(data []byte) error
func (*PubKeySecp256k1) VerifyBytes ¶
func (pubKey *PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
type Signature ¶
type Signature interface { Bytes() []byte IsZero() bool String() string Equals(Signature) bool json.Marshaler json.Unmarshaler }
Signature is a part of Txs and consensus Votes.
type SignatureEd25519 ¶
type SignatureEd25519 [64]byte
Implements Signature
func (*SignatureEd25519) Bytes ¶
func (sig *SignatureEd25519) Bytes() []byte
func (*SignatureEd25519) Equals ¶
func (sig *SignatureEd25519) Equals(other Signature) bool
func (*SignatureEd25519) IsZero ¶
func (sig *SignatureEd25519) IsZero() bool
func (*SignatureEd25519) MarshalJSON ¶
func (sig *SignatureEd25519) MarshalJSON() ([]byte, error)
func (*SignatureEd25519) String ¶
func (sig *SignatureEd25519) String() string
func (*SignatureEd25519) UnmarshalJSON ¶
func (sig *SignatureEd25519) UnmarshalJSON(data []byte) error
type SignatureSecp256k1 ¶
type SignatureSecp256k1 []byte
Implements Signature
func (*SignatureSecp256k1) Bytes ¶
func (sig *SignatureSecp256k1) Bytes() []byte
func (*SignatureSecp256k1) Equals ¶
func (sig *SignatureSecp256k1) Equals(other Signature) bool
func (*SignatureSecp256k1) IsZero ¶
func (sig *SignatureSecp256k1) IsZero() bool
func (*SignatureSecp256k1) MarshalJSON ¶
func (sig *SignatureSecp256k1) MarshalJSON() ([]byte, error)
func (*SignatureSecp256k1) String ¶
func (sig *SignatureSecp256k1) String() string
func (*SignatureSecp256k1) UnmarshalJSON ¶
func (sig *SignatureSecp256k1) UnmarshalJSON(data []byte) error
type StPrivKey ¶
type StPrivKey struct {
PrivKey
}
func (StPrivKey) MarshalJSON ¶
func (*StPrivKey) UnmarshalJSON ¶
type StPubKey ¶
type StPubKey struct {
PubKey
}
func (StPubKey) MarshalJSON ¶
func (*StPubKey) UnmarshalJSON ¶
type StSignature ¶
type StSignature struct {
Signature
}
func (StSignature) MarshalJSON ¶
func (s StSignature) MarshalJSON() ([]byte, error)
func (*StSignature) String ¶
func (s *StSignature) String() string
func (*StSignature) UnmarshalJSON ¶
func (s *StSignature) UnmarshalJSON(data []byte) error