ed25519

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeySize  = ed25519.PublicKeySize
	SignatureSize  = ed25519.SignatureSize
	PrivateKeySize = ed25519.PrivateKeySize
	SeedSize       = ed25519.SeedSize
)

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey() (publicKey PublicKey, privateKey PrivateKey, err error)

GenerateKey creates a public/private key pair.

Types

type KeyPair

type KeyPair struct {
	PrivateKey PrivateKey
	PublicKey  PublicKey
}

func GenerateKeyPair

func GenerateKeyPair() (keyPair KeyPair)

type PrivateKey

type PrivateKey [PrivateKeySize]byte

PrivateKey is the type of Ed25519 private keys.

func GeneratePrivateKey

func GeneratePrivateKey() (privateKey PrivateKey, err error)

GenerateKey creates a private key.

func PrivateKeyFromBytes

func PrivateKeyFromBytes(bytes []byte) (result PrivateKey, err error, consumedBytes int)

PrivateKeyFromBytes creates a PrivateKey from the given bytes.

func PrivateKeyFromSeed

func PrivateKeyFromSeed(seed []byte) (result PrivateKey)

PrivateKeyFromSeed calculates a private key from a seed.

func (PrivateKey) Bytes

func (privateKey PrivateKey) Bytes() []byte

Bytes returns the privateKey in bytes.

func (PrivateKey) Public

func (privateKey PrivateKey) Public() (result PublicKey)

Public returns the PublicKey corresponding to privateKey.

func (PrivateKey) Sign

func (privateKey PrivateKey) Sign(data []byte) (result Signature)

Sign signs the message with privateKey and returns a signature.

func (PrivateKey) String

func (privateKey PrivateKey) String() string

String returns a human readable version of the PrivateKey (base58 encoded).

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey is the type of Ed25519 public keys.

func ParsePublicKey

func ParsePublicKey(marshalUtil *marshalutil.MarshalUtil) (PublicKey, error)

func PublicKeyFromBytes

func PublicKeyFromBytes(bytes []byte) (result PublicKey, consumedBytes int, err error)

PublicKeyFromBytes creates a PublicKey from the given bytes.

func RecoverKey

func RecoverKey(key, data, sig []byte) (result PublicKey, err error)

RecoverKey makes sure that key and signature have the correct length and verifies whether sig is a valid signature of data by pub.

func (PublicKey) Bytes

func (publicKey PublicKey) Bytes() []byte

Bytes returns the publicKey in bytes.

func (PublicKey) String

func (publicKey PublicKey) String() string

String returns a human readable version of the PublicKey (base58 encoded).

func (*PublicKey) UnmarshalBinary

func (publicKey *PublicKey) UnmarshalBinary(bytes []byte) (err error)

func (PublicKey) VerifySignature

func (publicKey PublicKey) VerifySignature(data []byte, signature Signature) bool

VerifySignature reports whether signature is a valid signature of message by publicKey.

type Signature

type Signature [SignatureSize]byte
var EmptySignature Signature

func ParseSignature

func ParseSignature(marshalUtil *marshalutil.MarshalUtil) (Signature, error)

func SignatureFromBytes

func SignatureFromBytes(bytes []byte) (result Signature, consumedBytes int, err error)

SignatureFromBytes creates a Signature from the given bytes.

func (Signature) Bytes

func (signature Signature) Bytes() []byte

Bytes returns the signature in bytes.

func (Signature) String

func (signature Signature) String() string

String returns a human readable version of the Signature (base58 encoded).

func (*Signature) UnmarshalBinary

func (signature *Signature) UnmarshalBinary(bytes []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL