p256

package
v0.0.0-...-3948e75 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Size = 32

Size is the size of a field element in bytes.

Variables

This section is empty.

Functions

func Add

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

func CMov

func CMov(y *Elt, x *Elt, c uint)

func Decode

func Decode(z *Elt, x *Elt)

Decode decodes from the Montgomery domain.

func Encode

func Encode(z *Elt, x *Elt)

Encode encodes into the Montgomery domain.

func Inv

func Inv(z *Elt, x *Elt)

Inv computes z = 1/x (mod p).

func Mul

func Mul(z *Elt, x *Elt, y *Elt)

func Neg

func Neg(z *Elt, x *Elt)

Neg computes z = -x (mod p).

func Sqr

func Sqr(z *Elt, x *Elt)

func Sub

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

Types

type Affine

type Affine struct {
	X Elt
	Y Elt
}

func NewAffine

func NewAffine(X, Y *big.Int) *Affine

func (*Affine) Coordinates

func (p *Affine) Coordinates() (X, Y *big.Int)

func (*Affine) Jacobian

func (a *Affine) Jacobian() (p *Jacobian)

func (*Affine) Projective

func (a *Affine) Projective() (p *Projective)

func (*Affine) Set

func (p *Affine) Set(q *Affine)

type Curve

type Curve interface {
	elliptic.Curve

	// Inverse computes the inverse of k modulo the order N. Satisfies the
	// crypto/ecdsa.invertable interface.
	Inverse(k *big.Int) *big.Int
}

Curve extends the standard elliptic.Curve interface.

func P256

func P256() Curve

P256 returns a Curve which implements P-256.

type Elt

type Elt [32]uint8

Elt is a field element.

func (*Elt) Int

func (x *Elt) Int() *big.Int

Int converts to a big integer.

func (*Elt) IntRaw

func (x *Elt) IntRaw() *big.Int

IntRaw converts to a big integer. This raw variant sets the value directly, bypassing any encoding/decoding steps.

func (*Elt) SetBytes

func (x *Elt) SetBytes(b []byte) *Elt

SetBytes constructs a field element from bytes in big-endian order.

func (*Elt) SetBytesRaw

func (x *Elt) SetBytesRaw(b []byte) *Elt

SetBytesRaw constructs a field element from bytes in big-endian order. This raw variant sets the value directly, bypassing any encoding/decoding steps.

func (*Elt) SetInt

func (x *Elt) SetInt(y *big.Int) *Elt

SetInt constructs a field element from a big integer.

func (*Elt) SetInt64

func (x *Elt) SetInt64(y int64) *Elt

SetInt64 constructs a field element from an integer.

func (*Elt) SetInt64Raw

func (x *Elt) SetInt64Raw(y int64) *Elt

SetInt64Raw constructs a field element from an integer. This raw variant sets the value directly, bypassing any encoding/decoding steps.

func (*Elt) SetIntRaw

func (x *Elt) SetIntRaw(y *big.Int) *Elt

SetIntRaw constructs a field element from a big integer. This raw variant sets the value directly, bypassing any encoding/decoding steps.

type Jacobian

type Jacobian struct {
	X Elt
	Y Elt
	Z Elt
}

func NewJacobian

func NewJacobian(X, Y, Z *big.Int) *Jacobian

func (*Jacobian) Add

func (p *Jacobian) Add(q *Jacobian, r *Jacobian)

func (*Jacobian) Affine

func (p *Jacobian) Affine() (a *Affine)

func (*Jacobian) CMov

func (p *Jacobian) CMov(q *Jacobian, c uint)

func (*Jacobian) CNeg

func (p *Jacobian) CNeg(c uint)

func (*Jacobian) Coordinates

func (p *Jacobian) Coordinates() (X, Y, Z *big.Int)

func (*Jacobian) Double

func (p *Jacobian) Double(q *Jacobian)

func (*Jacobian) Projective

func (p *Jacobian) Projective() (q *Projective)

func (*Jacobian) Set

func (p *Jacobian) Set(q *Jacobian)

type Projective

type Projective struct {
	X Elt
	Y Elt
	Z Elt
}

func NewProjective

func NewProjective(X, Y, Z *big.Int) *Projective

func (*Projective) Affine

func (p *Projective) Affine() (a *Affine)

func (*Projective) CNeg

func (p *Projective) CNeg(c uint)

func (*Projective) CompleteAdd

func (p *Projective) CompleteAdd(q *Projective, r *Projective)

func (*Projective) Coordinates

func (p *Projective) Coordinates() (X, Y, Z *big.Int)

func (*Projective) Set

func (p *Projective) Set(q *Projective)

Jump to

Keyboard shortcuts

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