crypto

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var PrivKeyMapper = data.NewMapper(PrivKey{})
View Source
var PubKeyMapper = data.NewMapper(PubKey{})
View Source
var SignatureMapper = data.NewMapper(Signature{})

Functions

func CRandBytes

func CRandBytes(numBytes int) []byte

This uses the OS and the Seed(s).

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.

func Sha256

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

f91afb642f3d1c87c17eb01aae5cb65c242dfdbe7cf1066cc260f4ce5d33b94e

Types

type PrivKey

type PrivKey struct {
	PrivKeyInner "json:\"unwrap\""
}

func PrivKeyFromBytes

func PrivKeyFromBytes(privKeyBytes []byte) (privKey PrivKey, err error)

func (PrivKey) MarshalJSON

func (h PrivKey) MarshalJSON() ([]byte, error)

func (*PrivKey) UnmarshalJSON

func (h *PrivKey) UnmarshalJSON(data []byte) (err error)

func (PrivKey) Unwrap

func (h PrivKey) Unwrap() PrivKeyInner

Unwrap recovers the concrete interface safely (regardless of levels of embeds)

type PrivKeyEd25519

type PrivKeyEd25519 [64]byte

Implements PrivKey

func GenPrivKeyEd25519

func GenPrivKeyEd25519() PrivKeyEd25519

func (PrivKeyEd25519) MarshalJSON

func (p 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) UnmarshalJSON

func (p *PrivKeyEd25519) UnmarshalJSON(enc []byte) error

func (PrivKeyEd25519) Wrap

func (hi PrivKeyEd25519) Wrap() PrivKey

type PrivKeyInner

type PrivKeyInner interface {
	Sign(msg []byte) Signature
	PubKey() PubKey
	Wrap() PrivKey
}

DO NOT USE THIS INTERFACE. You probably want to use PrivKey +gen wrapper:"PrivKey,Impl[PrivKeyEd25519,PrivKeySecp256k1],ed25519,secp256k1"

type PubKey

type PubKey struct {
	PubKeyInner "json:\"unwrap\""
}

func (PubKey) MarshalJSON

func (h PubKey) MarshalJSON() ([]byte, error)

func (*PubKey) UnmarshalJSON

func (h *PubKey) UnmarshalJSON(data []byte) (err error)

func (PubKey) Unwrap

func (h PubKey) Unwrap() PubKeyInner

Unwrap recovers the concrete interface safely (regardless of levels of embeds)

type PubKeyEd25519

type PubKeyEd25519 [32]byte

Implements PubKeyInner

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 (p PubKeyEd25519) MarshalJSON() ([]byte, error)

func (PubKeyEd25519) String

func (pubKey PubKeyEd25519) String() string

func (*PubKeyEd25519) UnmarshalJSON

func (p *PubKeyEd25519) UnmarshalJSON(enc []byte) error

func (PubKeyEd25519) VerifyBytes

func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool

func (PubKeyEd25519) Wrap

func (hi PubKeyEd25519) Wrap() PubKey

type PubKeyInner

type PubKeyInner interface {
	KeyString() string
	VerifyBytes(msg []byte, sig Signature) bool
	Equals(PubKey) bool
	Wrap() PubKey
}

DO NOT USE THIS INTERFACE. You probably want to use PubKey +gen wrapper:"PubKey,Impl[PubKeyEd25519,PubKeySecp256k1],ed25519,secp256k1"

type Signature

type Signature struct {
	SignatureInner "json:\"unwrap\""
}

func SignatureFromBytes

func SignatureFromBytes(sigBytes []byte) (sig Signature, err error)

func (Signature) MarshalJSON

func (h Signature) MarshalJSON() ([]byte, error)

func (*Signature) UnmarshalJSON

func (h *Signature) UnmarshalJSON(data []byte) (err error)

func (Signature) Unwrap

func (h Signature) Unwrap() SignatureInner

Unwrap recovers the concrete interface safely (regardless of levels of embeds)

type SignatureEd25519

type SignatureEd25519 [64]byte

Implements Signature

func (SignatureEd25519) Bytes

func (sig SignatureEd25519) Bytes() []byte

func (SignatureEd25519) MarshalJSON

func (sig SignatureEd25519) MarshalJSON() ([]byte, error)

func (*SignatureEd25519) UnmarshalJSON

func (sig *SignatureEd25519) UnmarshalJSON(enc []byte) error

func (SignatureEd25519) Wrap

func (hi SignatureEd25519) Wrap() Signature

type SignatureInner

type SignatureInner interface {
	Bytes() []byte
	Wrap() Signature
}

DO NOT USE THIS INTERFACE. You probably want to use Signature. +gen wrapper:"Signature,Impl[SignatureEd25519,SignatureSecp256k1],ed25519,secp256k1"

Jump to

Keyboard shortcuts

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