ed25519

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: LGPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const PrivateKeyLength int = 64

PrivateKeyLength is the fixed Private Key Length

View Source
const PublicKeyLength int = 32

PublicKeyLength is the fixed Public Key Length

View Source
const SeedLength int = 32

SeedLength is the fixed Seed Length

View Source
const SignatureLength int = 64

SignatureLength is the fixed Signature Length

Variables

This section is empty.

Functions

func Verify

func Verify(pub *PublicKey, msg, sig []byte) (bool, error)

Verify returns true if the signature is valid for the given message and public key, false otherwise

Types

type Keypair

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

Keypair is a ed25519 public-private keypair

func GenerateKeypair

func GenerateKeypair() (*Keypair, error)

GenerateKeypair returns a new ed25519 keypair

func NewKeypair

func NewKeypair(priv ed25519.PrivateKey) *Keypair

NewKeypair returns an Ed25519 keypair given a ed25519 private key

func NewKeypairFromMnenomic added in v0.3.1

func NewKeypairFromMnenomic(mnemonic, password string) (*Keypair, error)

NewKeypairFromMnenomic returns a new Keypair using the given mnemonic and password.

func NewKeypairFromPrivate

func NewKeypairFromPrivate(priv *PrivateKey) (*Keypair, error)

NewKeypairFromPrivate returns a ed25519 Keypair given a *ed25519.PrivateKey

func NewKeypairFromPrivateKeyString

func NewKeypairFromPrivateKeyString(in string) (*Keypair, error)

NewKeypairFromPrivateKeyString returns a Keypair given a 0x prefixed private key string

func NewKeypairFromSeed

func NewKeypairFromSeed(seed []byte) (*Keypair, error)

NewKeypairFromSeed generates a new ed25519 keypair from a 32 byte seed

func (*Keypair) Private

func (kp *Keypair) Private() crypto.PrivateKey

Private returns the keypair's private key

func (*Keypair) Public

func (kp *Keypair) Public() crypto.PublicKey

Public returns the keypair's public key

func (*Keypair) Sign

func (kp *Keypair) Sign(msg []byte) ([]byte, error)

Sign uses the keypair to sign the message using the ed25519 signature algorithm

func (*Keypair) Type added in v0.2.0

func (kp *Keypair) Type() crypto.KeyType

Type returns Ed25519Type

type PrivateKey

type PrivateKey ed25519.PrivateKey

PrivateKey is the ed25519 Private Key

func NewPrivateKey

func NewPrivateKey(in []byte) (*PrivateKey, error)

NewPrivateKey returns an ed25519 private key that consists of the input bytes Input length must be 64 bytes

func (*PrivateKey) Decode

func (k *PrivateKey) Decode(in []byte) error

Decode turns the input bytes into a ed25519 PrivateKey the input must be 64 bytes, or the function will return an error

func (*PrivateKey) Encode

func (k *PrivateKey) Encode() []byte

Encode returns the bytes underlying the ed25519 PrivateKey

func (*PrivateKey) Hex

func (k *PrivateKey) Hex() string

Hex will return PrivateKey Hex

func (*PrivateKey) Public

func (k *PrivateKey) Public() (crypto.PublicKey, error)

Public returns the public key corresponding to the ed25519 private key

func (*PrivateKey) Sign

func (k *PrivateKey) Sign(msg []byte) ([]byte, error)

Sign uses the ed25519 signature algorithm to sign the message

type PublicKey

type PublicKey ed25519.PublicKey

PublicKey is the ed25519 Public Key

func NewPublicKey

func NewPublicKey(in []byte) (*PublicKey, error)

NewPublicKey returns an ed25519 public key that consists of the input bytes Input length must be 32 bytes

func (*PublicKey) Address

func (k *PublicKey) Address() common.Address

Address returns the ss58 address for this public key

func (*PublicKey) AsBytes

func (k *PublicKey) AsBytes() PublicKeyBytes

AsBytes returns the public key as PublicKeyBytes

func (*PublicKey) Decode

func (k *PublicKey) Decode(in []byte) error

Decode turns the input bytes into an ed25519 PublicKey the input must be 32 bytes, or the function will return and error

func (*PublicKey) Encode

func (k *PublicKey) Encode() []byte

Encode returns the encoding of the ed25519 PublicKey

func (*PublicKey) Hex

func (k *PublicKey) Hex() string

Hex returns the public key as a '0x' prefixed hex string

func (*PublicKey) Verify

func (k *PublicKey) Verify(msg, sig []byte) (bool, error)

Verify checks that Ed25519PublicKey was used to create the signature for the message

type PublicKeyBytes

type PublicKeyBytes [PublicKeyLength]byte

PublicKeyBytes is an encoded ed25519 public key

func (PublicKeyBytes) Decode added in v0.2.0

Decode returns the SCALE decoded PublicKeyBytes

func (PublicKeyBytes) Encode added in v0.2.0

func (b PublicKeyBytes) Encode() ([]byte, error)

Encode returns the SCALE encoding of PublicKeyBytes

func (PublicKeyBytes) String added in v0.2.0

func (b PublicKeyBytes) String() string

String returns the PublicKeyBytes formatted as a hex string

type SignatureBytes

type SignatureBytes [SignatureLength]byte

SignatureBytes is a ed25519 signature

func NewSignatureBytes

func NewSignatureBytes(in []byte) SignatureBytes

NewSignatureBytes returns a SignatureBytes given a byte array

Jump to

Keyboard shortcuts

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