crypto

package
v0.0.0-...-8fbb6bc Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EcdsaPrivKeyAminoRoute = "true/PrivKeyTrue"
	EcdsaPubKeyAminoRoute  = "true/PubKeyTrue"
	// Size of an Edwards25519 signature. Namely the size of a compressed
	// Edwards25519 point, and a field element. Both of which are 32 bytes.
	SignatureEd25519Size = 64
)

-------------------------------------

Variables

This section is empty.

Functions

func Sha256

func Sha256(bytes []byte) []byte

Sha256 return new sha256

Types

type PrivKey

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

PrivKey is private key interface

type PrivKeyTrue

type PrivKeyTrue ecdsa.PrivateKey

PrivKeyTrue implements PrivKey.

func GenPrivKey

func GenPrivKey() PrivKeyTrue

GenPrivKey generates a new ed25519 private key.

func (PrivKeyTrue) Bytes

func (priv PrivKeyTrue) Bytes() []byte

Bytes marshals the privkey using amino encoding.

func (PrivKeyTrue) Equals

func (priv PrivKeyTrue) Equals(other PrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (PrivKeyTrue) PubKey

func (priv PrivKeyTrue) PubKey() PubKey

PubKey gets the corresponding public key from the private key.

func (PrivKeyTrue) Sign

func (priv PrivKeyTrue) Sign(msg []byte) ([]byte, error)

Sign produces a signature on the provided message.

type PubKey

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

PubKey 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.

type PubKeyTrue

type PubKeyTrue ecdsa.PublicKey

PubKeyTrue implements PubKey for the ecdsa.PublicKey signature scheme.

func (PubKeyTrue) Address

func (pub PubKeyTrue) Address() help.Address

Address is the Keccak256 of the raw pubkey bytes.

func (PubKeyTrue) Bytes

func (pub PubKeyTrue) Bytes() []byte

Bytes marshals the PubKey using amino encoding.

func (PubKeyTrue) Equals

func (pub PubKeyTrue) Equals(other PubKey) bool

Equals is comp public key

func (PubKeyTrue) String

func (pub PubKeyTrue) String() string

func (PubKeyTrue) VerifyBytes

func (pub PubKeyTrue) VerifyBytes(msg []byte, sig []byte) bool

VerifyBytes is check msg

type Symmetric

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

Symmetric is Keygen,Encrypt and Decrypt interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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