elligator

package module
v0.0.0-...-2ea1a6b Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

README

elligator-squared-p256

An implementation of the Elligator Squared algorithm for encoding NIST P-256 elliptic curve points as uniformly distributed bitstrings.

License

Copyright © 2025 Coda Hale Portions copied from the Go standard library.

Distributed under the Apache License 2.0 or MIT License.

Documentation

Overview

Example
// Generate a P-256 ECDH key pair.
k, err := ecdh.P256().GenerateKey(rand.Reader)
if err != nil {
	panic(err)
}

// Encode the public key.
encoded, err := Encode(k.PublicKey().Bytes(), rand.Reader)
if err != nil {
	panic(err)
}

// Decode the public key.
qP, err := Decode(encoded)
if err != nil {
	panic(err)
}

// Compare the two.
fmt.Println(bytes.Equal(k.PublicKey().Bytes(), qP))
Output:

true

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEncoding is returned when the given encoded point is malformed.
	ErrInvalidEncoding = errors.New("elligator: invalid encoding")
	// ErrInvalidPoint is returned when the given point is not an uncompressed SEC point.
	ErrInvalidPoint = errors.New("elligator: invalid point")
)

Functions

func Decode

func Decode(b []byte) ([]byte, error)

Decode maps the Elligator Squared-encoded point to an uncompressed SEC-encoded point.

func Encode

func Encode(p []byte, rand io.Reader) ([]byte, error)

Encode maps the given uncompressed SEC-encoded point to a random 64-byte bitstring.

Types

This section is empty.

Jump to

Keyboard shortcuts

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