keys

package
v4.0.23 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPkhFromBytes added in v4.0.13

func GetPkhFromBytes(b []byte) (string, error)

func IsValidBlockHash added in v4.0.16

func IsValidBlockHash(input string) bool

func IsValidOperationHash added in v4.0.16

func IsValidOperationHash(input string) bool

func IsValidPk added in v4.0.16

func IsValidPk(pk string) bool

func IsValidPkh added in v4.0.14

func IsValidPkh(pkh string) bool

func IsValidSignature added in v4.0.16

func IsValidSignature(input string) bool

Types

type ECKind

type ECKind string

ECKind is the key type

const (
	// Ed25519 https://tools.ietf.org/html/rfc8032
	Ed25519 ECKind = "Ed25519"
	// Secp256k1 https://tools.ietf.org/html/rfc4492
	Secp256k1 ECKind = "Secp256k1"
	// NistP256 https://tools.ietf.org/html/rfc5656
	NistP256 ECKind = "NistP256"
)

type Key

type Key struct {
	PubKey PubKey
	// contains filtered or unexported fields
}

Key is the cryptographic key to a Tezos Wallet

func FromBase58

func FromBase58(privKey string) (*Key, error)

FromBase58 returns a new key from a private key in base58 form

func FromBase64

func FromBase64(privKey string, kind ECKind) (*Key, error)

FromBase64 returns a new key from a private key in base64 form

func FromBytes

func FromBytes(privKey []byte, kind ECKind) (*Key, error)

FromBytes returns a new key from a private key in byte form

func FromEncryptedSecret

func FromEncryptedSecret(esk, passwd string) (*Key, error)

FromEncryptedSecret returns a new key from an encrypted private key

func FromHex

func FromHex(privKey string, kind ECKind) (*Key, error)

FromHex returns a new key from a private key in hex form

func FromMnemonic

func FromMnemonic(mnemonic, email, passwd string, kind ECKind) (*Key, error)

FromMnemonic returns a new key from a mnemonic

func Generate

func Generate(kind ECKind) (*Key, error)

Generate returns a new cryptographic key based on the kind of elliptical curve passed

  • Ed25519
  • Secp256k1
  • NistP256

func (*Key) GetBytes

func (k *Key) GetBytes() []byte

GetBytes will return the raw bytes of the private key.

func (*Key) GetSecretKey

func (k *Key) GetSecretKey() string

GetSecretKey will return the base58 encoded key with the secret key prefix. This is unencrypted. Example: edskRpfRbhVr7SjmVpMK1kzTDrSzuCKroxjQAsfJn94X7LgbpqJLvRDHfNHFT9KbCZAXVVhMmkQGz4APscezMbJFov5ZNPSY9H

func (*Key) SignData added in v4.0.21

func (k *Key) SignData(msg []byte, magic_bytes []byte) (Signature, error)

SignBytes will sign a byte message for operation

func (*Key) SignDataRaw added in v4.0.21

func (k *Key) SignDataRaw(msg []byte) (Signature, error)

SignBytes will sign a byte message

func (*Key) SignGeneric added in v4.0.21

func (k *Key) SignGeneric(msg string) (Signature, error)

SignHex will sign a hex encoded string for operation, add 0x03 magic bytes

func (*Key) SignHexRaw added in v4.0.21

func (k *Key) SignHexRaw(msg string) (Signature, error)

SignBytes will sign a string in hex message

type PubKey

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

PubKey is the public key to a Tezos Wallet

func FromBase58Pk added in v4.0.6

func FromBase58Pk(pubKey string) (*PubKey, error)

func (*PubKey) CheckSignature added in v4.0.14

func (pk *PubKey) CheckSignature(data string, signature string) (bool, error)

SignBytes will sign a byte message for operation

func (*PubKey) GetAddress

func (p *PubKey) GetAddress() string

GetAddress will public key hash (address) of the public key. Example:

tz1L8fUQLuwRuywTZUP5JUw9LL3kJa8LMfoo

func (*PubKey) GetBytes

func (p *PubKey) GetBytes() []byte

GetBytes will return the raw bytes of the public key

func (*PubKey) GetPublicKey

func (p *PubKey) GetPublicKey() string

GetPublicKey will return the base58 encoded key with the private key prefix. Example:

edskRpfRbhVr7SjmVpMK1kzTDrSzuCKroxjQAsfJn94X7LgbpqJLvRDHfNHFT9KbCZAXVVhMmkQGz4APscezMbJFov5ZNPSY9H

type Signature

type Signature struct {
	Bytes []byte
	// contains filtered or unexported fields
}

Signature represents the signature of an operation

func (*Signature) AppendToBytes

func (s *Signature) AppendToBytes(msg []byte) []byte

AppendToBytes takes a bytes message and adds the signature to it for injection

func (*Signature) AppendToHex

func (s *Signature) AppendToHex(msg string) string

AppendToHex takes a hex encoded message and adds the signature to it for injection

func (*Signature) ToBase58

func (s *Signature) ToBase58() string

ToBase58 returns the signature as a base58 encoded string with the correct prefix

func (*Signature) ToBytes

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

ToBytes returns the signature as bytes

func (*Signature) ToHex

func (s *Signature) ToHex() string

ToHex returns the signature encoded to hex

Jump to

Keyboard shortcuts

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