bls

package
v0.0.0-...-09d2262 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

forked from https://github.com/protolambda/go-kzg at Feb 2,2023

forked from https://github.com/protolambda/go-kzg at Feb 2,2023

forked from https://github.com/protolambda/go-kzg at Feb 2,2023

forked from https://github.com/protolambda/go-kzg at Feb 2,2023

forked from https://github.com/protolambda/go-kzg at Feb 2,2023

Index

Constants

View Source
const ModulusStr = "52435875175126190479447740508185965837690552500527637822603658699938581184513"

Variables

View Source
var Scale2RootOfUnity []Fr

Functions

func AddG1

func AddG1(dst *G1Point, a *G1Point, b *G1Point)

func AddG2

func AddG2(dst *G2Point, a *G2Point, b *G2Point)

func AddModFr

func AddModFr(dst *Fr, a, b *Fr)

func AsFr

func AsFr(dst *Fr, i uint64)

func BatchInvModFr

func BatchInvModFr(f []Fr)

func ClearG1

func ClearG1(x *G1Point)

zeroes the point (like herumi BLS does with theirs). This is not co-factor clearing.

func ClearG2

func ClearG2(x *G2Point)

zeroes the point (like herumi BLS does with theirs). This is not co-factor clearing.

func CopyFr

func CopyFr(dst *Fr, v *Fr)

func CopyG1

func CopyG1(dst *G1Point, v *G1Point)

func CopyG2

func CopyG2(dst *G2Point, v *G2Point)

func DebugG1s

func DebugG1s(msg string, values []G1Point)

func DivModFr

func DivModFr(dst *Fr, a, b *Fr)

func EqualFr

func EqualFr(a *Fr, b *Fr) bool

func EqualG1

func EqualG1(a *G1Point, b *G1Point) bool

func EqualG2

func EqualG2(a *G2Point, b *G2Point) bool

func EqualOne

func EqualOne(v *Fr) bool

func EqualZero

func EqualZero(v *Fr) bool

func EvalPolyAt

func EvalPolyAt(dst *Fr, p []Fr, x *Fr)

func EvalPolyAtUnoptimized

func EvalPolyAtUnoptimized(dst *Fr, coeffs []Fr, x *Fr)

func EvaluatePolyInEvaluationForm

func EvaluatePolyInEvaluationForm(yFr *Fr, poly []Fr, x *Fr, rootsOfUnity []Fr, scale uint8)

Evaluate a polynomial (in evaluation form) at an arbitrary point x using the barycentric formula:

f(x) = (x**WIDTH - 1) / WIDTH  *  sum_(i=0)^WIDTH  (f(DOMAIN[i]) * DOMAIN[i]) / (x - DOMAIN[i])

See https://dankradfeist.de/ethereum/2021/06/18/pcs-multiproofs.html "Evaluating a polynomial in evaluation form on a point outside the domain".

Scale is used to indicate the power of 2 to use to stride through the domain values. Note: scale == 0 when the roots of unity length matches the polynomial.

func ExpModFr

func ExpModFr(dst *Fr, v *Fr, e *big.Int)

func FrFrom32

func FrFrom32(dst *Fr, v [32]byte) (ok bool)

FrFrom32 mutates the fr num. The value v is little-endian 32-bytes. Returns false, without modifying dst, if the value is out of range.

func FrStr

func FrStr(b *Fr) string

func FrTo32

func FrTo32(src *Fr) (v [32]byte)

FrTo32 serializes a fr number to 32 bytes. Encoded little-endian.

func InvModFr

func InvModFr(dst *Fr, v *Fr)

func IsPowerOfTwo

func IsPowerOfTwo(v uint64) bool

func MulG1

func MulG1(dst *G1Point, a *G1Point, b *Fr)

func MulG2

func MulG2(dst *G2Point, a *G2Point, b *Fr)

func MulModFr

func MulModFr(dst *Fr, a, b *Fr)

func NegG1

func NegG1(dst *G1Point)

func NegG2

func NegG2(dst *G2Point)

func PairingsVerify

func PairingsVerify(a1 *G1Point, a2 *G2Point, b1 *G1Point, b2 *G2Point) bool

e(a1^(-1), a2) * e(b1, b2) = 1_T

func SetFr

func SetFr(dst *Fr, v string)

func StrG1

func StrG1(v *G1Point) string

func StrG2

func StrG2(v *G2Point) string

func SubG1

func SubG1(dst *G1Point, a *G1Point, b *G1Point)

func SubG2

func SubG2(dst *G2Point, a *G2Point, b *G2Point)

func SubModFr

func SubModFr(dst *Fr, a, b *Fr)

func ToCompressedG1

func ToCompressedG1(p *G1Point) []byte

func ToCompressedG2

func ToCompressedG2(p *G2Point) []byte

func ValidFr

func ValidFr(val [32]byte) bool

Checks if a *little endian* uint256 is within the Fr modulus

Types

type Fr

type Fr kbls.Fr

Note: with Kilic BLS, we exclusively represent Fr in mont-red form. Whenever it is used with G1/G2, it needs to be normalized first.

var INVERSE_TWO Fr
var MODULUS_MINUS1, MODULUS_MINUS1_DIV2, MODULUS_MINUS2 Fr
var ZERO, ONE, TWO Fr

func LinCombFr

func LinCombFr(numbers []Fr, factors []Fr) Fr

func PolyLinComb

func PolyLinComb(vectors [][]Fr, scalars []Fr, polyDegree int) ([]Fr, error)

func RandomFr

func RandomFr() *Fr

func ToFr

func ToFr(v string) (out Fr)

func (*Fr) String

func (fr *Fr) String() string

type G1Point

type G1Point kbls.PointG1

TODO types file, swap BLS with build args

var GenG1 G1Point
var ZERO_G1 G1Point
var ZeroG1 G1Point

func FromCompressedG1

func FromCompressedG1(v []byte) (*G1Point, error)

func LinCombG1

func LinCombG1(numbers []G1Point, factors []Fr) *G1Point

func (*G1Point) MarshalText

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

MarshalText encodes G1Point into hex formatted text (no 0x prefix)

func (*G1Point) String

func (p *G1Point) String() string

func (*G1Point) UnmarshalText

func (p *G1Point) UnmarshalText(text []byte) error

UnmarshalText decodes hex formatted text (no 0x prefix) into a G1Point

type G2Point

type G2Point kbls.PointG2
var GenG2 G2Point
var ZeroG2 G2Point

func FromCompressedG2

func FromCompressedG2(v []byte) (*G2Point, error)

func (*G2Point) MarshalText

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

MarshalText encodes G2Point into hex formatted text (no 0x prefix)

func (*G2Point) String

func (p *G2Point) String() string

func (*G2Point) UnmarshalText

func (p *G2Point) UnmarshalText(text []byte) error

UnmarshalText decodes hex formatted text (no 0x prefix) into a G2Point

Jump to

Keyboard shortcuts

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