twistededwards

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 5 Imported by: 33

Documentation

Overview

Package twistededwards provides bn254's twisted edwards "companion curve" defined on fr.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurveParams

type CurveParams struct {
	A, D     fr.Element // in Montgomery form
	Cofactor fr.Element // not in Montgomery form
	Order    big.Int
	Base     PointAffine
}

CurveParams curve parameters: ax^2 + y^2 = 1 + d*x^2*y^2

func GetEdwardsCurve

func GetEdwardsCurve() CurveParams

GetEdwardsCurve returns the twisted Edwards curve on BN254's Fr

type PointAffine

type PointAffine struct {
	X, Y fr.Element
}

PointAffine point on a twisted Edwards curve

func NewPointAffine

func NewPointAffine(x, y fr.Element) PointAffine

NewPointAffine creates a new instance of PointAffine

func (*PointAffine) Add

func (p *PointAffine) Add(p1, p2 *PointAffine) *PointAffine

Add adds two points (x,y), (u,v) on a twisted Edwards curve with parameters a, d modifies p

func (*PointAffine) Bytes

func (p *PointAffine) Bytes() [sizePointCompressed]byte

Bytes returns the compressed point as a byte array Follows https://tools.ietf.org/html/rfc8032#section-3.1, as the twisted Edwards implementation is primarily used for eddsa.

func (*PointAffine) Double

func (p *PointAffine) Double(p1 *PointAffine) *PointAffine

Double doubles point (x,y) on a twisted Edwards curve with parameters a, d modifies p

func (*PointAffine) Equal

func (p *PointAffine) Equal(p1 *PointAffine) bool

Equal returns true if p=p1 false otherwise

func (*PointAffine) FromProj

func (p *PointAffine) FromProj(p1 *PointProj) *PointAffine

FromProj sets p in affine from p in projective

func (*PointAffine) IsOnCurve

func (p *PointAffine) IsOnCurve() bool

IsOnCurve checks if a point is on the twisted Edwards curve

func (*PointAffine) Marshal

func (p *PointAffine) Marshal() []byte

Marshal converts p to a byte slice

func (*PointAffine) Neg

func (p *PointAffine) Neg(p1 *PointAffine) *PointAffine

Neg sets p to -p1 and returns it

func (*PointAffine) ScalarMul

func (p *PointAffine) ScalarMul(p1 *PointAffine, scalar *big.Int) *PointAffine

ScalarMul scalar multiplication of a point p1 points on the twisted Edwards curve c parameters of the twisted Edwards curve scal scalar NOT in Montgomery form modifies p func (p *PointAffine) ScalarMul(p1 *PointAffine, scalar fr.Element) *PointAffine {

func (*PointAffine) Set

func (p *PointAffine) Set(p1 *PointAffine) *PointAffine

Set sets p to p1 and return it

func (*PointAffine) SetBytes

func (p *PointAffine) SetBytes(buf []byte) (int, error)

SetBytes sets p from buf len(buf) >= sizePointCompressed buf contains the Y coordinate masked with a parity bit to recompute the X coordinate from the curve equation. See Bytes() and https://tools.ietf.org/html/rfc8032#section-3.1 Returns the number of read bytes and an error if the buffer is too short.

func (*PointAffine) Unmarshal

func (p *PointAffine) Unmarshal(b []byte) error

Unmarshal alias to SetBytes()

type PointProj

type PointProj struct {
	X, Y, Z fr.Element
}

PointProj point in projective coordinates

func (*PointProj) Add

func (p *PointProj) Add(p1, p2 *PointProj) *PointProj

Add adds points in projective coordinates cf https://hyperelliptic.org/EFD/g1p/auto-twisted-projective.html

func (*PointProj) Double

func (p *PointProj) Double(p1 *PointProj) *PointProj

Double adds points in projective coordinates cf https://hyperelliptic.org/EFD/g1p/auto-twisted-projective.html

func (*PointProj) Equal

func (p *PointProj) Equal(p1 *PointProj) bool

Equal returns true if p=p1 false otherwise If one point is on the affine chart Z=0 it returns false

func (*PointProj) FromAffine

func (p *PointProj) FromAffine(p1 *PointAffine) *PointProj

FromAffine sets p in projective from p in affine

func (*PointProj) Neg

func (p *PointProj) Neg(p1 *PointProj) *PointProj

Neg negates point (x,y) on a twisted Edwards curve with parameters a, d modifies p

func (*PointProj) Set

func (p *PointProj) Set(p1 *PointProj) *PointProj

Set sets p to p1 and return it

Directories

Path Synopsis
Package eddsa provides EdDSA signature scheme on bn254's twisted edwards curve.
Package eddsa provides EdDSA signature scheme on bn254's twisted edwards curve.

Jump to

Keyboard shortcuts

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