keys

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 GenerateKey

func GenerateKey(kind ECKind) (Key, error)

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

  • Ed25519
  • Secp256k1
  • NistP256

func NewKey

func NewKey(input NewKeyInput) (Key, error)

NewKey gets a new Key based on the input passed

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) Sign

func (k *Key) Sign(input SignInput) (Signature, error)

Sign will either sign a hex encoded string or bytes with Key

func (*Key) Verify

func (k *Key) Verify(input VerifyInput) bool

Verify will verify the authenticity of the public key, signature and data.

type NewKeyInput

type NewKeyInput struct {
	Bytes         []byte
	EncodedString string
	Esk           string
	Password      string
	Mnemonic      string
	Email         string

	Kind ECKind `validate:"required"`
}

NewKeyInput is the input for the keys.NewKey function.

Note:

You can generate a key with the following combinations:
	* Bytes
	* EncodedString: hex, base64, or base58
	* Esk & Password
	* Mnemonic
	* Mnemonic & Password
	* Mnemonic & Password & Email

Function:

func NewKey(input NewKeyInput) (Key, error) {}

type NewPubKeyInput

type NewPubKeyInput struct {
	Bytes  []byte
	String string
	Kind   ECKind `validate:"required"`
}

NewPubKeyInput is the input for the keys.NewPubKey function.

Notes:

The public key can be derived by Bytes, or a String that is encoded in hex, base64, or base58.

Function:

func NewPubKey(input NewPubKeyInput) (PubKey, error) {}

type PubKey

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

PubKey is the public key to a Tezos Wallet

func GeneratePubKey

func GeneratePubKey(kind ECKind) (PubKey, error)

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

  • Ed25519
  • Secp256k1
  • NistP256

func NewPubKey

func NewPubKey(input NewPubKeyInput) (PubKey, error)

NewPubKey gets a new PubKey based on the input passed

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

func (*PubKey) GetPublicKeyHash

func (p *PubKey) GetPublicKeyHash() string

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

tz1L8fUQLuwRuywTZUP5JUw9LL3kJa8LMfoo

func (*PubKey) Verify

func (p *PubKey) Verify(input VerifyInput) bool

Verify will verify the authenticity of the public key, signature and data.

type SignInput

type SignInput struct {
	Message string
	Bytes   []byte
}

SignInput is the input for the key.Sign function.

Note:

You can sign with the following combinations:
	* Message
		or
	* Bytes

Function:

func FromMnemonic(input FromMnemonicInput) (Key, error) {}

type Signature

type Signature struct {
	Bytes  []byte
	Prefix []byte
}

Signature represents the signature of an operation

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

type VerifyInput

type VerifyInput struct {
	BytesData      []byte
	BytesSignature []byte
	Data           string
	Signature      string
}

VerifyInput is the input for the key.Verify function.

Note:

You can verify with the following combinations:
	* BytesData & BytesSignature
	* Data & Signature

Function:

func Verify(input VerifyInput) bool {}

Jump to

Keyboard shortcuts

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