key

package module
v0.0.0-...-2febe77 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: MIT Imports: 10 Imported by: 0

README

#key

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDriver        = errors.New("unknown driver")
	ErrPublicKey     = errors.New("invalid public key")
	ErrCanonicalSign = errors.New("couldn't find a canonical signature")
	ErrRecoverSign   = errors.New("recover error")
)

Errors

Functions

func Decrypt

func Decrypt(encryptor string, key Key, attrs Property, reader io.Reader) error

Decrypt .

func DecryptBlock

func DecryptBlock(key Key, message []byte) ([]byte, error)

DecryptBlock .

func Encrypt

func Encrypt(encryptor string, key Key, attrs Property, writer io.Writer) error

Encrypt .

func EncryptBlock

func EncryptBlock(driver string, pubkey []byte, message []byte) ([]byte, error)

EncryptBlock .

func MnemonicFromKeystore

func MnemonicFromKeystore(reader io.Reader, password string) (string, error)

MnemonicFromKeystore .

func MnemonicToKeystore

func MnemonicToKeystore(mnemonic string, password string, writer io.Writer) error

MnemonicToKeystore .

func PublicKeyToAddress

func PublicKeyToAddress(driver string, pubkey []byte) (string, error)

PublicKeyToAddress .

func Recover

func Recover(driver string, sig []byte, hash []byte) ([]byte, error)

Recover recover public key from sig and hash

func RegisterEncryptor

func RegisterEncryptor(name string, f Encryptor)

RegisterEncryptor register key encrypto

func RegisterProvider

func RegisterProvider(provider Provider)

RegisterProvider register provider

func ValidAddress

func ValidAddress(driver string, address string) (bool, error)

ValidAddress .

func Verify

func Verify(driver string, pubkey []byte, sig []byte, hash []byte) (bool, error)

Verify .

Types

type BytesEncryptor

type BytesEncryptor interface {
	EncryptBytes(source []byte, property Property, writer io.Writer) error
	DecryptBytes(property Property, reader io.Reader) ([]byte, error)
}

BytesEncryptor .

type Encryptor

type Encryptor interface {
	Encrypt(key Key, property Property, writer io.Writer) error
	Decrypt(key Key, property Property, reader io.Reader) error
}

Encryptor .

type Key

type Key interface {
	Address() string                    // address display string
	PriKey() []byte                     // private key byte array
	PubKey() []byte                     // public key byte array
	SetBytes(priKey []byte)             // set private key bytes
	Sign(hashed []byte) ([]byte, error) // sign the hashed message
	Provider() Provider                 // provider
}

Key blockchain key facade

func From

func From(driver string, key Key) (Key, error)

From create key from exist key

func FromMnemonic

func FromMnemonic(driver string, mnemonic string, path string) (Key, error)

FromMnemonic .

func New

func New(driver string) (Key, error)

New create key

func NewMnemonic

func NewMnemonic(driver string, path string) (string, Key, error)

NewMnemonic .

func NewMnemonicWithLength

func NewMnemonicWithLength(driver string, path string, length int) (string, Key, error)

NewMnemonicWithLength .

type Property

type Property map[string]string

Property .

type Provider

type Provider interface {
	Name() string      // driver name
	New() (Key, error) // create new key
	Verify(pubkey []byte, sig []byte, hash []byte) bool
	PublicKeyToAddress(pubkey []byte) (string, error)
	ValidAddress(address string) bool
	PrivateToPublic(privateKey []byte) []byte
	Curve() elliptic.Curve
}

Provider the key service provider

type RecoverableProvider

type RecoverableProvider interface {
	Provider
	Recover(sig []byte, hash []byte) (pubkey []byte, err error)
}

RecoverableProvider .

type WithNetID

type WithNetID interface {
	NetID() byte
	SetNetID(id byte)
	SupportNetID() []byte
}

WithNetID .

Directories

Path Synopsis
cmd
wif
internal
bnb
did
Package did Ontology Distributed Identification Protocol impelement
Package did Ontology Distributed Identification Protocol impelement
eos
eth
neo
ont
trx

Jump to

Keyboard shortcuts

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