curve25519

package
v0.0.0-...-97e1097 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package curve25519 implements the XEd25519 signature scheme.

See https://signal.org/docs/specifications/xeddsa/#curve25519 for more information.

Index

Constants

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

Variables

This section is empty.

Functions

func VerifySignature

func VerifySignature(publicKey []byte, signature []byte, messages ...[]byte) (bool, error)

VerifySignature verifies the signature is a valid signature for the messages by the public key.

It is expected the given public key is Montgomery u-point.

Types

type PrivateKey

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

PrivateKey represents a Montgomery private key used for the XEdDSA scheme.

func GeneratePrivateKey

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

GeneratePrivateKey generates a cryptographic random private key.

func NewPrivateKey

func NewPrivateKey(key []byte) (*PrivateKey, error)

NewPrivateKey creates a new private key based on the given input.

It is expected that the given key is already clamped based on https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5.

func (*PrivateKey) Agreement

func (p *PrivateKey) Agreement(key []byte) ([]byte, error)

Agreement computes the ECDH shared key between the private key and the given public key.

func (*PrivateKey) Bytes

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

Bytes returns a copy of the private key.

func (*PrivateKey) PublicKeyBytes

func (p *PrivateKey) PublicKeyBytes() []byte

PublicKeyBytes returns the public key in the form of a Montgomery u-point.

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(random io.Reader, messages ...[]byte) ([]byte, error)

Sign calculates an XEdDSA signature using the X25519 private key directly.

The calculated signature is a valid ed25519 signature.

Jump to

Keyboard shortcuts

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