crypto

package
v3.0.0-rc5+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: LGPL-3.0 Imports: 7 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm uint8

Algorithm is the crypto algorithm of signature

const (
	Secp256k1 Algorithm
	Ed25519
)

Algorithm list

func NewAlgorithm added in v1.1.0

func NewAlgorithm(name string) Algorithm

NewAlgorithm returns a new algorithm by name

func (Algorithm) GenSeckey

func (a Algorithm) GenSeckey() []byte

GenSeckey will generate the secret key

func (Algorithm) GetPubkey

func (a Algorithm) GetPubkey(seckey []byte) []byte

GetPubkey will get the public key of the secret key

func (Algorithm) Sign

func (a Algorithm) Sign(message []byte, seckey []byte) []byte

Sign will signature the message with seckey

func (Algorithm) String added in v1.1.0

func (a Algorithm) String() string

String return algorithm readable string

func (Algorithm) Verify

func (a Algorithm) Verify(message []byte, pubkey []byte, sig []byte) (ret bool)

Verify will verify the message with pubkey and sig

type AlgorithmBackend

type AlgorithmBackend interface {
	Sign(message []byte, seckey []byte) []byte
	Verify(message []byte, pubkey []byte, sig []byte) bool
	GetPubkey(seckey []byte) []byte
	GenSeckey() []byte
}

AlgorithmBackend is the interface of algorithm backend

type Signature

type Signature struct {
	Algorithm Algorithm

	Sig    []byte
	Pubkey []byte
}

Signature is the signature of some message

func NewSignature

func NewSignature(algo Algorithm, info []byte, privkey []byte) *Signature

NewSignature returns new signature

func (*Signature) Decode

func (s *Signature) Decode(b []byte) error

Decode will unmarshal the signature by protobuf

func (*Signature) Encode

func (s *Signature) Encode() ([]byte, error)

Encode will marshal the signature by protobuf

func (*Signature) Equal

func (s *Signature) Equal(sig *Signature) bool

Equal returns whether two signatures are equal.

func (*Signature) FromPb added in v1.1.0

func (s *Signature) FromPb(sr *sigpb.Signature) *Signature

FromPb convert Signature from proto buf data structure.

func (*Signature) Hash

func (s *Signature) Hash() []byte

Hash returns the hash code of signature

func (*Signature) SetPubkey

func (s *Signature) SetPubkey(pubkey []byte)

SetPubkey will set the public key

func (*Signature) ToBytes added in v1.1.0

func (s *Signature) ToBytes() []byte

ToBytes converts Signature to a specific byte slice.

func (*Signature) ToPb added in v1.1.0

func (s *Signature) ToPb() *sigpb.Signature

ToPb convert Signature to proto buf data structure.

func (*Signature) Verify

func (s *Signature) Verify(info []byte) bool

Verify will verify the info

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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