tendermint: github.com/tendermint/tendermint/crypto Index | Examples | Files | Directories

package crypto

import "github.com/tendermint/tendermint/crypto"

Index

Examples

Package Files

crypto.go doc.go hash.go random.go version.go

Constants

const (
    // AddressSize is the size of a pubkey address.
    AddressSize = tmhash.TruncatedSize
)
const Version = "0.9.0-dev"

func CRandBytes Uses

func CRandBytes(numBytes int) []byte

This only uses the OS's randomness

func CRandHex Uses

func CRandHex(numDigits int) string

CRandHex returns a hex encoded string that's floor(numDigits/2) * 2 long.

Note: CRandHex(24) gives 96 bits of randomness that are usually strong enough for most purposes.

func CReader Uses

func CReader() io.Reader

Returns a crand.Reader.

func Sha256 Uses

func Sha256(bytes []byte) []byte

Code:

sum := crypto.Sha256([]byte("This is Tendermint"))
fmt.Printf("%x\n", sum)

Output:

f91afb642f3d1c87c17eb01aae5cb65c242dfdbe7cf1066cc260f4ce5d33b94e

type Address Uses

type Address = bytes.HexBytes

An address is a []byte, but hex-encoded even in JSON. []byte leaves us the option to change the address length. Use an alias so Unmarshal methods (with ptr receivers) are available too.

func AddressHash Uses

func AddressHash(bz []byte) Address

type PrivKey Uses

type PrivKey interface {
    Bytes() []byte
    Sign(msg []byte) ([]byte, error)
    PubKey() PubKey
    Equals(PrivKey) bool
}

type PubKey Uses

type PubKey interface {
    Address() Address
    Bytes() []byte
    VerifyBytes(msg []byte, sig []byte) bool
    Equals(PubKey) bool
}

type Symmetric Uses

type Symmetric interface {
    Keygen() []byte
    Encrypt(plaintext []byte, secret []byte) (ciphertext []byte)
    Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error)
}

Directories

PathSynopsis
armor
ed25519
encoding/amino
internal/benchmarking
merklePackage merkle computes a deterministic minimal height Merkle tree hash.
multisig
multisig/bitarray
secp256k1
sr25519
tmhash
xchacha20poly1305Package xchacha20poly1305 creates an AEAD using hchacha, chacha, and poly1305 This allows for randomized nonces to be used in conjunction with chacha.
xsalsa20symmetric

Package crypto imports 6 packages (graph) and is imported by 347 packages. Updated 2019-12-12. Refresh now. Tools for package owners.