ec

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 6 Imported by: 7

Documentation

Overview

Package ec contains logic for handling elliptic curve keys

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
)

Variables

This section is empty.

Functions

func Sign

func Sign(priv *PrivateKey, msg []byte) []byte

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

func Verify

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

Verify verifies the message msg against the provided PublicKey and signature sig

Types

type PrivateKey

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

PrivateKey is a wrapper of containing both an ed25519 private key and its associated public key. Wrapper provides additional functionality on top of Go's library

func LoadPrivateKey

func LoadPrivateKey(data string) (*PrivateKey, error)

LoadPrivateKey loads a base64 string into a PrivateKey

func NewKeyPair

func NewKeyPair(rand io.Reader) (*PrivateKey, error)

NewKeyPair creates an ed25519 keypair wrapped around a PrivateKey, using the random source (for example, crypto/rand.Reader).

func (*PrivateKey) GetPublic

func (priv *PrivateKey) GetPublic() *PublicKey

GetPublic returns a copy of PrivateKey's PublicKey

func (*PrivateKey) KeyType

func (priv *PrivateKey) KeyType() string

KeyType returns the PrivateKey type as a string. For this case, it will be the constant "edd25519 in this case the constant variable whose value is "ed25519".

func (*PrivateKey) Marshal

func (priv *PrivateKey) Marshal() []byte

Marshal serializes a PrivateKey into a byte slice

func (*PrivateKey) MarshalJSON

func (priv *PrivateKey) MarshalJSON() ([]byte, error)

MarshalJSON marshals the PrivateKey into valid JSON. This function adheres to the json.Marshaler interface.

func (*PrivateKey) MarshalText

func (priv *PrivateKey) MarshalText() string

MarshalText returns a base64 encoded string of the PrivateKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PrivateKey) String

func (priv *PrivateKey) String() string

Stringer function for PrivateKey

func (*PrivateKey) Unmarshal

func (priv *PrivateKey) Unmarshal(data []byte) error

Unmarshal deserializes a byte slice into the PrivateKey

func (*PrivateKey) UnmarshalJSON

func (priv *PrivateKey) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshalls the JSON into the PrivateKey. This function adheres to the json.Unmarshaler interface.

func (*PrivateKey) UnmarshalText

func (priv *PrivateKey) UnmarshalText(data string) error

UnmarshalText deserializes a base64-encoded string into the PrivateKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/

type PublicKey

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

PublicKey is a wrapper of an ed25519 public key. Wrapper provides additional functionality on top of Go's library.

func LoadPublicKey

func LoadPublicKey(data string) (*PublicKey, error)

LoadPublicKey loads a base64 string into a PublicKey

func (*PublicKey) DeepCopy

func (pub *PublicKey) DeepCopy() *PublicKey

DeepCopy returns a new PublicKey with identical data as this PublicKey

func (*PublicKey) KeyType

func (pub *PublicKey) KeyType() string

KeyType returns the PublicKey type as a string. For this case, it will be the constant "edd25519 in this case the constant variable whose value is "ed25519".

func (*PublicKey) Marshal

func (pub *PublicKey) Marshal() []byte

Marshal serializes a PublicKey into a byte slice

func (*PublicKey) MarshalJSON

func (pub *PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON marshals the PublicKey into valid JSON. This function adheres to the json.Marshaler interface.

func (*PublicKey) MarshalText

func (pub *PublicKey) MarshalText() string

MarshalText returns a base64 encoded string of the PublicKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/

func (*PublicKey) String

func (pub *PublicKey) String() string

Stringer function for PublicKey

func (*PublicKey) Unmarshal

func (pub *PublicKey) Unmarshal(data []byte) error

Unmarshal deserializes a byte slice into the PrivateKey

func (*PublicKey) UnmarshalJSON

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

UnmarshalJSON unmarshalls the JSON into the PublicKey. This function adheres to the json.Unmarshaler interface.

func (*PublicKey) UnmarshalText

func (pub *PublicKey) UnmarshalText(data string) error

UnmarshalText deserializes a base64-encoded string into the PublicKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/

Jump to

Keyboard shortcuts

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