math

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 64

README

mathlib

License Go Report Card Go

Library to perform operations over elements of pairing-friendly elliptic curve groups

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Curves []*Curve = []*Curve{
	{

		GenG1:      &G1{g1: (&amcl.Fp256bn{}).GenG1(), curveID: FP256BN_AMCL},
		GenG2:      &G2{g2: (&amcl.Fp256bn{}).GenG2(), curveID: FP256BN_AMCL},
		GenGt:      &Gt{gt: (&amcl.Fp256bn{}).GenGt(), curveID: FP256BN_AMCL},
		GroupOrder: &Zr{zr: (&amcl.Fp256bn{}).GroupOrder(), curveID: FP256BN_AMCL},
		FieldBytes: (&amcl.Fp256bn{}).FieldBytes(),
		// contains filtered or unexported fields
	},
	{

		GenG1:      &G1{g1: (&gurvy.Bn254{}).GenG1(), curveID: BN254},
		GenG2:      &G2{g2: (&gurvy.Bn254{}).GenG2(), curveID: BN254},
		GenGt:      &Gt{gt: (&gurvy.Bn254{}).GenGt(), curveID: BN254},
		GroupOrder: &Zr{zr: (&gurvy.Bn254{}).GroupOrder(), curveID: BN254},
		FieldBytes: (&gurvy.Bn254{}).FieldBytes(),
		// contains filtered or unexported fields
	},
	{

		GenG1:      &G1{g1: (&amcl.Fp256Miraclbn{}).GenG1(), curveID: FP256BN_AMCL_MIRACL},
		GenG2:      &G2{g2: (&amcl.Fp256Miraclbn{}).GenG2(), curveID: FP256BN_AMCL_MIRACL},
		GenGt:      &Gt{gt: (&amcl.Fp256Miraclbn{}).GenGt(), curveID: FP256BN_AMCL_MIRACL},
		GroupOrder: &Zr{zr: (&amcl.Fp256Miraclbn{}).GroupOrder(), curveID: FP256BN_AMCL_MIRACL},
		FieldBytes: (&amcl.Fp256Miraclbn{}).FieldBytes(),
		// contains filtered or unexported fields
	},
}

Functions

This section is empty.

Types

type Curve

type Curve struct {
	GenG1      *G1
	GenG2      *G2
	GenGt      *Gt
	GroupOrder *Zr
	FieldBytes int
	// contains filtered or unexported fields
}

func (*Curve) FExp

func (c *Curve) FExp(a *Gt) *Gt

func (*Curve) HashToG1

func (c *Curve) HashToG1(data []byte) *G1

func (*Curve) HashToZr

func (c *Curve) HashToZr(data []byte) *Zr

func (*Curve) ModAdd

func (c *Curve) ModAdd(a, b, m *Zr) *Zr

func (*Curve) ModMul

func (c *Curve) ModMul(a1, b1, m *Zr) *Zr

func (*Curve) ModNeg

func (c *Curve) ModNeg(a1, m *Zr) *Zr

func (*Curve) ModSub

func (c *Curve) ModSub(a, b, m *Zr) *Zr

func (*Curve) NewG1

func (c *Curve) NewG1() *G1

func (*Curve) NewG1FromBytes

func (c *Curve) NewG1FromBytes(b []byte) (p *G1, err error)

func (*Curve) NewG2

func (c *Curve) NewG2() *G2

func (*Curve) NewG2FromBytes

func (c *Curve) NewG2FromBytes(b []byte) (p *G2, err error)

func (*Curve) NewGtFromBytes

func (c *Curve) NewGtFromBytes(b []byte) (p *Gt, err error)

func (*Curve) NewRandomZr

func (c *Curve) NewRandomZr(rng io.Reader) *Zr

func (*Curve) NewZrFromBytes

func (c *Curve) NewZrFromBytes(b []byte) *Zr

func (*Curve) NewZrFromInt

func (c *Curve) NewZrFromInt(i int64) *Zr

func (*Curve) Pairing

func (c *Curve) Pairing(a *G2, b *G1) *Gt

func (*Curve) Pairing2

func (c *Curve) Pairing2(p *G2, q *G1, r *G2, s *G1) *Gt

func (*Curve) Rand

func (c *Curve) Rand() (io.Reader, error)

type CurveID

type CurveID int
const (
	FP256BN_AMCL CurveID = iota
	BN254
	FP256BN_AMCL_MIRACL
)

type G1

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

func (*G1) Add

func (g *G1) Add(a *G1)

func (*G1) Bytes

func (g *G1) Bytes() []byte

func (*G1) Clone

func (g *G1) Clone(a *G1)

func (*G1) Copy

func (g *G1) Copy() *G1

func (*G1) Equals

func (g *G1) Equals(a *G1) bool

func (*G1) IsInfinity

func (g *G1) IsInfinity() bool

func (*G1) MarshalJSON

func (g *G1) MarshalJSON() ([]byte, error)

func (*G1) Mul

func (g *G1) Mul(a *Zr) *G1

func (*G1) Mul2

func (g *G1) Mul2(e *Zr, Q *G1, f *Zr) *G1

func (*G1) String

func (g *G1) String() string

func (*G1) Sub

func (g *G1) Sub(a *G1)

func (*G1) UnmarshalJSON

func (g *G1) UnmarshalJSON(raw []byte) error

type G2

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

func (*G2) Add

func (g *G2) Add(a *G2)

func (*G2) Affine

func (g *G2) Affine()

func (*G2) Bytes

func (g *G2) Bytes() []byte

func (*G2) Clone

func (g *G2) Clone(a *G2)

func (*G2) Copy

func (g *G2) Copy() *G2

func (*G2) Equals

func (g *G2) Equals(a *G2) bool

func (*G2) MarshalJSON

func (g *G2) MarshalJSON() ([]byte, error)

func (*G2) Mul

func (g *G2) Mul(a *Zr) *G2

func (*G2) String

func (g *G2) String() string

func (*G2) Sub

func (g *G2) Sub(a *G2)

func (*G2) UnmarshalJSON

func (g *G2) UnmarshalJSON(raw []byte) error

type Gt

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

func (*Gt) Bytes

func (g *Gt) Bytes() []byte

func (*Gt) Equals

func (g *Gt) Equals(a *Gt) bool

func (*Gt) Exp

func (g *Gt) Exp(z *Zr) *Gt

func (*Gt) Inverse

func (g *Gt) Inverse()

func (*Gt) IsUnity

func (g *Gt) IsUnity() bool

func (*Gt) MarshalJSON

func (g *Gt) MarshalJSON() ([]byte, error)

func (*Gt) Mul

func (g *Gt) Mul(a *Gt)

func (*Gt) String

func (g *Gt) String() string

func (*Gt) UnmarshalJSON

func (g *Gt) UnmarshalJSON(raw []byte) error

type Zr

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

func (*Zr) Bytes

func (z *Zr) Bytes() []byte

func (*Zr) Clone

func (z *Zr) Clone(a *Zr)

func (*Zr) Copy

func (z *Zr) Copy() *Zr

func (*Zr) Equals

func (z *Zr) Equals(a *Zr) bool

func (*Zr) Int

func (z *Zr) Int() (int64, error)

func (*Zr) InvModP

func (z *Zr) InvModP(a *Zr)

func (*Zr) MarshalJSON

func (z *Zr) MarshalJSON() ([]byte, error)

func (*Zr) Mod

func (z *Zr) Mod(a *Zr)

func (*Zr) Mul

func (z *Zr) Mul(a *Zr) *Zr

func (*Zr) Plus

func (z *Zr) Plus(a *Zr) *Zr

func (*Zr) PowMod

func (z *Zr) PowMod(a *Zr) *Zr

func (*Zr) String

func (z *Zr) String() string

func (*Zr) UnmarshalJSON

func (z *Zr) UnmarshalJSON(raw []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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