ecmath

package
v1.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Zero is the number 0.
	Zero Scalar

	// One is the number 1.
	One = Scalar{1}

	// NegOne is the number -1 mod L
	NegOne = Scalar{
		0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
		0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
	}

	// L is the subgroup order:
	// 2^252 + 27742317777372353535851937790883648493
	L = Scalar{
		0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
		0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
	}
)

Functions

This section is empty.

Types

type Point

Point is a point on the ed25519 curve.

var ZeroPoint Point

ZeroPoint is the zero point on the ed25519 curve (not the zero value of Point).

func (*Point) Add

func (z *Point) Add(x, y *Point) *Point

Add adds the points in x and y, storing the result in z and returning that. Any or all of x, y, and z may be the same pointers.

func (*Point) ConstTimeEqual

func (z *Point) ConstTimeEqual(x *Point) bool

func (*Point) Decode

func (z *Point) Decode(e [32]byte) (*Point, bool)

func (*Point) Encode

func (z *Point) Encode() [32]byte

func (*Point) ScMul

func (z *Point) ScMul(x *Point, y *Scalar) *Point

ScMul multiplies the EC point x by the scalar y, placing the result in z and returning that. X and z may be the same pointer.

func (*Point) ScMulAdd

func (z *Point) ScMulAdd(a *Point, x, y *Scalar) *Point

ScMulAdd computes xa+yB, where B is the ed25519 base point, and places the result in z, returning that.

func (*Point) ScMulBase

func (z *Point) ScMulBase(x *Scalar) *Point

ScMulBase multiplies the ed25519 base point by x and places the result in z, returning that.

func (*Point) Sub

func (z *Point) Sub(x, y *Point) *Point

Sub subtracts y from x, storing the result in z and returning that. Any or all of x, y, and z may be the same pointers.

type Scalar

type Scalar [32]byte

Scalar is a 256-bit little-endian scalar.

func (*Scalar) Add

func (z *Scalar) Add(x, y *Scalar) *Scalar

Add computes x+y (mod L) and places the result in z, returning that. Any or all of x, y, and z may be the same pointer.

func (*Scalar) Equal

func (z *Scalar) Equal(x *Scalar) bool

func (*Scalar) MulAdd

func (z *Scalar) MulAdd(a, b, c *Scalar) *Scalar

MulAdd computes ab+c (mod L) and places the result in z, returning that. Any or all of the pointers may be the same.

func (*Scalar) Neg

func (z *Scalar) Neg(x *Scalar) *Scalar

Neg negates x (mod L) and places the result in z, returning that. X and z may be the same pointer.

func (*Scalar) Prune

func (z *Scalar) Prune()

Prune performs the pruning operation in-place.

func (*Scalar) Reduce

func (z *Scalar) Reduce(x *[64]byte) *Scalar

Reduce takes a 512-bit scalar and reduces it mod L, placing the result in z and returning that.

func (*Scalar) Sub

func (z *Scalar) Sub(x, y *Scalar) *Scalar

Sub computes x-y (mod L) and places the result in z, returning that. Any or all of x, y, and z may be the same pointer.

Jump to

Keyboard shortcuts

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