curve25519

package
v0.0.0-...-5e8e628 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 9 Imported by: 1

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(random io.Reader) (*PrivateKey, error)

GeneratePrivateKey generates a random private key.

It is recommended to use a cryptographic random reader. If random is nil, then crypto/rand.Reader is used.

func NewPrivateKey

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

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

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.

It is recommended to use a cryptographic random reader. If random is nil, then crypto/rand.Reader is used.

Jump to

Keyboard shortcuts

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