keypair

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StrKeyTagEd25519        = "ed25519"
	StrKeyTagSecp256k1      = "secp256k1"
	Separator          byte = 0
)

Variables

This section is empty.

Functions

func ReadBase64File

func ReadBase64File(path string) ([]byte, error)

ReadBase64File reads the Base64 content of a file, get rid of PEM frames

func ReadBase64WithPEM

func ReadBase64WithPEM(content string) ([]byte, error)

Types

type KeyPair

type KeyPair interface {
	RawSeed() []byte
	KeyTag() KeyTag
	PublicKey() PublicKey
	AccountHash() string
	Sign(mes []byte) Signature
	Verify(sign []byte, mes []byte) bool
}

type KeyTag

type KeyTag byte
const (
	KeyTagEd25519 KeyTag = iota + 1
	KeyTagSecp256k1
)

type PublicKey

type PublicKey struct {
	Tag        KeyTag
	PubKeyData []byte
}

func (PublicKey) Marshal

func (key PublicKey) Marshal(w io.Writer) (int, error)

func (PublicKey) MarshalJSON

func (key PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) ToBytes

func (key PublicKey) ToBytes() ([]byte, error)

func (*PublicKey) UnmarshalJSON

func (key *PublicKey) UnmarshalJSON(data []byte) error

type Signature

type Signature struct {
	Tag           KeyTag
	SignatureData []byte
}

func (Signature) Marshal

func (signature Signature) Marshal(w io.Writer) (int, error)

func (Signature) MarshalJSON

func (signature Signature) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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