ed25519

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Overview

Package ed25519 implements the cryptographic primitives for the Edwards 25519 elliptic curve.

The signatures are created using the Schnorr algorithm which allows the aggregation of multiple signatures and public keys.

Related Papers:

Efficient Identification and Signatures for Smart Cards (1989) https://link.springer.com/chapter/10.1007/0-387-34805-0_22

Documentation Last Review: 05.10.2020

Index

Examples

Constants

View Source
const (
	// Algorithm is the name of the curve used for the schnorr signature.
	Algorithm = "CURVE-ED25519"
)

Variables

This section is empty.

Functions

func NewPublicKeyFactory

func NewPublicKeyFactory() crypto.PublicKeyFactory

NewPublicKeyFactory returns a new instance of the factory.

func NewSignatureFactory

func NewSignatureFactory() crypto.SignatureFactory

NewSignatureFactory returns a new instance of the factory.

func NewSigner

func NewSigner() crypto.Signer

NewSigner returns a new random schnorr signer.

func RegisterPublicKeyFormat

func RegisterPublicKeyFormat(format serde.Format, engine serde.FormatEngine)

RegisterPublicKeyFormat register the engine for the provided format.

func RegisterSignatureFormat

func RegisterSignatureFormat(format serde.Format, engine serde.FormatEngine)

RegisterSignatureFormat register the engine for the provided format.

Types

type PublicKey

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

PublicKey is the public key adapter to the Kyber Ed25519 public key.

- implements crypto.PublicKey

func NewPublicKey

func NewPublicKey(data []byte) (PublicKey, error)

NewPublicKey returns a new public key from the data.

func NewPublicKeyFromPoint

func NewPublicKeyFromPoint(point kyber.Point) PublicKey

NewPublicKeyFromPoint creates a new public key from an existing point.

func (PublicKey) Equal

func (pk PublicKey) Equal(other interface{}) bool

Equal implements crypto.PublicKey. It returns true if the other public key is the same.

func (PublicKey) GetPoint

func (pk PublicKey) GetPoint() kyber.Point

GetPoint returns the kyber.point.

func (PublicKey) MarshalBinary

func (pk PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler. It produces a slice of bytes representing the public key.

func (PublicKey) MarshalText

func (pk PublicKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It returns a text representation of the public key.

func (PublicKey) Serialize

func (pk PublicKey) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data of the public key.

func (PublicKey) String

func (pk PublicKey) String() string

String implements fmt.Stringer. It returns a string representation of the point.

func (PublicKey) Verify

func (pk PublicKey) Verify(msg []byte, sig crypto.Signature) error

Verify implements crypto.PublicKey. It returns nil if the signature matches the message for this public key.

type Signature

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

Signature is the adapter of the Kyber Schnorr signature.

- implements crypto.Signature

func NewSignature

func NewSignature(data []byte) Signature

NewSignature returns a new signature from the data.

func (Signature) Equal

func (sig Signature) Equal(other crypto.Signature) bool

Equal implements crypto.Signature. It returns true if both signatures are the same.

func (Signature) MarshalBinary

func (sig Signature) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler. It returns a slice of bytes representing the signature.

func (Signature) Serialize

func (sig Signature) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data of the signature.

type Signer

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

Signer implements a signer that is creating Schnorr signatures using the private key of the Ed25519 elliptic curve.

- implements crypto.Signer

func (Signer) GetPrivateKey

func (s Signer) GetPrivateKey() kyber.Scalar

GetPrivateKey returns the signer's private key.

func (Signer) GetPublicKey

func (s Signer) GetPublicKey() crypto.PublicKey

GetPublicKey implements crypto.Signer. It returns the public key of the signer that can be used to verify signatures.

func (Signer) GetPublicKeyFactory

func (s Signer) GetPublicKeyFactory() crypto.PublicKeyFactory

GetPublicKeyFactory implements crypto.Signer. It returns the public key factory for schnorr signatures.

func (Signer) GetSignatureFactory

func (s Signer) GetSignatureFactory() crypto.SignatureFactory

GetSignatureFactory implements crypto.Signer. It returns the signature factory for schnorr signatures.

func (Signer) Sign

func (s Signer) Sign(msg []byte) (crypto.Signature, error)

Sign implements crypto.Signer. It signs the message in parameter and returns the signature, or an error if it cannot sign.

Example
signerA := NewSigner()

message := []byte("42")

signature, err := signerA.Sign(message)
if err != nil {
	panic("signer failed: " + err.Error())
}

err = signerA.GetPublicKey().Verify(message, signature)
if err != nil {
	panic("invalid signature: " + err.Error())
}

fmt.Println("Success")
Output:

Success

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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