eddsa

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: AGPL-3.0 Imports: 13 Imported by: 44

Documentation

Overview

Package eddsa provides EdDSA (Ed25519) wrappers.

Index

Constants

View Source
const (
	// PublicKeySize is the size of a serialized PublicKey in bytes (32 bytes).
	PublicKeySize = ed25519.PublicKeySize

	// PrivateKeySize is the size of a serialized PrivateKey in bytes (64 bytes).
	PrivateKeySize = ed25519.PrivateKeySize

	// SignatureSize is the size of a serialized Signature in bytes (64 bytes).
	SignatureSize = ed25519.SignatureSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey is a EdDSA private key.

func Load

func Load(privFile, pubFile string, r io.Reader) (*PrivateKey, error)

Load loads a new PrivateKey from the PEM encoded file privFile, optionally creating and saving a PrivateKey instead if an entropy source is provided. If pubFile is specified and a key has been created, the corresponding PublicKey will be written to pubFile in PEM format.

func NewKeypair

func NewKeypair(r io.Reader) (*PrivateKey, error)

NewKeypair generates a new PrivateKey sampled from the provided entropy source.

func (*PrivateKey) Bytes

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

Bytes returns the raw private key.

func (*PrivateKey) FromBytes

func (k *PrivateKey) FromBytes(b []byte) error

FromBytes deserializes the byte slice b into the PrivateKey.

func (*PrivateKey) Identity added in v0.0.4

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

Identity returns the key's identity, in this case it's our public key in bytes.

func (*PrivateKey) InternalPtr

func (k *PrivateKey) InternalPtr() *ed25519.PrivateKey

InternalPtr returns a pointer to the internal (`golang.org/x/crypto/ed25519`) data structure. Most people should not use this.

func (*PrivateKey) KeyType added in v0.0.4

func (k *PrivateKey) KeyType() string

KeyType returns the key type string, in this case the constant variable whose value is "ed25519".

func (*PrivateKey) MarshalBinary added in v0.0.7

func (k *PrivateKey) MarshalBinary() ([]byte, error)

MarshalBinary implements the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PrivateKey) PublicKey

func (k *PrivateKey) PublicKey() *PublicKey

PublicKey returns the PublicKey corresponding to the PrivateKey.

func (*PrivateKey) Reset

func (k *PrivateKey) Reset()

Reset clears the PrivateKey structure such that no sensitive data is left in memory.

func (*PrivateKey) Sign

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

Sign signs the message msg with the PrivateKey and returns the signature.

func (*PrivateKey) ToECDH

func (k *PrivateKey) ToECDH() *ecdh.PrivateKey

ToECDH converts the PrivateKey to the corresponding ecdh.PrivateKey.

func (*PrivateKey) UnmarshalBinary added in v0.0.7

func (k *PrivateKey) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/

type PublicKey

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

PublicKey is a EdDSA public key.

func (*PublicKey) ByteArray

func (k *PublicKey) ByteArray() [PublicKeySize]byte

ByteArray returns the raw public key as an array suitable for use as a map key.

func (*PublicKey) Bytes

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

Bytes returns the raw public key.

func (*PublicKey) Equal

func (k *PublicKey) Equal(cmp *PublicKey) bool

Equal returns true iff the public key is byte for byte identical.

func (*PublicKey) FromBytes

func (k *PublicKey) FromBytes(b []byte) error

FromBytes deserializes the byte slice b into the PublicKey.

func (*PublicKey) FromString

func (k *PublicKey) FromString(s string) error

FromString deserializes the string s into the PublicKey.

func (*PublicKey) Identity added in v0.0.4

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

Identity returns the key's identity, in this case it's our public key in bytes.

func (*PublicKey) InternalPtr

func (k *PublicKey) InternalPtr() *ed25519.PublicKey

InternalPtr returns a pointer to the internal (`golang.org/x/crypto/ed25519`) data structure. Most people should not use this.

func (*PublicKey) MarshalBinary

func (k *PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary implements the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) MarshalText

func (k *PublicKey) MarshalText() ([]byte, error)

MarshalText implements the TextMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) Reset

func (k *PublicKey) Reset()

Reset clears the PublicKey structure such that no sensitive data is left in memory. PublicKeys, despite being public may be considered sensitive in certain contexts (eg: if used once in path selection).

func (*PublicKey) String

func (k *PublicKey) String() string

String returns the public key as a base64 encoded string.

func (*PublicKey) ToECDH

func (k *PublicKey) ToECDH() *ecdh.PublicKey

ToECDH converts the PublicKey to the corresponding ecdh.PublicKey.

func (*PublicKey) ToPEMFile

func (k *PublicKey) ToPEMFile(f string) error

ToPEMFile writes out the PublicKey to a PEM file at path f.

func (*PublicKey) UnmarshalBinary

func (k *PublicKey) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) UnmarshalText

func (k *PublicKey) UnmarshalText(data []byte) error

UnmarshalText implements the TextUnmarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) Verify

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

Verify returns true iff the signature sig is valid for the message msg.

Jump to

Keyboard shortcuts

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