crypto

package
v0.0.0-...-2eec6a9 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2017 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package crypto provides crypto algos

Index

Constants

View Source
const HashLength = 32

HashLength length of hash in bytes

Variables

This section is empty.

Functions

func AbbrevID

func AbbrevID(id string) string

AbbrevID returns abbreviation of ID

func RecoverID

func RecoverID(msgHash Hash, sig []byte) (string, error)

RecoverID recover ID from message hash and signature.

Types

type Hash

type Hash [HashLength]byte

Hash hash type

func HashSum

func HashSum(data []byte) (hash Hash)

HashSum compute hash of data default algorithm is blake2b

func HexToHash

func HexToHash(str string) (*Hash, error)

HexToHash parse hex string to hash

func (Hash) MarshalJSON

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

MarshalJSON Marshal JSON

func (Hash) ToHex

func (h Hash) ToHex() string

ToHex convert hash into hex string (without '0x' prefix)

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal JSON

type Identity

type Identity struct {
	// contains filtered or unexported fields
}

Identity wrap ECDSA private key to identify some one.

func GenerateIdentity

func GenerateIdentity() (*Identity, error)

GenerateIdentity generate a new identity

func NewIdentity

func NewIdentity(privKey []byte) (*Identity, error)

NewIdentity create identity from private key.

func (*Identity) ID

func (identity *Identity) ID() string

ID returns ID of identity in string. The ID is derived from public key, and the result is cached.

func (*Identity) PrivateKey

func (identity *Identity) PrivateKey() []byte

PrivateKey returns private key in bytes.

func (*Identity) Sign

func (identity *Identity) Sign(msgHash Hash) ([]byte, error)

Sign sign message hash and returns signature.

Jump to

Keyboard shortcuts

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