keypair

package
v0.0.0-...-8526a12 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecretFree = "secret-free"
	Sr25519    = "sr25519"
	Ed25519    = "ed25519"
	Secp256k1  = "secp256k1"

	SecretFreeIdx = "0"
	Sr25519Idx    = "1"
	Ed25519Idx    = "2"
	Secp256k1Idx  = "3"
)

Variables

View Source
var KeyTypeBytLen = 1

Functions

func GenEdKey

func GenEdKey() (PubKey, PrivKey)

func GenEdKeyWithSecret

func GenEdKeyWithSecret(secret []byte) (PubKey, PrivKey)

func GenKeyPair

func GenKeyPair(keyType string) (PubKey, PrivKey, error)

func GenKeyPairWithSecret

func GenKeyPairWithSecret(keyType string, secret []byte) (PubKey, PrivKey, error)

func GenSecpKey

func GenSecpKey() (PubKey, PrivKey)

func GenSecpKeyWithSecret

func GenSecpKeyWithSecret(secret []byte) (PubKey, PrivKey)

func GenSrKey

func GenSrKey() (PubKey, PrivKey)

func GenSrKeyWithSecret

func GenSrKeyWithSecret(secret []byte) (PubKey, PrivKey)

Types

type EdPrivkey

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

func (*EdPrivkey) Bytes

func (epr *EdPrivkey) Bytes() []byte

func (*EdPrivkey) BytesWithType

func (epr *EdPrivkey) BytesWithType() []byte

func (*EdPrivkey) Equals

func (epr *EdPrivkey) Equals(key Key) bool

func (*EdPrivkey) SignData

func (epr *EdPrivkey) SignData(data []byte) ([]byte, error)

func (*EdPrivkey) String

func (epr *EdPrivkey) String() string

func (*EdPrivkey) StringWithType

func (epr *EdPrivkey) StringWithType() string

func (*EdPrivkey) Type

func (epr *EdPrivkey) Type() string

type EdPubkey

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

func EdPubKeyFromBytes

func EdPubKeyFromBytes(data []byte) *EdPubkey

func (*EdPubkey) Address

func (epb *EdPubkey) Address() Address

func (*EdPubkey) Bytes

func (epb *EdPubkey) Bytes() []byte

func (*EdPubkey) BytesWithType

func (epb *EdPubkey) BytesWithType() []byte

func (*EdPubkey) Equals

func (epb *EdPubkey) Equals(key Key) bool

func (*EdPubkey) String

func (epb *EdPubkey) String() string

func (*EdPubkey) StringWithType

func (epb *EdPubkey) StringWithType() string

func (*EdPubkey) Type

func (epb *EdPubkey) Type() string

func (*EdPubkey) VerifySignature

func (epb *EdPubkey) VerifySignature(msg, sig []byte) bool

type FreePrivkey

type FreePrivkey struct{}

func (*FreePrivkey) Bytes

func (f *FreePrivkey) Bytes() []byte

func (*FreePrivkey) BytesWithType

func (f *FreePrivkey) BytesWithType() []byte

func (*FreePrivkey) Equals

func (f *FreePrivkey) Equals(key Key) bool

func (*FreePrivkey) SignData

func (f *FreePrivkey) SignData(bytes []byte) ([]byte, error)

func (*FreePrivkey) String

func (f *FreePrivkey) String() string

func (*FreePrivkey) StringWithType

func (f *FreePrivkey) StringWithType() string

func (*FreePrivkey) Type

func (f *FreePrivkey) Type() string

type FreePubkey

type FreePubkey struct{}

func (*FreePubkey) Address

func (s *FreePubkey) Address() Address

func (*FreePubkey) Bytes

func (s *FreePubkey) Bytes() []byte

func (*FreePubkey) BytesWithType

func (s *FreePubkey) BytesWithType() []byte

func (*FreePubkey) Equals

func (s *FreePubkey) Equals(key Key) bool

func (*FreePubkey) String

func (s *FreePubkey) String() string

func (*FreePubkey) StringWithType

func (s *FreePubkey) StringWithType() string

func (*FreePubkey) Type

func (s *FreePubkey) Type() string

func (*FreePubkey) VerifySignature

func (s *FreePubkey) VerifySignature(msg, sig []byte) bool

type Key

type Key interface {
	Type() string
	Equals(key Key) bool
	Bytes() []byte
	String() string

	BytesWithType() []byte
	StringWithType() string
}

type PrivKey

type PrivKey interface {
	Key
	SignData([]byte) ([]byte, error)
}

type PubKey

type PubKey interface {
	Key
	Address() common.Address
	VerifySignature(msg, sig []byte) bool
}

func PubKeyFromBytes

func PubKeyFromBytes(data []byte) (PubKey, error)

data: (keyTypeBytes + keyBytes)

func PubkeyFromStr

func PubkeyFromStr(data string) (PubKey, error)

type SecpPrivkey

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

func SecpPrivkeyFromBytes

func SecpPrivkeyFromBytes(data []byte) *SecpPrivkey

func (*SecpPrivkey) Bytes

func (spr *SecpPrivkey) Bytes() []byte

func (*SecpPrivkey) BytesWithType

func (spr *SecpPrivkey) BytesWithType() []byte

func (*SecpPrivkey) Equals

func (spr *SecpPrivkey) Equals(key Key) bool

func (*SecpPrivkey) GenPubkey

func (spr *SecpPrivkey) GenPubkey() []byte

func (*SecpPrivkey) SignData

func (spr *SecpPrivkey) SignData(data []byte) ([]byte, error)

func (*SecpPrivkey) String

func (spr *SecpPrivkey) String() string

func (*SecpPrivkey) StringWithType

func (spr *SecpPrivkey) StringWithType() string

func (*SecpPrivkey) Type

func (spr *SecpPrivkey) Type() string

type SecpPubkey

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

func SecpPubkeyFromBytes

func SecpPubkeyFromBytes(data []byte) *SecpPubkey

func (*SecpPubkey) Address

func (spb *SecpPubkey) Address() Address

func (*SecpPubkey) Bytes

func (spb *SecpPubkey) Bytes() []byte

func (*SecpPubkey) BytesWithType

func (spb *SecpPubkey) BytesWithType() []byte

func (*SecpPubkey) Equals

func (spb *SecpPubkey) Equals(key Key) bool

func (*SecpPubkey) String

func (spb *SecpPubkey) String() string

func (*SecpPubkey) StringWithType

func (spb *SecpPubkey) StringWithType() string

func (*SecpPubkey) Type

func (spb *SecpPubkey) Type() string

func (*SecpPubkey) VerifySignature

func (spb *SecpPubkey) VerifySignature(msg, sig []byte) bool

type SrPrivkey

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

func (*SrPrivkey) Bytes

func (spr *SrPrivkey) Bytes() []byte

func (*SrPrivkey) BytesWithType

func (spr *SrPrivkey) BytesWithType() []byte

func (*SrPrivkey) Equals

func (spr *SrPrivkey) Equals(key Key) bool

func (*SrPrivkey) SignData

func (spr *SrPrivkey) SignData(data []byte) ([]byte, error)

func (*SrPrivkey) String

func (spr *SrPrivkey) String() string

func (*SrPrivkey) StringWithType

func (spr *SrPrivkey) StringWithType() string

func (*SrPrivkey) Type

func (spr *SrPrivkey) Type() string

type SrPubkey

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

func SrPubKeyFromBytes

func SrPubKeyFromBytes(data []byte) *SrPubkey

func (*SrPubkey) Address

func (spb *SrPubkey) Address() Address

func (*SrPubkey) Bytes

func (spb *SrPubkey) Bytes() []byte

func (*SrPubkey) BytesWithType

func (spb *SrPubkey) BytesWithType() []byte

func (*SrPubkey) Equals

func (spb *SrPubkey) Equals(key Key) bool

func (*SrPubkey) String

func (spb *SrPubkey) String() string

func (*SrPubkey) StringWithType

func (spb *SrPubkey) StringWithType() string

func (*SrPubkey) Type

func (spb *SrPubkey) Type() string

func (*SrPubkey) VerifySignature

func (spb *SrPubkey) VerifySignature(msg, sig []byte) bool

Jump to

Keyboard shortcuts

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