curvey

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 31 Imported by: 1

README

curvey

Implementations of constant time elliptic curves in go. The following elliptic curves are provided

  • BLS12-381
  • Ed25519
  • Secp256k1
  • NistP256
  • Pallas

These curves all implement a common interface and as such can be used in a curve agnostic manner.

This work is derived from Coinbase's kryptology library.

Security and Compliance

All the code is strict, both in terms of timing-based side-channels (everything is constant-time, except if explicity state otherwise) and in compliance to relavant standards. There is no attempt at "zeroing memory" anywhere in the code. Golang just doesn't really support this easily and it ruins readability. In general, such memory cleansing is a fool's errand anyway.

Warning: Although all of the code aims at being representative of optimized production ready-code, some bugs might still exist, no matter how careful I am. Any assertion of suitability to any purpose is explicitly denied. The primary purpose of this library is to enable various elliptic curves that implement a common interface, and easy-to-use API.

License

Licensed under Apache License, Version 2.0, LICENSE or http://www.apache.org/licenses/LICENSE-2.0

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any terms or conditions.

Documentation

Index

Constants

View Source
const (
	K256Name       = "secp256k1"
	BLS12381G1Name = "BLS12381G1"
	BLS12381G2Name = "BLS12381G2"
	BLS12831Name   = "BLS12831"
	P256Name       = "P-256"
	P384Name       = "P-384"
	ED25519Name    = "ed25519"
	PallasName     = "pallas"
)

Variables

This section is empty.

Functions

func PointMarshalBinary

func PointMarshalBinary(point Point) ([]byte, error)

func PointMarshalJSON

func PointMarshalJSON(point Point) ([]byte, error)

func PointMarshalText

func PointMarshalText(point Point) ([]byte, error)

func ScalarMarshalBinary

func ScalarMarshalBinary(scalar Scalar) ([]byte, error)

func ScalarMarshalJSON

func ScalarMarshalJSON(scalar Scalar) ([]byte, error)

func ScalarMarshalText

func ScalarMarshalText(scalar Scalar) ([]byte, error)

Types

type Curve

type Curve struct {
	Scalar Scalar
	Point  Point
	Name   string
}

Curve represents a named elliptic curve with a scalar field and point group.

func BLS12381G1

func BLS12381G1() *Curve

BLS12381G1 returns the BLS12-381 curve with points in G1.

func BLS12381G2

func BLS12381G2() *Curve

BLS12381G2 returns the BLS12-381 curve with points in G2.

func ED25519

func ED25519() *Curve

func GetCurveByName

func GetCurveByName(name string) *Curve

GetCurveByName returns the correct `Curve` given the name.

func K256

func K256() *Curve

K256 returns the secp256k1 curve.

func P256

func P256() *Curve

func P384 added in v1.1.0

func P384() *Curve

func PALLAS

func PALLAS() *Curve

func (*Curve) NewGeneratorPoint

func (c *Curve) NewGeneratorPoint() Point

func (*Curve) NewIdentityPoint

func (c *Curve) NewIdentityPoint() Point

func (*Curve) NewScalar

func (c *Curve) NewScalar() Scalar

func (*Curve) ScalarBaseMult

func (c *Curve) ScalarBaseMult(sc Scalar) Point

func (*Curve) ToEllipticCurve

func (c *Curve) ToEllipticCurve() (elliptic.Curve, error)

ToEllipticCurve returns the equivalent of this curve as the go interface `elliptic.Curve`.

type Koblitz256

type Koblitz256 struct {
	*elliptic.CurveParams
}

func K256Curve

func K256Curve() *Koblitz256

func (*Koblitz256) Add

func (*Koblitz256) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*Koblitz256) Double

func (*Koblitz256) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*Koblitz256) IsOnCurve

func (*Koblitz256) IsOnCurve(x, y *big.Int) bool

func (*Koblitz256) Params

func (curve *Koblitz256) Params() *elliptic.CurveParams

func (*Koblitz256) ScalarBaseMult

func (*Koblitz256) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*Koblitz256) ScalarMult

func (*Koblitz256) ScalarMult(capBx, capBy *big.Int, k []byte) (*big.Int, *big.Int)

type NistP256

type NistP256 struct {
	*elliptic.CurveParams
}

func NistP256Curve

func NistP256Curve() *NistP256

func (*NistP256) Add

func (*NistP256) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*NistP256) Double

func (*NistP256) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*NistP256) IsOnCurve

func (*NistP256) IsOnCurve(x, y *big.Int) bool

func (*NistP256) Params

func (curve *NistP256) Params() *elliptic.CurveParams

func (*NistP256) ScalarBaseMult

func (*NistP256) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*NistP256) ScalarMul

func (*NistP256) ScalarMul(capBx, capBy *big.Int, k []byte) (*big.Int, *big.Int)

type NistP384 added in v1.1.0

type NistP384 struct {
	*elliptic.CurveParams
}

func NistP384Curve added in v1.1.0

func NistP384Curve() *NistP384

func (*NistP384) Add added in v1.1.0

func (*NistP384) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*NistP384) Double added in v1.1.0

func (*NistP384) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*NistP384) IsOnCurve added in v1.1.0

func (*NistP384) IsOnCurve(x, y *big.Int) bool

func (*NistP384) Params added in v1.1.0

func (curve *NistP384) Params() *elliptic.CurveParams

func (*NistP384) ScalarBaseMult added in v1.1.0

func (*NistP384) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*NistP384) ScalarMul added in v1.1.0

func (*NistP384) ScalarMul(capBx, capBy *big.Int, k []byte) (*big.Int, *big.Int)

type PairingCurve

type PairingCurve struct {
	Scalar  PairingScalar
	PointG1 PairingPoint
	PointG2 PairingPoint
	GT      Scalar
	Name    string
}

PairingCurve represents a named elliptic curve that supports pairings.

func BLS12381

func BLS12381(preferredPoint Point) *PairingCurve

func GetPairingCurveByName

func GetPairingCurveByName(name string) *PairingCurve

func (*PairingCurve) NewG1GeneratorPoint

func (c *PairingCurve) NewG1GeneratorPoint() PairingPoint

func (*PairingCurve) NewG1IdentityPoint

func (c *PairingCurve) NewG1IdentityPoint() PairingPoint

func (*PairingCurve) NewG2GeneratorPoint

func (c *PairingCurve) NewG2GeneratorPoint() PairingPoint

func (*PairingCurve) NewG2IdentityPoint

func (c *PairingCurve) NewG2IdentityPoint() PairingPoint

func (*PairingCurve) NewScalar

func (c *PairingCurve) NewScalar() PairingScalar

func (*PairingCurve) ScalarG1BaseMult

func (c *PairingCurve) ScalarG1BaseMult(sc Scalar) PairingPoint

func (*PairingCurve) ScalarG2BaseMult

func (c *PairingCurve) ScalarG2BaseMult(sc Scalar) PairingPoint

type PairingPoint

type PairingPoint interface {
	Point
	OtherGroup() PairingPoint
	Pairing(rhs PairingPoint) Scalar
	MultiPairing(...PairingPoint) Scalar
}

type PairingScalar

type PairingScalar interface {
	Scalar
	SetPoint(p Point) PairingScalar
}

type PallasCurve

type PallasCurve struct {
	*elliptic.CurveParams
}

func Pallas

func Pallas() *PallasCurve

func (*PallasCurve) Add

func (*PallasCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*PallasCurve) Double

func (*PallasCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*PallasCurve) IsOnCurve

func (*PallasCurve) IsOnCurve(x, y *big.Int) bool

func (*PallasCurve) Params

func (curve *PallasCurve) Params() *elliptic.CurveParams

func (*PallasCurve) ScalarBaseMult

func (*PallasCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*PallasCurve) ScalarMult

func (*PallasCurve) ScalarMult(bx, by *big.Int, k []byte) (*big.Int, *big.Int)

type PallasScalar

type PallasScalar struct{}

PallasScalar - Old interface.

func NewPallasScalar

func NewPallasScalar() *PallasScalar

func (PallasScalar) Add

func (PallasScalar) Add(x, y *big.Int) *big.Int

func (PallasScalar) Bytes

func (PallasScalar) Bytes(x *big.Int) []byte

func (PallasScalar) Div

func (PallasScalar) Div(x, y *big.Int) *big.Int

func (PallasScalar) Hash

func (PallasScalar) Hash(input []byte) *big.Int

func (PallasScalar) IsValid

func (PallasScalar) IsValid(x *big.Int) bool

func (PallasScalar) Mul

func (PallasScalar) Mul(x, y *big.Int) *big.Int

func (PallasScalar) Neg

func (PallasScalar) Neg(x *big.Int) *big.Int

func (PallasScalar) Random

func (PallasScalar) Random() (*big.Int, error)

func (PallasScalar) Sub

func (PallasScalar) Sub(x, y *big.Int) *big.Int

type Point

type Point interface {
	Random(reader io.Reader) Point
	Hash(bytes []byte) Point
	Identity() Point
	Generator() Point
	IsIdentity() bool
	IsNegative() bool
	IsOnCurve() bool
	Double() Point
	Scalar() Scalar
	Neg() Point
	Add(rhs Point) Point
	Sub(rhs Point) Point
	Mul(rhs Scalar) Point
	Equal(rhs Point) bool
	Set(x, y *big.Int) (Point, error)
	ToAffineCompressed() []byte
	ToAffineUncompressed() []byte
	FromAffineCompressed(bytes []byte) (Point, error)
	FromAffineUncompressed(bytes []byte) (Point, error)
	CurveName() string
	SumOfProducts(points []Point, scalars []Scalar) Point
}

Point represents an elliptic curve point.

func PointUnmarshalBinary

func PointUnmarshalBinary(input []byte) (Point, error)

func PointUnmarshalJSON

func PointUnmarshalJSON(input []byte) (Point, error)

func PointUnmarshalText

func PointUnmarshalText(input []byte) (Point, error)

type PointBls12381G1

type PointBls12381G1 struct {
	Value *bls12381.G1
}

func (*PointBls12381G1) Add

func (p *PointBls12381G1) Add(rhs Point) Point

func (*PointBls12381G1) CurveName

func (*PointBls12381G1) CurveName() string

func (*PointBls12381G1) Double

func (p *PointBls12381G1) Double() Point

func (*PointBls12381G1) Equal

func (p *PointBls12381G1) Equal(rhs Point) bool

func (*PointBls12381G1) FromAffineCompressed

func (*PointBls12381G1) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointBls12381G1) FromAffineUncompressed

func (*PointBls12381G1) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointBls12381G1) Generator

func (*PointBls12381G1) Generator() Point

func (*PointBls12381G1) Hash

func (*PointBls12381G1) Hash(bytes []byte) Point

func (*PointBls12381G1) Identity

func (*PointBls12381G1) Identity() Point

func (*PointBls12381G1) IsIdentity

func (p *PointBls12381G1) IsIdentity() bool

func (*PointBls12381G1) IsNegative

func (p *PointBls12381G1) IsNegative() bool

func (*PointBls12381G1) IsOnCurve

func (p *PointBls12381G1) IsOnCurve() bool

func (*PointBls12381G1) MarshalBinary

func (p *PointBls12381G1) MarshalBinary() ([]byte, error)

func (*PointBls12381G1) MarshalJSON

func (p *PointBls12381G1) MarshalJSON() ([]byte, error)

func (*PointBls12381G1) MarshalText

func (p *PointBls12381G1) MarshalText() ([]byte, error)

func (*PointBls12381G1) Modulus

func (*PointBls12381G1) Modulus() *big.Int

func (*PointBls12381G1) Mul

func (p *PointBls12381G1) Mul(rhs Scalar) Point

func (*PointBls12381G1) MultiPairing

func (*PointBls12381G1) MultiPairing(points ...PairingPoint) Scalar

func (*PointBls12381G1) Neg

func (p *PointBls12381G1) Neg() Point

func (*PointBls12381G1) OtherGroup

func (*PointBls12381G1) OtherGroup() PairingPoint

func (*PointBls12381G1) Pairing

func (p *PointBls12381G1) Pairing(rhs PairingPoint) Scalar

func (*PointBls12381G1) Random

func (p *PointBls12381G1) Random(reader io.Reader) Point

func (*PointBls12381G1) Scalar

func (*PointBls12381G1) Scalar() Scalar

func (*PointBls12381G1) Set

func (*PointBls12381G1) Set(x, y *big.Int) (Point, error)

func (*PointBls12381G1) Sub

func (p *PointBls12381G1) Sub(rhs Point) Point

func (*PointBls12381G1) SumOfProducts

func (*PointBls12381G1) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointBls12381G1) ToAffineCompressed

func (p *PointBls12381G1) ToAffineCompressed() []byte

func (*PointBls12381G1) ToAffineUncompressed

func (p *PointBls12381G1) ToAffineUncompressed() []byte

func (*PointBls12381G1) UnmarshalBinary

func (p *PointBls12381G1) UnmarshalBinary(input []byte) error

func (*PointBls12381G1) UnmarshalJSON

func (p *PointBls12381G1) UnmarshalJSON(input []byte) error

func (*PointBls12381G1) UnmarshalText

func (p *PointBls12381G1) UnmarshalText(input []byte) error

func (*PointBls12381G1) X

func (p *PointBls12381G1) X() *big.Int

func (*PointBls12381G1) Y

func (p *PointBls12381G1) Y() *big.Int

type PointBls12381G2

type PointBls12381G2 struct {
	Value *bls12381.G2
}

func (*PointBls12381G2) Add

func (p *PointBls12381G2) Add(rhs Point) Point

func (*PointBls12381G2) CurveName

func (*PointBls12381G2) CurveName() string

func (*PointBls12381G2) Double

func (p *PointBls12381G2) Double() Point

func (*PointBls12381G2) Equal

func (p *PointBls12381G2) Equal(rhs Point) bool

func (*PointBls12381G2) FromAffineCompressed

func (*PointBls12381G2) FromAffineCompressed(x []byte) (Point, error)

func (*PointBls12381G2) FromAffineUncompressed

func (*PointBls12381G2) FromAffineUncompressed(x []byte) (Point, error)

func (*PointBls12381G2) Generator

func (*PointBls12381G2) Generator() Point

func (*PointBls12381G2) Hash

func (*PointBls12381G2) Hash(bytes []byte) Point

func (*PointBls12381G2) Identity

func (*PointBls12381G2) Identity() Point

func (*PointBls12381G2) IsIdentity

func (p *PointBls12381G2) IsIdentity() bool

func (*PointBls12381G2) IsNegative

func (p *PointBls12381G2) IsNegative() bool

func (*PointBls12381G2) IsOnCurve

func (p *PointBls12381G2) IsOnCurve() bool

func (*PointBls12381G2) MarshalBinary

func (p *PointBls12381G2) MarshalBinary() ([]byte, error)

func (*PointBls12381G2) MarshalJSON

func (p *PointBls12381G2) MarshalJSON() ([]byte, error)

func (*PointBls12381G2) MarshalText

func (p *PointBls12381G2) MarshalText() ([]byte, error)

func (*PointBls12381G2) Modulus

func (*PointBls12381G2) Modulus() *big.Int

func (*PointBls12381G2) Mul

func (p *PointBls12381G2) Mul(rhs Scalar) Point

func (*PointBls12381G2) MultiPairing

func (*PointBls12381G2) MultiPairing(points ...PairingPoint) Scalar

func (*PointBls12381G2) Neg

func (p *PointBls12381G2) Neg() Point

func (*PointBls12381G2) OtherGroup

func (*PointBls12381G2) OtherGroup() PairingPoint

func (*PointBls12381G2) Pairing

func (p *PointBls12381G2) Pairing(rhs PairingPoint) Scalar

func (*PointBls12381G2) Random

func (p *PointBls12381G2) Random(reader io.Reader) Point

func (*PointBls12381G2) Scalar

func (*PointBls12381G2) Scalar() Scalar

func (*PointBls12381G2) Set

func (*PointBls12381G2) Set(x, y *big.Int) (Point, error)

func (*PointBls12381G2) Sub

func (p *PointBls12381G2) Sub(rhs Point) Point

func (*PointBls12381G2) SumOfProducts

func (*PointBls12381G2) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointBls12381G2) ToAffineCompressed

func (p *PointBls12381G2) ToAffineCompressed() []byte

func (*PointBls12381G2) ToAffineUncompressed

func (p *PointBls12381G2) ToAffineUncompressed() []byte

func (*PointBls12381G2) UnmarshalBinary

func (p *PointBls12381G2) UnmarshalBinary(input []byte) error

func (*PointBls12381G2) UnmarshalJSON

func (p *PointBls12381G2) UnmarshalJSON(input []byte) error

func (*PointBls12381G2) UnmarshalText

func (p *PointBls12381G2) UnmarshalText(input []byte) error

func (*PointBls12381G2) X

func (p *PointBls12381G2) X() *big.Int

func (*PointBls12381G2) Y

func (p *PointBls12381G2) Y() *big.Int

type PointBls12381Gt added in v1.0.2

type PointBls12381Gt struct {
	Value *bls12381.Gt
}

PointBls12381Gt exists for convenience if a point is needed for dealing with a scalar

func (*PointBls12381Gt) Add added in v1.0.2

func (p *PointBls12381Gt) Add(rhs Point) Point

func (*PointBls12381Gt) CurveName added in v1.0.2

func (p *PointBls12381Gt) CurveName() string

func (*PointBls12381Gt) Double added in v1.0.2

func (p *PointBls12381Gt) Double() Point

func (*PointBls12381Gt) Equal added in v1.0.2

func (p *PointBls12381Gt) Equal(rhs Point) bool

func (*PointBls12381Gt) FromAffineCompressed added in v1.0.2

func (p *PointBls12381Gt) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointBls12381Gt) FromAffineUncompressed added in v1.0.2

func (p *PointBls12381Gt) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointBls12381Gt) Generator added in v1.0.2

func (p *PointBls12381Gt) Generator() Point

func (*PointBls12381Gt) Hash added in v1.0.2

func (p *PointBls12381Gt) Hash(bytes []byte) Point

func (*PointBls12381Gt) Identity added in v1.0.2

func (p *PointBls12381Gt) Identity() Point

func (*PointBls12381Gt) IsIdentity added in v1.0.2

func (p *PointBls12381Gt) IsIdentity() bool

func (*PointBls12381Gt) IsNegative added in v1.0.2

func (p *PointBls12381Gt) IsNegative() bool

func (*PointBls12381Gt) IsOnCurve added in v1.0.2

func (p *PointBls12381Gt) IsOnCurve() bool

func (*PointBls12381Gt) Mul added in v1.0.2

func (p *PointBls12381Gt) Mul(rhs Scalar) Point

func (*PointBls12381Gt) Neg added in v1.0.2

func (p *PointBls12381Gt) Neg() Point

func (*PointBls12381Gt) Random added in v1.0.2

func (p *PointBls12381Gt) Random(reader io.Reader) Point

func (*PointBls12381Gt) Scalar added in v1.0.2

func (p *PointBls12381Gt) Scalar() Scalar

func (*PointBls12381Gt) Set added in v1.0.2

func (p *PointBls12381Gt) Set(x, y *big.Int) (Point, error)

func (*PointBls12381Gt) Sub added in v1.0.2

func (p *PointBls12381Gt) Sub(rhs Point) Point

func (*PointBls12381Gt) SumOfProducts added in v1.0.2

func (p *PointBls12381Gt) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointBls12381Gt) ToAffineCompressed added in v1.0.2

func (p *PointBls12381Gt) ToAffineCompressed() []byte

func (*PointBls12381Gt) ToAffineUncompressed added in v1.0.2

func (p *PointBls12381Gt) ToAffineUncompressed() []byte

type PointEd25519

type PointEd25519 struct {
	// contains filtered or unexported fields
}

func (*PointEd25519) Add

func (p *PointEd25519) Add(rhs Point) Point

func (*PointEd25519) CurveName

func (*PointEd25519) CurveName() string

func (*PointEd25519) Double

func (p *PointEd25519) Double() Point

func (*PointEd25519) Equal

func (p *PointEd25519) Equal(rhs Point) bool

func (*PointEd25519) FromAffineCompressed

func (*PointEd25519) FromAffineCompressed(b []byte) (Point, error)

func (*PointEd25519) FromAffineUncompressed

func (*PointEd25519) FromAffineUncompressed(b []byte) (Point, error)

func (*PointEd25519) Generator

func (*PointEd25519) Generator() Point

func (*PointEd25519) GetEdwardsPoint

func (p *PointEd25519) GetEdwardsPoint() *edwards25519.Point

func (*PointEd25519) Hash

func (*PointEd25519) Hash(b []byte) Point

func (*PointEd25519) Identity

func (*PointEd25519) Identity() Point

func (*PointEd25519) IsIdentity

func (p *PointEd25519) IsIdentity() bool

func (*PointEd25519) IsNegative

func (*PointEd25519) IsNegative() bool

func (*PointEd25519) IsOnCurve

func (p *PointEd25519) IsOnCurve() bool

func (*PointEd25519) MangleScalarBitsAndMulByBasepointToProducePublicKey

func (*PointEd25519) MangleScalarBitsAndMulByBasepointToProducePublicKey(rhs *ScalarEd25519) *PointEd25519

MangleScalarBitsAndMulByBasepointToProducePublicKey is a function for mangling the bits of a (formerly mathematically well-defined) "scalar" and multiplying it to produce a public key.

func (*PointEd25519) MarshalBinary

func (p *PointEd25519) MarshalBinary() ([]byte, error)

func (*PointEd25519) MarshalJSON

func (p *PointEd25519) MarshalJSON() ([]byte, error)

func (*PointEd25519) MarshalText

func (p *PointEd25519) MarshalText() ([]byte, error)

func (*PointEd25519) Mul

func (p *PointEd25519) Mul(rhs Scalar) Point

func (*PointEd25519) Neg

func (p *PointEd25519) Neg() Point

func (*PointEd25519) Random

func (p *PointEd25519) Random(reader io.Reader) Point

func (*PointEd25519) Scalar

func (*PointEd25519) Scalar() Scalar

func (*PointEd25519) Set

func (p *PointEd25519) Set(x, y *big.Int) (Point, error)

func (*PointEd25519) SetEdwardsPoint

func (*PointEd25519) SetEdwardsPoint(pt *edwards25519.Point) *PointEd25519

func (*PointEd25519) Sub

func (p *PointEd25519) Sub(rhs Point) Point

func (*PointEd25519) SumOfProducts

func (*PointEd25519) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointEd25519) ToAffineCompressed

func (p *PointEd25519) ToAffineCompressed() []byte

func (*PointEd25519) ToAffineUncompressed

func (p *PointEd25519) ToAffineUncompressed() []byte

func (*PointEd25519) UnmarshalBinary

func (p *PointEd25519) UnmarshalBinary(input []byte) error

func (*PointEd25519) UnmarshalJSON

func (p *PointEd25519) UnmarshalJSON(input []byte) error

func (*PointEd25519) UnmarshalText

func (p *PointEd25519) UnmarshalText(input []byte) error

func (*PointEd25519) VarTimeDoubleScalarBaseMult

func (*PointEd25519) VarTimeDoubleScalarBaseMult(a Scalar, capA Point, b Scalar) Point

type PointK256

type PointK256 struct {
	// contains filtered or unexported fields
}

func (*PointK256) Add

func (p *PointK256) Add(rhs Point) Point

func (*PointK256) CurveName

func (p *PointK256) CurveName() string

func (*PointK256) Double

func (p *PointK256) Double() Point

func (*PointK256) Equal

func (p *PointK256) Equal(rhs Point) bool

func (*PointK256) FromAffineCompressed

func (p *PointK256) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointK256) FromAffineUncompressed

func (*PointK256) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointK256) Generator

func (*PointK256) Generator() Point

func (*PointK256) Hash

func (*PointK256) Hash(bytes []byte) Point

func (*PointK256) Identity

func (*PointK256) Identity() Point

func (*PointK256) IsIdentity

func (p *PointK256) IsIdentity() bool

func (*PointK256) IsNegative

func (p *PointK256) IsNegative() bool

func (*PointK256) IsOnCurve

func (p *PointK256) IsOnCurve() bool

func (*PointK256) MarshalBinary

func (p *PointK256) MarshalBinary() ([]byte, error)

func (*PointK256) MarshalJSON

func (p *PointK256) MarshalJSON() ([]byte, error)

func (*PointK256) MarshalText

func (p *PointK256) MarshalText() ([]byte, error)

func (*PointK256) Mul

func (p *PointK256) Mul(rhs Scalar) Point

func (*PointK256) Neg

func (p *PointK256) Neg() Point

func (*PointK256) Params

func (*PointK256) Params() *elliptic.CurveParams

func (*PointK256) Random

func (p *PointK256) Random(reader io.Reader) Point

func (*PointK256) Scalar

func (*PointK256) Scalar() Scalar

func (*PointK256) Set

func (*PointK256) Set(x, y *big.Int) (Point, error)

func (*PointK256) Sub

func (p *PointK256) Sub(rhs Point) Point

func (*PointK256) SumOfProducts

func (*PointK256) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointK256) ToAffineCompressed

func (p *PointK256) ToAffineCompressed() []byte

func (*PointK256) ToAffineUncompressed

func (p *PointK256) ToAffineUncompressed() []byte

func (*PointK256) UnmarshalBinary

func (p *PointK256) UnmarshalBinary(input []byte) error

func (*PointK256) UnmarshalJSON

func (p *PointK256) UnmarshalJSON(input []byte) error

func (*PointK256) UnmarshalText

func (p *PointK256) UnmarshalText(input []byte) error

func (*PointK256) X

func (p *PointK256) X() *native.Field4

func (*PointK256) Y

func (p *PointK256) Y() *native.Field4

type PointP256

type PointP256 struct {
	// contains filtered or unexported fields
}

func (*PointP256) Add

func (p *PointP256) Add(rhs Point) Point

func (*PointP256) CurveName

func (*PointP256) CurveName() string

func (*PointP256) Double

func (p *PointP256) Double() Point

func (*PointP256) Equal

func (p *PointP256) Equal(rhs Point) bool

func (*PointP256) FromAffineCompressed

func (p *PointP256) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointP256) FromAffineUncompressed

func (*PointP256) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointP256) Generator

func (*PointP256) Generator() Point

func (*PointP256) Hash

func (*PointP256) Hash(bytes []byte) Point

func (*PointP256) Identity

func (*PointP256) Identity() Point

func (*PointP256) IsIdentity

func (p *PointP256) IsIdentity() bool

func (*PointP256) IsNegative

func (p *PointP256) IsNegative() bool

func (*PointP256) IsOnCurve

func (p *PointP256) IsOnCurve() bool

func (*PointP256) MarshalBinary

func (p *PointP256) MarshalBinary() ([]byte, error)

func (*PointP256) MarshalJSON

func (p *PointP256) MarshalJSON() ([]byte, error)

func (*PointP256) MarshalText

func (p *PointP256) MarshalText() ([]byte, error)

func (*PointP256) Mul

func (p *PointP256) Mul(rhs Scalar) Point

func (*PointP256) Neg

func (p *PointP256) Neg() Point

func (*PointP256) Params

func (*PointP256) Params() *elliptic.CurveParams

func (*PointP256) Random

func (p *PointP256) Random(reader io.Reader) Point

func (*PointP256) Scalar

func (*PointP256) Scalar() Scalar

func (*PointP256) Set

func (*PointP256) Set(x, y *big.Int) (Point, error)

func (*PointP256) Sub

func (p *PointP256) Sub(rhs Point) Point

func (*PointP256) SumOfProducts

func (*PointP256) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointP256) ToAffineCompressed

func (p *PointP256) ToAffineCompressed() []byte

func (*PointP256) ToAffineUncompressed

func (p *PointP256) ToAffineUncompressed() []byte

func (*PointP256) UnmarshalBinary

func (p *PointP256) UnmarshalBinary(input []byte) error

func (*PointP256) UnmarshalJSON

func (p *PointP256) UnmarshalJSON(input []byte) error

func (*PointP256) UnmarshalText

func (p *PointP256) UnmarshalText(input []byte) error

func (*PointP256) X

func (p *PointP256) X() *native.Field4

func (*PointP256) Y

func (p *PointP256) Y() *native.Field4

type PointP384 added in v1.1.0

type PointP384 struct {
	// contains filtered or unexported fields
}

func (*PointP384) Add added in v1.1.0

func (p *PointP384) Add(rhs Point) Point

func (*PointP384) CurveName added in v1.1.0

func (*PointP384) CurveName() string

func (*PointP384) Double added in v1.1.0

func (p *PointP384) Double() Point

func (*PointP384) Equal added in v1.1.0

func (p *PointP384) Equal(rhs Point) bool

func (*PointP384) FromAffineCompressed added in v1.1.0

func (p *PointP384) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointP384) FromAffineUncompressed added in v1.1.0

func (*PointP384) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointP384) Generator added in v1.1.0

func (*PointP384) Generator() Point

func (*PointP384) Hash added in v1.1.0

func (*PointP384) Hash(bytes []byte) Point

func (*PointP384) Identity added in v1.1.0

func (*PointP384) Identity() Point

func (*PointP384) IsIdentity added in v1.1.0

func (p *PointP384) IsIdentity() bool

func (*PointP384) IsNegative added in v1.1.0

func (p *PointP384) IsNegative() bool

func (*PointP384) IsOnCurve added in v1.1.0

func (p *PointP384) IsOnCurve() bool

func (*PointP384) MarshalBinary added in v1.1.0

func (p *PointP384) MarshalBinary() ([]byte, error)

func (*PointP384) MarshalJSON added in v1.1.0

func (p *PointP384) MarshalJSON() ([]byte, error)

func (*PointP384) MarshalText added in v1.1.0

func (p *PointP384) MarshalText() ([]byte, error)

func (*PointP384) Mul added in v1.1.0

func (p *PointP384) Mul(rhs Scalar) Point

func (*PointP384) Neg added in v1.1.0

func (p *PointP384) Neg() Point

func (*PointP384) Params added in v1.1.0

func (*PointP384) Params() *elliptic.CurveParams

func (*PointP384) Random added in v1.1.0

func (p *PointP384) Random(reader io.Reader) Point

func (*PointP384) Scalar added in v1.1.0

func (*PointP384) Scalar() Scalar

func (*PointP384) Set added in v1.1.0

func (*PointP384) Set(x, y *big.Int) (Point, error)

func (*PointP384) Sub added in v1.1.0

func (p *PointP384) Sub(rhs Point) Point

func (*PointP384) SumOfProducts added in v1.1.0

func (*PointP384) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointP384) ToAffineCompressed added in v1.1.0

func (p *PointP384) ToAffineCompressed() []byte

func (*PointP384) ToAffineUncompressed added in v1.1.0

func (p *PointP384) ToAffineUncompressed() []byte

func (*PointP384) UnmarshalBinary added in v1.1.0

func (p *PointP384) UnmarshalBinary(input []byte) error

func (*PointP384) UnmarshalJSON added in v1.1.0

func (p *PointP384) UnmarshalJSON(input []byte) error

func (*PointP384) UnmarshalText added in v1.1.0

func (p *PointP384) UnmarshalText(input []byte) error

func (*PointP384) X added in v1.1.0

func (p *PointP384) X() *native.Field6

func (*PointP384) Y added in v1.1.0

func (p *PointP384) Y() *native.Field6

type PointPallas

type PointPallas struct {
	*native.EllipticPoint4
}

func (*PointPallas) Add

func (p *PointPallas) Add(rhs Point) Point

func (*PointPallas) CurveName

func (*PointPallas) CurveName() string

func (*PointPallas) Double

func (p *PointPallas) Double() Point

func (*PointPallas) Equal

func (p *PointPallas) Equal(rhs Point) bool

func (*PointPallas) FromAffineCompressed

func (p *PointPallas) FromAffineCompressed(bytes []byte) (Point, error)

func (*PointPallas) FromAffineUncompressed

func (*PointPallas) FromAffineUncompressed(bytes []byte) (Point, error)

func (*PointPallas) Generator

func (*PointPallas) Generator() Point

func (*PointPallas) Hash

func (*PointPallas) Hash(bytes []byte) Point

func (*PointPallas) Identity

func (*PointPallas) Identity() Point

func (*PointPallas) IsNegative

func (p *PointPallas) IsNegative() bool

func (*PointPallas) MarshalBinary

func (p *PointPallas) MarshalBinary() ([]byte, error)

func (*PointPallas) MarshalJSON

func (p *PointPallas) MarshalJSON() ([]byte, error)

func (*PointPallas) MarshalText

func (p *PointPallas) MarshalText() ([]byte, error)

func (*PointPallas) Mul

func (p *PointPallas) Mul(rhs Scalar) Point

func (*PointPallas) Neg

func (p *PointPallas) Neg() Point

func (*PointPallas) Random

func (p *PointPallas) Random(reader io.Reader) Point

func (*PointPallas) Scalar

func (*PointPallas) Scalar() Scalar

func (*PointPallas) Set

func (*PointPallas) Set(x, y *big.Int) (Point, error)

func (*PointPallas) Sub

func (p *PointPallas) Sub(rhs Point) Point

func (*PointPallas) SumOfProducts

func (p *PointPallas) SumOfProducts(points []Point, scalars []Scalar) Point

func (*PointPallas) ToAffineCompressed

func (p *PointPallas) ToAffineCompressed() []byte

func (*PointPallas) ToAffineUncompressed

func (p *PointPallas) ToAffineUncompressed() []byte

func (*PointPallas) UnmarshalBinary

func (p *PointPallas) UnmarshalBinary(input []byte) error

func (*PointPallas) UnmarshalJSON

func (p *PointPallas) UnmarshalJSON(input []byte) error

func (*PointPallas) UnmarshalText

func (p *PointPallas) UnmarshalText(input []byte) error

func (*PointPallas) X

func (p *PointPallas) X() *native.Field4

func (*PointPallas) Y

func (p *PointPallas) Y() *native.Field4

type Scalar

type Scalar interface {
	// Random returns a random scalar using the provided reader
	// to retrieve bytes
	Random(reader io.Reader) Scalar
	// Hash the specific bytes in a manner to yield a
	// uniformly distributed scalar
	Hash(bytes []byte) Scalar
	// Zero returns the additive identity element
	Zero() Scalar
	// One returns the multiplicative identity element
	One() Scalar
	// IsZero returns true if this element is the additive identity element
	IsZero() bool
	// IsOne returns true if this element is the multiplicative identity element
	IsOne() bool
	// IsOdd returns true if this element is odd
	IsOdd() bool
	// IsEven returns true if this element is even
	IsEven() bool
	// New returns an element with the value equal to `value`
	New(value int) Scalar
	// Cmp returns
	// -2 if this element is in a different field than rhs
	// -1 if this element is less than rhs
	// 0 if this element is equal to rhs
	// 1 if this element is greater than rhs
	Cmp(rhs Scalar) int
	// Square returns element*element
	Square() Scalar
	// Double returns element+element
	Double() Scalar
	// Invert returns element^-1 mod p
	Invert() (Scalar, error)
	// Sqrt computes the square root of this element if it exists.
	Sqrt() (Scalar, error)
	// Cube returns element*element*element
	Cube() Scalar
	// Pow returns the scalar exponentiated to the power of i
	Pow(exp uint64) Scalar
	// Add returns element+rhs
	Add(rhs Scalar) Scalar
	// Sub returns element-rhs
	Sub(rhs Scalar) Scalar
	// Mul returns element*rhs
	Mul(rhs Scalar) Scalar
	// MulAdd returns element * y + z mod p
	MulAdd(y, z Scalar) Scalar
	// Div returns element*rhs^-1 mod p
	Div(rhs Scalar) Scalar
	// Neg returns -element mod p
	Neg() Scalar
	// SetBigInt returns this element set to the value of v
	SetBigInt(v *big.Int) (Scalar, error)
	// BigInt returns this element as a big integer
	BigInt() *big.Int
	// Point returns the associated point for this scalar
	Point() Point
	// Bytes returns the canonical byte representation of this scalar
	Bytes() []byte
	// SetBytes creates a scalar from the canonical representation expecting the exact number of bytes needed to represent the scalar
	SetBytes(bytes []byte) (Scalar, error)
	// SetBytesWide creates a scalar expecting double the exact number of bytes needed to represent the scalar which is reduced by the modulus
	SetBytesWide(bytes []byte) (Scalar, error)
	// Clone returns a cloned Scalar of this value
	Clone() Scalar
}

Scalar represents an element of the scalar field \mathbb{F}_q of the elliptic curve construction.

func ScalarUnmarshalBinary

func ScalarUnmarshalBinary(input []byte) (Scalar, error)

func ScalarUnmarshalJSON

func ScalarUnmarshalJSON(input []byte) (Scalar, error)

func ScalarUnmarshalText

func ScalarUnmarshalText(input []byte) (Scalar, error)

type ScalarBls12381

type ScalarBls12381 struct {
	Value *native.Field4
	// contains filtered or unexported fields
}

func (*ScalarBls12381) Add

func (s *ScalarBls12381) Add(rhs Scalar) Scalar

func (*ScalarBls12381) BigInt

func (s *ScalarBls12381) BigInt() *big.Int

func (*ScalarBls12381) Bytes

func (s *ScalarBls12381) Bytes() []byte

func (*ScalarBls12381) Clone

func (s *ScalarBls12381) Clone() Scalar

func (*ScalarBls12381) Cmp

func (s *ScalarBls12381) Cmp(rhs Scalar) int

func (*ScalarBls12381) Cube

func (s *ScalarBls12381) Cube() Scalar

func (*ScalarBls12381) Div

func (s *ScalarBls12381) Div(rhs Scalar) Scalar

func (*ScalarBls12381) Double

func (s *ScalarBls12381) Double() Scalar

func (*ScalarBls12381) Hash

func (s *ScalarBls12381) Hash(bytes []byte) Scalar

func (*ScalarBls12381) Invert

func (s *ScalarBls12381) Invert() (Scalar, error)

func (*ScalarBls12381) IsEven

func (s *ScalarBls12381) IsEven() bool

func (*ScalarBls12381) IsOdd

func (s *ScalarBls12381) IsOdd() bool

func (*ScalarBls12381) IsOne

func (s *ScalarBls12381) IsOne() bool

func (*ScalarBls12381) IsZero

func (s *ScalarBls12381) IsZero() bool

func (*ScalarBls12381) MarshalBinary

func (s *ScalarBls12381) MarshalBinary() ([]byte, error)

func (*ScalarBls12381) MarshalJSON

func (s *ScalarBls12381) MarshalJSON() ([]byte, error)

func (*ScalarBls12381) MarshalText

func (s *ScalarBls12381) MarshalText() ([]byte, error)

func (*ScalarBls12381) Mul

func (s *ScalarBls12381) Mul(rhs Scalar) Scalar

func (*ScalarBls12381) MulAdd

func (s *ScalarBls12381) MulAdd(y, z Scalar) Scalar

func (*ScalarBls12381) Neg

func (s *ScalarBls12381) Neg() Scalar

func (*ScalarBls12381) New

func (s *ScalarBls12381) New(value int) Scalar

func (*ScalarBls12381) One

func (s *ScalarBls12381) One() Scalar

func (*ScalarBls12381) Order

func (s *ScalarBls12381) Order() *big.Int

func (*ScalarBls12381) Point

func (s *ScalarBls12381) Point() Point

func (*ScalarBls12381) Pow

func (s *ScalarBls12381) Pow(exp uint64) Scalar

func (*ScalarBls12381) Random

func (s *ScalarBls12381) Random(reader io.Reader) Scalar

func (*ScalarBls12381) SetBigInt

func (s *ScalarBls12381) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarBls12381) SetBytes

func (s *ScalarBls12381) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarBls12381) SetBytesWide

func (s *ScalarBls12381) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarBls12381) SetPoint

func (s *ScalarBls12381) SetPoint(p Point) PairingScalar

func (*ScalarBls12381) Sqrt

func (s *ScalarBls12381) Sqrt() (Scalar, error)

func (*ScalarBls12381) Square

func (s *ScalarBls12381) Square() Scalar

func (*ScalarBls12381) Sub

func (s *ScalarBls12381) Sub(rhs Scalar) Scalar

func (*ScalarBls12381) UnmarshalBinary

func (s *ScalarBls12381) UnmarshalBinary(input []byte) error

func (*ScalarBls12381) UnmarshalJSON

func (s *ScalarBls12381) UnmarshalJSON(input []byte) error

func (*ScalarBls12381) UnmarshalText

func (s *ScalarBls12381) UnmarshalText(input []byte) error

func (*ScalarBls12381) Zero

func (s *ScalarBls12381) Zero() Scalar

type ScalarBls12381Gt

type ScalarBls12381Gt struct {
	Value *bls12381.Gt
}

func (*ScalarBls12381Gt) Add

func (s *ScalarBls12381Gt) Add(rhs Scalar) Scalar

func (*ScalarBls12381Gt) BigInt

func (s *ScalarBls12381Gt) BigInt() *big.Int

func (*ScalarBls12381Gt) Bytes

func (s *ScalarBls12381Gt) Bytes() []byte

func (*ScalarBls12381Gt) Clone

func (s *ScalarBls12381Gt) Clone() Scalar

func (*ScalarBls12381Gt) Cmp

func (s *ScalarBls12381Gt) Cmp(rhs Scalar) int

func (*ScalarBls12381Gt) Cube

func (s *ScalarBls12381Gt) Cube() Scalar

func (*ScalarBls12381Gt) Div

func (s *ScalarBls12381Gt) Div(rhs Scalar) Scalar

func (*ScalarBls12381Gt) Double

func (s *ScalarBls12381Gt) Double() Scalar

func (*ScalarBls12381Gt) Hash

func (s *ScalarBls12381Gt) Hash(bytes []byte) Scalar

func (*ScalarBls12381Gt) Invert

func (s *ScalarBls12381Gt) Invert() (Scalar, error)

func (*ScalarBls12381Gt) IsEven

func (s *ScalarBls12381Gt) IsEven() bool

func (*ScalarBls12381Gt) IsOdd

func (s *ScalarBls12381Gt) IsOdd() bool

func (*ScalarBls12381Gt) IsOne

func (s *ScalarBls12381Gt) IsOne() bool

func (*ScalarBls12381Gt) IsZero

func (s *ScalarBls12381Gt) IsZero() bool

func (*ScalarBls12381Gt) MarshalBinary

func (s *ScalarBls12381Gt) MarshalBinary() ([]byte, error)

func (*ScalarBls12381Gt) MarshalJSON

func (s *ScalarBls12381Gt) MarshalJSON() ([]byte, error)

func (*ScalarBls12381Gt) MarshalText

func (s *ScalarBls12381Gt) MarshalText() ([]byte, error)

func (*ScalarBls12381Gt) Mul

func (s *ScalarBls12381Gt) Mul(rhs Scalar) Scalar

func (*ScalarBls12381Gt) MulAdd

func (s *ScalarBls12381Gt) MulAdd(y, z Scalar) Scalar

func (*ScalarBls12381Gt) Neg

func (s *ScalarBls12381Gt) Neg() Scalar

func (*ScalarBls12381Gt) New

func (*ScalarBls12381Gt) New(input int) Scalar

func (*ScalarBls12381Gt) One

func (*ScalarBls12381Gt) One() Scalar

func (*ScalarBls12381Gt) Point

func (*ScalarBls12381Gt) Point() Point

func (*ScalarBls12381Gt) Pow

func (s *ScalarBls12381Gt) Pow(exp uint64) Scalar

func (*ScalarBls12381Gt) Random

func (s *ScalarBls12381Gt) Random(reader io.Reader) Scalar

func (*ScalarBls12381Gt) SetBigInt

func (s *ScalarBls12381Gt) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarBls12381Gt) SetBytes

func (*ScalarBls12381Gt) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarBls12381Gt) SetBytesWide

func (*ScalarBls12381Gt) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarBls12381Gt) Sqrt

func (*ScalarBls12381Gt) Sqrt() (Scalar, error)

func (*ScalarBls12381Gt) Square

func (s *ScalarBls12381Gt) Square() Scalar

func (*ScalarBls12381Gt) Sub

func (s *ScalarBls12381Gt) Sub(rhs Scalar) Scalar

func (*ScalarBls12381Gt) UnmarshalBinary

func (s *ScalarBls12381Gt) UnmarshalBinary(input []byte) error

func (*ScalarBls12381Gt) UnmarshalJSON

func (s *ScalarBls12381Gt) UnmarshalJSON(input []byte) error

func (*ScalarBls12381Gt) UnmarshalText

func (s *ScalarBls12381Gt) UnmarshalText(input []byte) error

func (*ScalarBls12381Gt) Zero

func (*ScalarBls12381Gt) Zero() Scalar

type ScalarEd25519

type ScalarEd25519 struct {
	// contains filtered or unexported fields
}

func (*ScalarEd25519) Add

func (s *ScalarEd25519) Add(rhs Scalar) Scalar

func (*ScalarEd25519) BigInt

func (s *ScalarEd25519) BigInt() *big.Int

func (*ScalarEd25519) Bytes

func (s *ScalarEd25519) Bytes() []byte

func (*ScalarEd25519) Clone

func (s *ScalarEd25519) Clone() Scalar

func (*ScalarEd25519) Cmp

func (s *ScalarEd25519) Cmp(rhs Scalar) int

func (*ScalarEd25519) Cube

func (s *ScalarEd25519) Cube() Scalar

func (*ScalarEd25519) Div

func (s *ScalarEd25519) Div(rhs Scalar) Scalar

func (*ScalarEd25519) Double

func (s *ScalarEd25519) Double() Scalar

func (*ScalarEd25519) GetEdwardsScalar

func (s *ScalarEd25519) GetEdwardsScalar() *edwards25519.Scalar

func (*ScalarEd25519) Hash

func (*ScalarEd25519) Hash(b []byte) Scalar

func (*ScalarEd25519) Invert

func (s *ScalarEd25519) Invert() (Scalar, error)

func (*ScalarEd25519) IsEven

func (s *ScalarEd25519) IsEven() bool

func (*ScalarEd25519) IsOdd

func (s *ScalarEd25519) IsOdd() bool

func (*ScalarEd25519) IsOne

func (s *ScalarEd25519) IsOne() bool

func (*ScalarEd25519) IsZero

func (s *ScalarEd25519) IsZero() bool

func (*ScalarEd25519) MarshalBinary

func (s *ScalarEd25519) MarshalBinary() ([]byte, error)

func (*ScalarEd25519) MarshalJSON

func (s *ScalarEd25519) MarshalJSON() ([]byte, error)

func (*ScalarEd25519) MarshalText

func (s *ScalarEd25519) MarshalText() ([]byte, error)

func (*ScalarEd25519) Mul

func (s *ScalarEd25519) Mul(rhs Scalar) Scalar

func (*ScalarEd25519) MulAdd

func (s *ScalarEd25519) MulAdd(y, z Scalar) Scalar

func (*ScalarEd25519) Neg

func (s *ScalarEd25519) Neg() Scalar

func (*ScalarEd25519) New

func (*ScalarEd25519) New(input int) Scalar

func (*ScalarEd25519) One

func (*ScalarEd25519) One() Scalar

func (*ScalarEd25519) Point

func (*ScalarEd25519) Point() Point

func (*ScalarEd25519) Pow

func (s *ScalarEd25519) Pow(exp uint64) Scalar

func (*ScalarEd25519) Random

func (s *ScalarEd25519) Random(reader io.Reader) Scalar

func (*ScalarEd25519) SetBigInt

func (*ScalarEd25519) SetBigInt(x *big.Int) (Scalar, error)

func (*ScalarEd25519) SetBytes

func (*ScalarEd25519) SetBytes(input []byte) (Scalar, error)

SetBytes takes input a 32-byte long array and returns a ed25519 scalar. The input must be 32-byte long and must be a reduced bytes.

func (*ScalarEd25519) SetBytesCanonical

func (s *ScalarEd25519) SetBytesCanonical(b []byte) (Scalar, error)

SetBytesCanonical uses SetCanonicalBytes of fillipo.io/edwards25519. https://github.com/FiloSottile/edwards25519/blob/v1.0.0-rc.1/scalar.go#L98 This function takes an input x and sets s = x, where x is a 32-byte little-endian encoding of s, then it returns the corresponding ed25519 scalar. If the input is not a canonical encoding of s, it returns nil and an error.

func (*ScalarEd25519) SetBytesClamping

func (*ScalarEd25519) SetBytesClamping(b []byte) (Scalar, error)

SetBytesClamping uses SetBytesWithClamping of fillipo.io/edwards25519- https://github.com/FiloSottile/edwards25519/blob/v1.0.0-rc.1/scalar.go#L135 which applies the buffer pruning described in RFC 8032, Section 5.1.5 (also known as clamping) and sets bytes to the result. The input must be 32-byte long, and it is not modified. If bytes is not of the right length, SetBytesWithClamping returns nil and an error, and the receiver is unchanged.

func (*ScalarEd25519) SetBytesWide

func (*ScalarEd25519) SetBytesWide(b []byte) (Scalar, error)

SetBytesWide takes input a 64-byte long byte array, reduce it and return an ed25519 scalar. It uses SetUniformBytes of fillipo.io/edwards25519 - https://github.com/FiloSottile/edwards25519/blob/v1.0.0-rc.1/scalar.go#L85 If bytes is not of the right length, it returns nil and an error.

func (*ScalarEd25519) SetEdwardsScalar

func (*ScalarEd25519) SetEdwardsScalar(sc *edwards25519.Scalar) *ScalarEd25519

func (*ScalarEd25519) Sqrt

func (s *ScalarEd25519) Sqrt() (Scalar, error)

func (*ScalarEd25519) Square

func (s *ScalarEd25519) Square() Scalar

func (*ScalarEd25519) Sub

func (s *ScalarEd25519) Sub(rhs Scalar) Scalar

func (*ScalarEd25519) UnmarshalBinary

func (s *ScalarEd25519) UnmarshalBinary(input []byte) error

func (*ScalarEd25519) UnmarshalJSON

func (s *ScalarEd25519) UnmarshalJSON(input []byte) error

func (*ScalarEd25519) UnmarshalText

func (s *ScalarEd25519) UnmarshalText(input []byte) error

func (*ScalarEd25519) Zero

func (*ScalarEd25519) Zero() Scalar

type ScalarK256

type ScalarK256 struct {
	// contains filtered or unexported fields
}

func (*ScalarK256) Add

func (s *ScalarK256) Add(rhs Scalar) Scalar

func (*ScalarK256) BigInt

func (s *ScalarK256) BigInt() *big.Int

func (*ScalarK256) Bytes

func (s *ScalarK256) Bytes() []byte

func (*ScalarK256) Clone

func (s *ScalarK256) Clone() Scalar

func (*ScalarK256) Cmp

func (s *ScalarK256) Cmp(rhs Scalar) int

func (*ScalarK256) Cube

func (s *ScalarK256) Cube() Scalar

func (*ScalarK256) Div

func (s *ScalarK256) Div(rhs Scalar) Scalar

func (*ScalarK256) Double

func (s *ScalarK256) Double() Scalar

func (*ScalarK256) Hash

func (*ScalarK256) Hash(bytes []byte) Scalar

func (*ScalarK256) Invert

func (s *ScalarK256) Invert() (Scalar, error)

func (*ScalarK256) IsEven

func (s *ScalarK256) IsEven() bool

func (*ScalarK256) IsOdd

func (s *ScalarK256) IsOdd() bool

func (*ScalarK256) IsOne

func (s *ScalarK256) IsOne() bool

func (*ScalarK256) IsZero

func (s *ScalarK256) IsZero() bool

func (*ScalarK256) MarshalBinary

func (s *ScalarK256) MarshalBinary() ([]byte, error)

func (*ScalarK256) MarshalJSON

func (s *ScalarK256) MarshalJSON() ([]byte, error)

func (*ScalarK256) MarshalText

func (s *ScalarK256) MarshalText() ([]byte, error)

func (*ScalarK256) Mul

func (s *ScalarK256) Mul(rhs Scalar) Scalar

func (*ScalarK256) MulAdd

func (s *ScalarK256) MulAdd(y, z Scalar) Scalar

func (*ScalarK256) Neg

func (s *ScalarK256) Neg() Scalar

func (*ScalarK256) New

func (*ScalarK256) New(value int) Scalar

func (*ScalarK256) One

func (*ScalarK256) One() Scalar

func (*ScalarK256) Point

func (*ScalarK256) Point() Point

func (*ScalarK256) Pow

func (s *ScalarK256) Pow(exp uint64) Scalar

func (*ScalarK256) Random

func (s *ScalarK256) Random(reader io.Reader) Scalar

func (*ScalarK256) SetBigInt

func (*ScalarK256) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarK256) SetBytes

func (*ScalarK256) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarK256) SetBytesWide

func (*ScalarK256) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarK256) Sqrt

func (s *ScalarK256) Sqrt() (Scalar, error)

func (*ScalarK256) Square

func (s *ScalarK256) Square() Scalar

func (*ScalarK256) Sub

func (s *ScalarK256) Sub(rhs Scalar) Scalar

func (*ScalarK256) UnmarshalBinary

func (s *ScalarK256) UnmarshalBinary(input []byte) error

func (*ScalarK256) UnmarshalJSON

func (s *ScalarK256) UnmarshalJSON(input []byte) error

func (*ScalarK256) UnmarshalText

func (s *ScalarK256) UnmarshalText(input []byte) error

func (*ScalarK256) Zero

func (*ScalarK256) Zero() Scalar

type ScalarP256

type ScalarP256 struct {
	// contains filtered or unexported fields
}

func (*ScalarP256) Add

func (s *ScalarP256) Add(rhs Scalar) Scalar

func (*ScalarP256) BigInt

func (s *ScalarP256) BigInt() *big.Int

func (*ScalarP256) Bytes

func (s *ScalarP256) Bytes() []byte

func (*ScalarP256) Clone

func (s *ScalarP256) Clone() Scalar

func (*ScalarP256) Cmp

func (s *ScalarP256) Cmp(rhs Scalar) int

func (*ScalarP256) Cube

func (s *ScalarP256) Cube() Scalar

func (*ScalarP256) Div

func (s *ScalarP256) Div(rhs Scalar) Scalar

func (*ScalarP256) Double

func (s *ScalarP256) Double() Scalar

func (*ScalarP256) Hash

func (*ScalarP256) Hash(bytes []byte) Scalar

func (*ScalarP256) Invert

func (s *ScalarP256) Invert() (Scalar, error)

func (*ScalarP256) IsEven

func (s *ScalarP256) IsEven() bool

func (*ScalarP256) IsOdd

func (s *ScalarP256) IsOdd() bool

func (*ScalarP256) IsOne

func (s *ScalarP256) IsOne() bool

func (*ScalarP256) IsZero

func (s *ScalarP256) IsZero() bool

func (*ScalarP256) MarshalBinary

func (s *ScalarP256) MarshalBinary() ([]byte, error)

func (*ScalarP256) MarshalJSON

func (s *ScalarP256) MarshalJSON() ([]byte, error)

func (*ScalarP256) MarshalText

func (s *ScalarP256) MarshalText() ([]byte, error)

func (*ScalarP256) Mul

func (s *ScalarP256) Mul(rhs Scalar) Scalar

func (*ScalarP256) MulAdd

func (s *ScalarP256) MulAdd(y, z Scalar) Scalar

func (*ScalarP256) Neg

func (s *ScalarP256) Neg() Scalar

func (*ScalarP256) New

func (*ScalarP256) New(value int) Scalar

func (*ScalarP256) One

func (*ScalarP256) One() Scalar

func (*ScalarP256) Point

func (*ScalarP256) Point() Point

func (*ScalarP256) Pow

func (s *ScalarP256) Pow(exp uint64) Scalar

func (*ScalarP256) Random

func (s *ScalarP256) Random(reader io.Reader) Scalar

func (*ScalarP256) SetBigInt

func (*ScalarP256) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarP256) SetBytes

func (*ScalarP256) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarP256) SetBytesWide

func (*ScalarP256) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarP256) Sqrt

func (s *ScalarP256) Sqrt() (Scalar, error)

func (*ScalarP256) Square

func (s *ScalarP256) Square() Scalar

func (*ScalarP256) Sub

func (s *ScalarP256) Sub(rhs Scalar) Scalar

func (*ScalarP256) UnmarshalBinary

func (s *ScalarP256) UnmarshalBinary(input []byte) error

func (*ScalarP256) UnmarshalJSON

func (s *ScalarP256) UnmarshalJSON(input []byte) error

func (*ScalarP256) UnmarshalText

func (s *ScalarP256) UnmarshalText(input []byte) error

func (*ScalarP256) Zero

func (*ScalarP256) Zero() Scalar

type ScalarP384 added in v1.1.0

type ScalarP384 struct {
	// contains filtered or unexported fields
}

func (*ScalarP384) Add added in v1.1.0

func (s *ScalarP384) Add(rhs Scalar) Scalar

func (*ScalarP384) BigInt added in v1.1.0

func (s *ScalarP384) BigInt() *big.Int

func (*ScalarP384) Bytes added in v1.1.0

func (s *ScalarP384) Bytes() []byte

func (*ScalarP384) Clone added in v1.1.0

func (s *ScalarP384) Clone() Scalar

func (*ScalarP384) Cmp added in v1.1.0

func (s *ScalarP384) Cmp(rhs Scalar) int

func (*ScalarP384) Cube added in v1.1.0

func (s *ScalarP384) Cube() Scalar

func (*ScalarP384) Div added in v1.1.0

func (s *ScalarP384) Div(rhs Scalar) Scalar

func (*ScalarP384) Double added in v1.1.0

func (s *ScalarP384) Double() Scalar

func (*ScalarP384) Hash added in v1.1.0

func (*ScalarP384) Hash(bytes []byte) Scalar

func (*ScalarP384) Invert added in v1.1.0

func (s *ScalarP384) Invert() (Scalar, error)

func (*ScalarP384) IsEven added in v1.1.0

func (s *ScalarP384) IsEven() bool

func (*ScalarP384) IsOdd added in v1.1.0

func (s *ScalarP384) IsOdd() bool

func (*ScalarP384) IsOne added in v1.1.0

func (s *ScalarP384) IsOne() bool

func (*ScalarP384) IsZero added in v1.1.0

func (s *ScalarP384) IsZero() bool

func (*ScalarP384) MarshalBinary added in v1.1.0

func (s *ScalarP384) MarshalBinary() ([]byte, error)

func (*ScalarP384) MarshalJSON added in v1.1.0

func (s *ScalarP384) MarshalJSON() ([]byte, error)

func (*ScalarP384) MarshalText added in v1.1.0

func (s *ScalarP384) MarshalText() ([]byte, error)

func (*ScalarP384) Mul added in v1.1.0

func (s *ScalarP384) Mul(rhs Scalar) Scalar

func (*ScalarP384) MulAdd added in v1.1.0

func (s *ScalarP384) MulAdd(y, z Scalar) Scalar

func (*ScalarP384) Neg added in v1.1.0

func (s *ScalarP384) Neg() Scalar

func (*ScalarP384) New added in v1.1.0

func (*ScalarP384) New(value int) Scalar

func (*ScalarP384) One added in v1.1.0

func (*ScalarP384) One() Scalar

func (*ScalarP384) Point added in v1.1.0

func (*ScalarP384) Point() Point

func (*ScalarP384) Pow added in v1.1.0

func (s *ScalarP384) Pow(exp uint64) Scalar

func (*ScalarP384) Random added in v1.1.0

func (s *ScalarP384) Random(reader io.Reader) Scalar

func (*ScalarP384) SetBigInt added in v1.1.0

func (*ScalarP384) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarP384) SetBytes added in v1.1.0

func (*ScalarP384) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarP384) SetBytesWide added in v1.1.0

func (*ScalarP384) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarP384) Sqrt added in v1.1.0

func (s *ScalarP384) Sqrt() (Scalar, error)

func (*ScalarP384) Square added in v1.1.0

func (s *ScalarP384) Square() Scalar

func (*ScalarP384) Sub added in v1.1.0

func (s *ScalarP384) Sub(rhs Scalar) Scalar

func (*ScalarP384) UnmarshalBinary added in v1.1.0

func (s *ScalarP384) UnmarshalBinary(input []byte) error

func (*ScalarP384) UnmarshalJSON added in v1.1.0

func (s *ScalarP384) UnmarshalJSON(input []byte) error

func (*ScalarP384) UnmarshalText added in v1.1.0

func (s *ScalarP384) UnmarshalText(input []byte) error

func (*ScalarP384) Zero added in v1.1.0

func (*ScalarP384) Zero() Scalar

type ScalarPallas

type ScalarPallas struct {
	Value *native.Field4
}

ScalarPallas - New interface.

func (*ScalarPallas) Add

func (s *ScalarPallas) Add(rhs Scalar) Scalar

func (*ScalarPallas) BigInt

func (s *ScalarPallas) BigInt() *big.Int

func (*ScalarPallas) Bytes

func (s *ScalarPallas) Bytes() []byte

func (*ScalarPallas) Clone

func (s *ScalarPallas) Clone() Scalar

func (*ScalarPallas) Cmp

func (s *ScalarPallas) Cmp(rhs Scalar) int

func (*ScalarPallas) Cube

func (s *ScalarPallas) Cube() Scalar

func (*ScalarPallas) Div

func (s *ScalarPallas) Div(rhs Scalar) Scalar

func (*ScalarPallas) Double

func (s *ScalarPallas) Double() Scalar

func (*ScalarPallas) Hash

func (*ScalarPallas) Hash(bytes []byte) Scalar

func (*ScalarPallas) Invert

func (s *ScalarPallas) Invert() (Scalar, error)

func (*ScalarPallas) IsEven

func (s *ScalarPallas) IsEven() bool

func (*ScalarPallas) IsOdd

func (s *ScalarPallas) IsOdd() bool

func (*ScalarPallas) IsOne

func (s *ScalarPallas) IsOne() bool

func (*ScalarPallas) IsZero

func (s *ScalarPallas) IsZero() bool

func (*ScalarPallas) MarshalBinary

func (s *ScalarPallas) MarshalBinary() ([]byte, error)

func (*ScalarPallas) MarshalJSON

func (s *ScalarPallas) MarshalJSON() ([]byte, error)

func (*ScalarPallas) MarshalText

func (s *ScalarPallas) MarshalText() ([]byte, error)

func (*ScalarPallas) Mul

func (s *ScalarPallas) Mul(rhs Scalar) Scalar

func (*ScalarPallas) MulAdd

func (s *ScalarPallas) MulAdd(y, z Scalar) Scalar

func (*ScalarPallas) Neg

func (s *ScalarPallas) Neg() Scalar

func (*ScalarPallas) New

func (*ScalarPallas) New(value int) Scalar

func (*ScalarPallas) One

func (*ScalarPallas) One() Scalar

func (*ScalarPallas) Point

func (*ScalarPallas) Point() Point

func (*ScalarPallas) Pow

func (s *ScalarPallas) Pow(exp uint64) Scalar

func (*ScalarPallas) Random

func (s *ScalarPallas) Random(reader io.Reader) Scalar

func (*ScalarPallas) SetBigInt

func (*ScalarPallas) SetBigInt(v *big.Int) (Scalar, error)

func (*ScalarPallas) SetBytes

func (*ScalarPallas) SetBytes(bytes []byte) (Scalar, error)

func (*ScalarPallas) SetBytesWide

func (*ScalarPallas) SetBytesWide(bytes []byte) (Scalar, error)

func (*ScalarPallas) Sqrt

func (s *ScalarPallas) Sqrt() (Scalar, error)

func (*ScalarPallas) Square

func (s *ScalarPallas) Square() Scalar

func (*ScalarPallas) Sub

func (s *ScalarPallas) Sub(rhs Scalar) Scalar

func (*ScalarPallas) UnmarshalBinary

func (s *ScalarPallas) UnmarshalBinary(input []byte) error

func (*ScalarPallas) UnmarshalJSON

func (s *ScalarPallas) UnmarshalJSON(input []byte) error

func (*ScalarPallas) UnmarshalText

func (s *ScalarPallas) UnmarshalText(input []byte) error

func (*ScalarPallas) Zero

func (*ScalarPallas) Zero() Scalar

Directories

Path Synopsis
k256/fp
Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --lang Go --no-wide-int --relax-primitive-carry-to-bitwidth 32,64 --cmovznz-by-mul --internal-static --package-case flatcase --public-function-case UpperCamelCase --private-function-case camelCase --public-type-case UpperCamelCase --private-type-case camelCase --no-prefix-fiat --doc-newline-in-typedef-bounds --doc-prepend-header 'Code generated by Fiat Cryptography.
Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --lang Go --no-wide-int --relax-primitive-carry-to-bitwidth 32,64 --cmovznz-by-mul --internal-static --package-case flatcase --public-function-case UpperCamelCase --private-function-case camelCase --public-type-case UpperCamelCase --private-type-case camelCase --no-prefix-fiat --doc-newline-in-typedef-bounds --doc-prepend-header 'Code generated by Fiat Cryptography.
k256/fq
Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --lang Go --no-wide-int --relax-primitive-carry-to-bitwidth 32,64 --cmovznz-by-mul --internal-static --package-case flatcase --public-function-case UpperCamelCase --private-function-case camelCase --public-type-case UpperCamelCase --private-type-case camelCase --no-prefix-fiat --doc-newline-in-typedef-bounds --doc-prepend-header 'Code generated by Fiat Cryptography.
Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --lang Go --no-wide-int --relax-primitive-carry-to-bitwidth 32,64 --cmovznz-by-mul --internal-static --package-case flatcase --public-function-case UpperCamelCase --private-function-case camelCase --public-type-case UpperCamelCase --private-type-case camelCase --no-prefix-fiat --doc-newline-in-typedef-bounds --doc-prepend-header 'Code generated by Fiat Cryptography.
p256/fp
Code generated by Fiat Cryptography.
Code generated by Fiat Cryptography.
p256/fq
Code generated by Fiat Cryptography.
Code generated by Fiat Cryptography.
p384/fp
Code generated by Fiat Cryptography.
Code generated by Fiat Cryptography.
p384/fq
Code generated by Fiat Cryptography.
Code generated by Fiat Cryptography.

Jump to

Keyboard shortcuts

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