crypto

package
v0.8.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

crypto

crypto is the cryptographic package adapted for Tendermint's uses

Importing it

To get the interfaces, import "bitbucket.org/number571/tendermint/crypto"

For any specific algorithm, use its specific module e.g. import "bitbucket.org/number571/tendermint/crypto/gost512"

Binary encoding

For Binary encoding, please refer to the Tendermint encoding specification.

JSON Encoding

JSON encoding is done using tendermint's internal json encoder. For more information on JSON encoding, please refer to Tendermint JSON encoding

Example JSON encodings:

gost512.PrivKey     - {"type":"tendermint/PrivKey512","value":"UTEwYjdhYTBkNTYwOTM3NDI5OWQwYjc0YWQyN2ZlODEyMDVkNDRmNWJlYTY3ZTUwNjY4ZTZlMmQzZTBmZTMyMGM3Yjc5N2I2NDRjZDA4Y2FjNTliNDk5NDA3YTMxYzIxODM4NjRjYmMwNTkzMmJkZDA0MjNiMzc5ZWRjOTg0OGNl"}
gost512.PubKey      - {"type":"tendermint/PubKey512","value":"UQYgAAA9LgAATUFHMQAEAAAwFQYJKoUDBwECAQIBBggqhQMHAQECA8OWSvhanUIAIQJNpbhLA3qbO7q8wu5Bcvu9f/4Grxee3yqSaPSA9sMne6auI2P9bLYagEdJDMZyTYIWGj/RUDhOyWIdymUWDwA6EiiGFqqrBK5uoq+X0xxmrT5ikC1VbGueC0EaZLYqqQpaG37Fga1vFYPPz4qIYLi3in6o5CYb"}
gost256.PubKey   - {"type":"tendermint/PrivKey256","value":"UDMxNzU0Mjk3Y2FjYTdiMmJjYzkxYWM4NTFjNWUzOTJjZWU0MDFhN2ZkNjQzMDFhODI2OGUxM2E0NjBlNmE2MDM3Yjc5N2I2NDRjZDA4Y2FjNTliNDk5NDA3YTMxYzIxODM4NjRjYmMwNTkzMmJkZDA0MjNiMzc5ZWRjOTg0OGNl"}
gost256.PubKey    - {"type":"tendermint/PubKey256","value":"UAYgAABJLgAATUFHMQACAAAwEwYHKoUDAgIjAQYIKoUDBwEBAgJaWews1GShsVvOwilvu3LrO6rBhdyVuBvZjUmaY+oOS9+xTff8DtlpgaukttrSS+q1L0IGC5iXP0K5q1vwTs9m"}

Documentation

Index

Examples

Constants

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

Variables

This section is empty.

Functions

func CRandBytes

func CRandBytes(numBytes int) []byte

func CRandHex

func CRandHex(numDigits int) string

func CReader

func CReader() io.Reader

func HashSum

func HashSum(bytes []byte) []byte
Example
package main

import (
	"fmt"

	"bitbucket.org/number571/tendermint/crypto"
)

func main() {
	sum := crypto.HashSum([]byte("This is Tendermint"))
	fmt.Printf("%x\n", sum)
}
Output:

eb979489a131cbc0cf1d9da8f8357730965de85649af8905dc0947ffb1174d05

Types

type Address

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

func AddressHash(bz []byte) Address

type BatchVerifier

type BatchVerifier interface {
	// Add appends an entry into the BatchVerifier.
	Add(key PubKey, message, signature []byte) error
	// Verify verifies all the entries in the BatchVerifier, and returns
	// if every signature in the batch is valid, and a vector of bools
	// indicating the verification status of each signature (in the order
	// that signatures were added to the batch).
	Verify() (bool, []bool)
}

If a new key type implements batch verification, the key type must be registered in bitbucket.org/number571/tendermint/crypto/batch

type PrivKey

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

type PubKey

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

type Symmetric

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

Directories

Path Synopsis
internal
Package merkle computes a deterministic minimal height Merkle tree hash.
Package merkle computes a deterministic minimal height Merkle tree hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL