ed25519

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ed25519 implements the Ed25519 signature algorithm. See https://ed25519.cr.yp.to/.

These functions are also compatible with the “Ed25519” function defined in RFC 8032.

Index

Constants

View Source
const (
	// PublicKeySize is the size, in bytes, of public keys as used in this package.
	PublicKeySize = 32
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 64
	// SignatureSize is the size, in bytes, of signatures generated and verified by this package.
	SignatureSize = 64
)
View Source
const (
	N2 = 32 // ceil(log2(q) / 8)
	N  = N2 / 2

	NOSIGN = 3
)
View Source
const (
	// RandomValueSize is the size, in bytes, of VRF random value as used in this package.
	RandomValueSize = 32
	// ProveSize is the size, in bytes, of VRF prove as used in this package.
	ProveSize = 81
)

Variables

View Source
var (
	ErrMalformedInput = errors.New("ECVRF: malformed input")
	ErrDecodeError    = errors.New("ECVRF: decode error")
	ErrInternalError  = errors.New("ECVRF: internal error")
)

Functions

func ECVRFDecodeProof

func ECVRFDecodeProof(pi []byte) (r *edwards25519.ExtendedGroupElement, c *[N2]byte, s *[N2]byte, err error)

func ECVRFHashPoints

func ECVRFHashPoints(ps ...[]byte) *big.Int

func ECVRFHashToCurve

func ECVRFHashToCurve(m []byte, pk PublicKey) *edwards25519.ExtendedGroupElement

func ECVRFProof2hash

func ECVRFProof2hash(pi VRFProve) []byte

ECVRFProof2hash obtains the VRF hash value from the prove

func ECVRFVerify

func ECVRFVerify(pk PublicKey, pi VRFProve, m []byte) (bool, error)

ECVRFVerify reports whether pi is a valid VRF prove of m by publickey pk

func F2IP

func F2IP(f *[32]byte) *big.Int

convert a field number (in LittleEndian) to a big int

func GenerateKey

func GenerateKey(rand io.Reader) (publicKey PublicKey, privateKey PrivateKey, err error)

GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used.

func I2OSP

func I2OSP(b *big.Int, n int) []byte

func OS2ECP

func OS2ECP(os []byte, sign byte) *edwards25519.ExtendedGroupElement

func OS2IP

func OS2IP(os []byte) *big.Int

func S2OS

func S2OS(s []byte) []byte

just prepend the sign octet

func Sign

func Sign(privateKey PrivateKey, message []byte) []byte

Sign signs the message with privateKey and returns a signature. It will panic if len(privateKey) is not PrivateKeySize.

func Verify

func Verify(publicKey PublicKey, message, sig []byte) bool

Verify reports whether sig is a valid signature of message by publicKey. It will panic if len(publicKey) is not PublicKeySize.

Types

type CachedGroupElement

type CachedGroupElement struct {
	Z, T2d edwards25519.FieldElement
	// contains filtered or unexported fields
}

copied from edwards25519.go and const.go in golang.org/x/crypto/ed25519/internal/edwards25519

type PrivateKey

type PrivateKey []byte

PrivateKey is the type of Ed25519 private keys. It implements crypto.Signer.

func (PrivateKey) Public

func (priv PrivateKey) Public() crypto.PublicKey

Public returns the PublicKey corresponding to priv.

func (PrivateKey) Sign

func (priv PrivateKey) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) (signature []byte, err error)

Sign signs the given message with priv. Ed25519 performs two passes over messages to be signed and therefore cannot handle pre-hashed messages. Thus opts.HashFunc() must return zero to indicate the message hasn't been hashed. This can be achieved by passing crypto.Hash(0) as the value for opts.

type PublicKey

type PublicKey []byte

PublicKey is the type of Ed25519 public keys.

type VRFProve

type VRFProve []byte //ProveSize = 81 in bytes

VRFProve is the output prove of VRF_Ed25519.

func ECVRFProve

func ECVRFProve(pk PublicKey, sk PrivateKey, m []byte) (pi VRFProve, err error)

ECVRFProve generates the VRF prove, assume <pk, sk> were generated by ed25519.GenerateKey()

type VRFRandomValue

type VRFRandomValue []byte //RandomValueSize = 32 in bytes

VRFRandomValue is the output random value of VRF_Ed25519.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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