crypto

package
v0.0.0-...-2c4dd60 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AES128_KEY_LENGTH  = 16
	AES256_KEY_LENGTH  = 32
	AES_GCM_NONCE_SIZE = 12
)
View Source
const (
	NACL_BOX_KEY_LENGTH   = 32
	NACL_BOX_NONCE_LENGTH = 24
)

Variables

View Source
var DefaultHDDerivationPathPrefix = accounts.DerivationPath{44, 60, 0, 0}
View Source
var (
	ErrCannotDecrypt = errors.New("cannot decrypt")
)

Functions

func GenerateMnemonic

func GenerateMnemonic() (string, error)

Types

type AsymEncKeypair

type AsymEncKeypair struct {
	*AsymEncPrivkey
	*AsymEncPubkey
}

func GenerateAsymEncKeypair

func GenerateAsymEncKeypair() (*AsymEncKeypair, error)

type AsymEncPrivkey

type AsymEncPrivkey [NACL_BOX_KEY_LENGTH]byte

func AsymEncPrivkeyFromBytes

func AsymEncPrivkeyFromBytes(bs []byte) *AsymEncPrivkey

func AsymEncPrivkeyFromHex

func AsymEncPrivkeyFromHex(s string) (*AsymEncPrivkey, error)

func (*AsymEncPrivkey) Bytes

func (privkey *AsymEncPrivkey) Bytes() []byte

func (*AsymEncPrivkey) OpenMessageFrom

func (privkey *AsymEncPrivkey) OpenMessageFrom(senderPublicKey *AsymEncPubkey, msgEncrypted []byte) ([]byte, error)

func (*AsymEncPrivkey) SealMessageFor

func (privkey *AsymEncPrivkey) SealMessageFor(recipientPubKey *AsymEncPubkey, msg []byte) ([]byte, error)

type AsymEncPubkey

type AsymEncPubkey [NACL_BOX_KEY_LENGTH]byte

func AsymEncPubkeyFromBytes

func AsymEncPubkeyFromBytes(bs []byte) *AsymEncPubkey

func AsymEncPubkeyFromHex

func AsymEncPubkeyFromHex(s string) (*AsymEncPubkey, error)

func (*AsymEncPubkey) Bytes

func (pubkey *AsymEncPubkey) Bytes() []byte

func (*AsymEncPubkey) Hex

func (pubkey *AsymEncPubkey) Hex() string

func (*AsymEncPubkey) MarshalBinary

func (pubkey *AsymEncPubkey) MarshalBinary() ([]byte, error)

func (*AsymEncPubkey) MarshalJSON

func (pubkey *AsymEncPubkey) MarshalJSON() ([]byte, error)

func (AsymEncPubkey) MarshalStateBytes

func (pubkey AsymEncPubkey) MarshalStateBytes() ([]byte, error)

func (*AsymEncPubkey) String

func (pubkey *AsymEncPubkey) String() string

func (*AsymEncPubkey) UnmarshalBinary

func (pubkey *AsymEncPubkey) UnmarshalBinary(bs []byte) error

func (*AsymEncPubkey) UnmarshalStateBytes

func (pubkey *AsymEncPubkey) UnmarshalStateBytes(bs []byte) error

type SigKeypair

type SigKeypair struct {
	*SigningPrivateKey
	*SigningPublicKey
}

func GenerateSigKeypair

func GenerateSigKeypair() (*SigKeypair, error)

func SigKeypairFromHDMnemonic

func SigKeypairFromHDMnemonic(mnemonic string, accountIndex uint32) (*SigKeypair, error)

func SigKeypairFromHex

func SigKeypairFromHex(s string) (*SigKeypair, error)

type SigningPrivateKey

type SigningPrivateKey struct {
	*ecdsa.PrivateKey
}

func (*SigningPrivateKey) Bytes

func (privkey *SigningPrivateKey) Bytes() []byte

func (*SigningPrivateKey) Hex

func (privkey *SigningPrivateKey) Hex() string

func (*SigningPrivateKey) SignHash

func (privkey *SigningPrivateKey) SignHash(hash types.Hash) ([]byte, error)

func (*SigningPrivateKey) String

func (privkey *SigningPrivateKey) String() string

type SigningPublicKey

type SigningPublicKey struct {
	*ecdsa.PublicKey
}

func RecoverSigningPubkey

func RecoverSigningPubkey(hash types.Hash, signature []byte) (*SigningPublicKey, error)

func SigningPublicKeyFromBytes

func SigningPublicKeyFromBytes(bs []byte) (*SigningPublicKey, error)

func (*SigningPublicKey) Address

func (pubkey *SigningPublicKey) Address() types.Address

func (*SigningPublicKey) Bytes

func (pubkey *SigningPublicKey) Bytes() []byte

func (*SigningPublicKey) Hex

func (pubkey *SigningPublicKey) Hex() string

func (*SigningPublicKey) MarshalBinary

func (pubkey *SigningPublicKey) MarshalBinary() ([]byte, error)

func (*SigningPublicKey) MarshalJSON

func (pubkey *SigningPublicKey) MarshalJSON() ([]byte, error)

func (SigningPublicKey) MarshalStateBytes

func (pubkey SigningPublicKey) MarshalStateBytes() ([]byte, error)

func (*SigningPublicKey) MarshalText

func (pubkey *SigningPublicKey) MarshalText() ([]byte, error)

func (*SigningPublicKey) String

func (pubkey *SigningPublicKey) String() string

func (*SigningPublicKey) UnmarshalBinary

func (pubkey *SigningPublicKey) UnmarshalBinary(bs []byte) error

func (*SigningPublicKey) UnmarshalStateBytes

func (pubkey *SigningPublicKey) UnmarshalStateBytes(bs []byte) error

func (*SigningPublicKey) UnmarshalText

func (pubkey *SigningPublicKey) UnmarshalText(bs []byte) error

func (*SigningPublicKey) VerifySignature

func (pubkey *SigningPublicKey) VerifySignature(hash types.Hash, signature []byte) bool

type SymEncKey

type SymEncKey [AES256_KEY_LENGTH]byte

AES-256 symmetric encryption key

func NewSymEncKey

func NewSymEncKey() (SymEncKey, error)

func SymEncKeyFromBytes

func SymEncKeyFromBytes(bs []byte) SymEncKey

func (SymEncKey) Bytes

func (key SymEncKey) Bytes() []byte

func (SymEncKey) Decrypt

func (key SymEncKey) Decrypt(msg SymEncMsg) ([]byte, error)

func (SymEncKey) Encrypt

func (key SymEncKey) Encrypt(plaintext []byte) (SymEncMsg, error)

func (SymEncKey) MarshalJSON

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

func (*SymEncKey) UnmarshalJSON

func (key *SymEncKey) UnmarshalJSON(hexBytes []byte) error

type SymEncMsg

type SymEncMsg struct {
	Nonce      []byte
	Ciphertext []byte
}

An AES-256 symmetrically encrypted message

func SymEncMsgFromBytes

func SymEncMsgFromBytes(bs []byte) SymEncMsg

func (SymEncMsg) Bytes

func (msg SymEncMsg) Bytes() []byte

Jump to

Keyboard shortcuts

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