crypto

package
v0.0.0-...-b6e904f Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CryptoClientPicker func() CryptoClient
)

Functions

func GenKeyPair

func GenKeyPair(path string) error

func InitCryptoClient

func InitCryptoClient(privateBytes []byte) error

func RegisterCryptoClient

func RegisterCryptoClient(fn func() CryptoClient)

RegisterCryptoClient registers a crypto client initialization function.

Types

type CryptoClient

type CryptoClient interface {
	Sign(msgBytes []byte) (newmsg []byte, err error)
	Verify(sign []byte, pk []byte, msgBytes []byte) (bool, error)
}

type DefaultCryptoClient

type DefaultCryptoClient struct {
	SK *ecdsa.PrivateKey
	PK *ecdsa.PublicKey
}

DefaultCryptoClient is a simple crypto client uses NIST P256.

func (*DefaultCryptoClient) Sign

func (cc *DefaultCryptoClient) Sign(msgBytes []byte) ([]byte, error)

Sign uses hotstuffpb only. crypto_client will load its own public_key and use private_key to sign msg ignore the tag signatrue

func (*DefaultCryptoClient) Verify

func (cc *DefaultCryptoClient) Verify(sign []byte, pk []byte, msgBytes []byte) (bool, error)

type Private

type Private struct {
	Curvname string
	X, Y, D  *big.Int
}

type Sign

type Sign struct {
	R, S *big.Int
}

Jump to

Keyboard shortcuts

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