ed25519

package
Version: v0.0.0-...-0082470 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 64

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

func (privateKey PrivateKey) Seed() *Seed

Seed returns the private key seed corresponding to privateKey. It is provided for interoperability with RFC 8032. RFC 8032's private keys correspond to seeds in this package.

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 PublicKeyFromString

func PublicKeyFromString(s string) (publicKey PublicKey, err error)

PublicKeyFromString parses the given string with base58 encoding and returns a PublicKey.

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

func (publicKey PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON serializes public key to JSON as base58 encoded string.

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

func (publicKey *PublicKey) UnmarshalJSON(b []byte) error

UnmarshalJSON parses public key from JSON in base58 encoding.

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 Seed

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

Seed is a generator for a deterministic sequence of KeyPairs.

func NewSeed

func NewSeed(optionalSeedBytes ...[]byte) *Seed

NewSeed represents the factory method for a Seed object. It either generates a new random seed or restores an existing one from a sequence of bytes.

func (*Seed) Bytes

func (seed *Seed) Bytes() []byte

Bytes marshals the Seed object into a sequence of Bytes that can be used to later restore the Seed by handing it into the factory method.

func (*Seed) KeyPair

func (seed *Seed) KeyPair(n uint64) (keyPair *KeyPair)

KeyPair retrieves the n'th KeyPair from the Seed.

func (*Seed) String

func (seed *Seed) String() string

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

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
y or Y : Canonical URL