Ethan Frey aecc32d363 | 8 years ago | |
---|---|---|
bcrypt | 9 years ago | |
hd | 8 years ago | |
.gitignore | 8 years ago | |
LICENSE | 9 years ago | |
Makefile | 8 years ago | |
README.md | 8 years ago | |
armor.go | 9 years ago | |
armor_test.go | 8 years ago | |
crypto.go | 8 years ago | |
embed_test.go | 8 years ago | |
encode_test.go | 8 years ago | |
glide.yaml | 8 years ago | |
hash.go | 9 years ago | |
priv_key.go | 8 years ago | |
pub_key.go | 8 years ago | |
pub_key_test.go | 8 years ago | |
random.go | 9 years ago | |
signature.go | 8 years ago | |
signature_test.go | 8 years ago | |
symmetric.go | 9 years ago | |
symmetric_test.go | 8 years ago |
import "github.com/tendermint/go-crypto"
armor.go hash.go priv_key.go pub_key.go random.go signature.go symmetric.go
const (
TypeEd25519 = byte(0x01)
TypeSecp256k1 = byte(0x02)
NameEd25519 = "ed25519"
NameSecp256k1 = "secp256k1"
)
Types of implementations
func CRandBytes(numBytes int) []byte
This uses the OS and the Seed(s).
func CRandHex(numDigits int) string
RandHex(24) gives 96 bits of randomness, strong enough for most purposes.
func CReader() io.Reader
Returns a crand.Reader mixed with user-supplied entropy
func DecodeArmor(armorStr string) (blockType string, headers map[string]string, data []byte, err error)
func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error)
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(blockType string, headers map[string]string, data []byte) string
func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte)
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(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.
func Ripemd160(bytes []byte) []byte
func Sha256(bytes []byte) []byte
type PrivKey interface {
Bytes() []byte
Sign(msg []byte) Signature
PubKey() PubKey
Equals(PrivKey) bool
}
PrivKey is part of PrivAccount and state.PrivValidator.
func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error)
type PrivKeyEd25519 [64]byte
Implements PrivKey
func GenPrivKeyEd25519() PrivKeyEd25519
func GenPrivKeyEd25519FromSecret(secret []byte) PrivKeyEd25519
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (privKey PrivKeyEd25519) Bytes() []byte
func (privKey PrivKeyEd25519) Equals(other PrivKey) bool
func (privKey PrivKeyEd25519) Generate(index int) PrivKeyEd25519
Deterministically generates new priv-key bytes from key.
func (p 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 (p *PrivKeyEd25519) UnmarshalJSON(enc []byte) error
type PrivKeyS struct {
PrivKey
}
PrivKeyS add json serialization to PrivKey
func (p PrivKeyS) Empty() bool
func (p PrivKeyS) MarshalJSON() ([]byte, error)
func (p *PrivKeyS) UnmarshalJSON(data []byte) (err error)
type PrivKeySecp256k1 [32]byte
Implements PrivKey
func GenPrivKeySecp256k1() PrivKeySecp256k1
func GenPrivKeySecp256k1FromSecret(secret []byte) PrivKeySecp256k1
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (privKey PrivKeySecp256k1) Bytes() []byte
func (privKey PrivKeySecp256k1) Equals(other PrivKey) bool
func (p PrivKeySecp256k1) MarshalJSON() ([]byte, error)
func (privKey PrivKeySecp256k1) PubKey() PubKey
func (privKey PrivKeySecp256k1) Sign(msg []byte) Signature
func (privKey PrivKeySecp256k1) String() string
func (p *PrivKeySecp256k1) UnmarshalJSON(enc []byte) error
type PubKey interface {
Address() []byte
Bytes() []byte
KeyString() string
VerifyBytes(msg []byte, sig Signature) bool
Equals(PubKey) bool
}
PubKey is part of Account and Validator.
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey PubKey, err error)
type PubKeyEd25519 [32]byte
Implements PubKey
func (pubKey PubKeyEd25519) Address() []byte
func (pubKey PubKeyEd25519) Bytes() []byte
func (pubKey PubKeyEd25519) Equals(other PubKey) bool
func (pubKey PubKeyEd25519) KeyString() string
Must return the full bytes in hex. Used for map keying, etc.
func (p PubKeyEd25519) MarshalJSON() ([]byte, error)
func (pubKey PubKeyEd25519) String() string
func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte
For use with golang/crypto/nacl/box If error, returns nil.
func (p *PubKeyEd25519) UnmarshalJSON(enc []byte) error
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
type PubKeyS struct {
PubKey
}
PubKeyS add json serialization to PubKey
func (p PubKeyS) Empty() bool
func (p PubKeyS) MarshalJSON() ([]byte, error)
func (p *PubKeyS) UnmarshalJSON(data []byte) (err error)
type PubKeySecp256k1 [33]byte
Implements PubKey. Compressed pubkey (just the x-cord), prefixed with 0x02 or 0x03, depending on the y-cord.
func (pubKey PubKeySecp256k1) Address() []byte
Implements Bitcoin style addresses: RIPEMD160(SHA256(pubkey))
func (pubKey PubKeySecp256k1) Bytes() []byte
func (pubKey PubKeySecp256k1) Equals(other PubKey) bool
func (pubKey PubKeySecp256k1) KeyString() string
Must return the full bytes in hex. Used for map keying, etc.
func (p PubKeySecp256k1) MarshalJSON() ([]byte, error)
func (pubKey PubKeySecp256k1) String() string
func (p *PubKeySecp256k1) UnmarshalJSON(enc []byte) error
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
type Signature interface {
Bytes() []byte
IsZero() bool
String() string
Equals(Signature) bool
}
Signature is a part of Txs and consensus Votes.
func SignatureFromBytes(sigBytes []byte) (sig Signature, err error)
type SignatureEd25519 [64]byte
Implements Signature
func (sig SignatureEd25519) Bytes() []byte
func (sig SignatureEd25519) Equals(other Signature) bool
func (sig SignatureEd25519) IsZero() bool
func (p SignatureEd25519) MarshalJSON() ([]byte, error)
func (sig SignatureEd25519) String() string
func (p *SignatureEd25519) UnmarshalJSON(enc []byte) error
type SignatureS struct {
Signature
}
SignatureS add json serialization to Signature
func (p SignatureS) Empty() bool
func (p SignatureS) MarshalJSON() ([]byte, error)
func (p *SignatureS) UnmarshalJSON(data []byte) (err error)
type SignatureSecp256k1 []byte
Implements Signature
func (sig SignatureSecp256k1) Bytes() []byte
func (sig SignatureSecp256k1) Equals(other Signature) bool
func (sig SignatureSecp256k1) IsZero() bool
func (p SignatureSecp256k1) MarshalJSON() ([]byte, error)
func (sig SignatureSecp256k1) String() string
func (p *SignatureSecp256k1) UnmarshalJSON(enc []byte) error
Generated by godoc2md