curve

package
v0.0.0-...-32ff903 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Order = bn256.Order
)

Functions

func DeriveFieldElementFromPoint

func DeriveFieldElementFromPoint(point Point) *big.Int

DeriveFieldElementFromPoint derives a field element k by the following rules: (1) Calculate h = SHA256(point.Marshal()) (2) Calculate k = BigInt(h) % Order (3) If k == 0, calculate h = SHA256(h), then jump to (2)

func RandomFieldElement

func RandomFieldElement(r io.Reader) (*big.Int, error)

RandomFieldElement returns x where x is a random, non-zero number read from r.

Types

type Curve

type Curve uint32
const (
	// TypeG1 represents point type G1
	TypeG1 Curve = iota
	// TypeG2 represents point type G2
	TypeG2
	// TypeGT represents point type GT
	TypeGT
)

func (Curve) String

func (curve Curve) String() (s string)

type G1

type G1 bn256.G1

func (*G1) Add

func (e *G1) Add(a, b Point) Point

func (*G1) Curve

func (e *G1) Curve() Curve

func (*G1) Marshal

func (e *G1) Marshal() []byte

func (*G1) Neg

func (e *G1) Neg(a Point) Point

func (*G1) ScalarBaseMult

func (e *G1) ScalarBaseMult(k *big.Int) Point

func (*G1) ScalarMult

func (e *G1) ScalarMult(a Point, k *big.Int) Point

func (*G1) Set

func (e *G1) Set(a Point) Point

func (*G1) String

func (e *G1) String() string

func (*G1) Unmarshal

func (e *G1) Unmarshal(m []byte) ([]byte, error)

type G2

type G2 bn256.G2

func (*G2) Add

func (e *G2) Add(a, b Point) Point

func (*G2) Curve

func (e *G2) Curve() Curve

func (*G2) Marshal

func (e *G2) Marshal() []byte

func (*G2) Neg

func (e *G2) Neg(a Point) Point

func (*G2) ScalarBaseMult

func (e *G2) ScalarBaseMult(k *big.Int) Point

func (*G2) ScalarMult

func (e *G2) ScalarMult(a Point, k *big.Int) Point

func (*G2) Set

func (e *G2) Set(a Point) Point

func (*G2) String

func (e *G2) String() string

func (*G2) Unmarshal

func (e *G2) Unmarshal(m []byte) ([]byte, error)

type GT

type GT bn256.GT

func Pair

func Pair(g1 *G1, g2 *G2) *GT

func (*GT) Add

func (e *GT) Add(a, b Point) Point

func (*GT) Curve

func (e *GT) Curve() Curve

func (*GT) Marshal

func (e *GT) Marshal() []byte

func (*GT) Neg

func (e *GT) Neg(a Point) Point

func (*GT) ScalarBaseMult

func (e *GT) ScalarBaseMult(k *big.Int) Point

func (*GT) ScalarMult

func (e *GT) ScalarMult(a Point, k *big.Int) Point

func (*GT) Set

func (e *GT) Set(a Point) Point

func (*GT) String

func (e *GT) String() string

func (*GT) Unmarshal

func (e *GT) Unmarshal(m []byte) ([]byte, error)

type Point

type Point interface {
	Curve() Curve
	String() string
	Marshal() []byte
	Unmarshal(m []byte) ([]byte, error)
	ScalarBaseMult(k *big.Int) Point
	ScalarMult(a Point, k *big.Int) Point
	Add(a, b Point) Point
	Neg(a Point) Point
	Set(a Point) Point
}

func NewPoint

func NewPoint(curve Curve) (point Point)

func NewRandomPoint

func NewRandomPoint(curve Curve, r io.Reader) (n *big.Int, point Point, err error)

Jump to

Keyboard shortcuts

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