common

package
v0.0.0-...-96d1451 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBasicLogger

func GetBasicLogger(writer io.Writer) crypto.Logger

GetBasicLogger get basic Logger

func GetBasicLoggerWithLevel

func GetBasicLoggerWithLevel(writer io.Writer, level int) crypto.Logger

GetBasicLoggerWithLevel get basic Logger

func GetCurve101

func GetCurve101(fft bool) crypto.Pairing

GetCurve101 get a curve for test

func GetCurve257

func GetCurve257(fft bool) crypto.Pairing

GetCurve257 get a curve for test

func GetCurve97

func GetCurve97(fft bool) crypto.Pairing

GetCurve97 get a curve for test

func GetR1CSForTest

func GetR1CSForTest(t *testing.T, L, R, O [][]crypto.FieldElement) crypto.R1CSIterator

GetR1CSForTest get r1cs

func PrintArray

func PrintArray(in interface{}) string

PrintArray print field element array

Types

type BigNumForTest

type BigNumForTest struct {
	P big.Int
	V *big.Int
}

BigNumForTest for test

func NewBigNum

func NewBigNum(P, V *big.Int) *BigNumForTest

NewBigNum new big

func (*BigNumForTest) Add

Add add

func (*BigNumForTest) Copy

func (b *BigNumForTest) Copy() crypto.FieldElement

Copy copy

func (*BigNumForTest) Div

Div div

func (*BigNumForTest) Double

Double double

func (*BigNumForTest) Equal

func (b *BigNumForTest) Equal(element crypto.FieldElement) bool

Equal reutrn bool

func (*BigNumForTest) Exp

func (b *BigNumForTest) Exp(element crypto.FieldElement, bytes []byte) crypto.FieldElement

Exp exp

func (*BigNumForTest) From

func (b *BigNumForTest) From(in *big.Int) crypto.FieldElement

From From

func (*BigNumForTest) FromRegular

func (b *BigNumForTest) FromRegular(content []byte) crypto.FieldElement

FromRegular From regular

func (*BigNumForTest) GetModule

func (b *BigNumForTest) GetModule(b2 *big.Int)

GetModule get module

func (*BigNumForTest) Inv

Inv inv

func (*BigNumForTest) IsNeg

func (b *BigNumForTest) IsNeg() bool

IsNeg is negative

func (*BigNumForTest) IsOne

func (b *BigNumForTest) IsOne() bool

IsOne is one

func (*BigNumForTest) IsZero

func (b *BigNumForTest) IsZero() bool

IsZero is zero

func (*BigNumForTest) MarshalJSON

func (b *BigNumForTest) MarshalJSON() ([]byte, error)

MarshalJSON json.Marshaler "v@p"

func (*BigNumForTest) MontBytes

func (b *BigNumForTest) MontBytes(bytes []byte) []byte

MontBytes Montgomery Byte String

func (*BigNumForTest) Mul

Mul mul

func (*BigNumForTest) Neg

Neg neg

func (*BigNumForTest) Regular

func (b *BigNumForTest) Regular(bytes []byte) []byte

Regular regular

func (*BigNumForTest) Set

Set set value

func (*BigNumForTest) SetInt64

func (b *BigNumForTest) SetInt64(u int64) crypto.FieldElement

SetInt64 set int64

func (*BigNumForTest) SetOne

func (b *BigNumForTest) SetOne() crypto.FieldElement

SetOne set one

func (*BigNumForTest) SetRandom

func (b *BigNumForTest) SetRandom(reader io.Reader) crypto.FieldElement

SetRandom set random

func (*BigNumForTest) SetUint64

func (b *BigNumForTest) SetUint64(u uint64) crypto.FieldElement

SetUint64 set uint64

func (*BigNumForTest) SetZero

func (b *BigNumForTest) SetZero() crypto.FieldElement

SetZero set zero

func (*BigNumForTest) Square

Square square

func (*BigNumForTest) String

func (b *BigNumForTest) String() string

String fmt.Stringer

func (*BigNumForTest) Sub

Sub sub

func (*BigNumForTest) ToBigInt

func (b *BigNumForTest) ToBigInt(rat *big.Int) *big.Int

ToBigInt convert to big.Rat

func (*BigNumForTest) UnmarshalJSON

func (b *BigNumForTest) UnmarshalJSON(in []byte) error

UnmarshalJSON json.UnMarshaler

type CSForKeyTest

type CSForKeyTest struct {
	Sys crypto.Pairing
}

func (*CSForKeyTest) Compute

func (C *CSForKeyTest) Compute(_ string) ([]crypto.FieldElement, error)

func (*CSForKeyTest) ComputeInC

func (C *CSForKeyTest) ComputeInC(cPath, info string) (wits []*big.Rat, err error)

func (*CSForKeyTest) ConstraintsNum

func (C *CSForKeyTest) ConstraintsNum() uint64

func (*CSForKeyTest) GetPairing

func (C *CSForKeyTest) GetPairing() crypto.Pairing

func (*CSForKeyTest) GetSignalByID

func (C *CSForKeyTest) GetSignalByID(nowid int) (id, reoffset int, prefix string, value crypto.FieldElement)

func (*CSForKeyTest) InputNum

func (C *CSForKeyTest) InputNum() (privateInput, publicInput int)

func (*CSForKeyTest) Marshal

func (C *CSForKeyTest) Marshal() []byte

func (*CSForKeyTest) Next

func (C *CSForKeyTest) Next(pos *int) (index int, a, b, c map[int]crypto.FieldElement)

func (*CSForKeyTest) OutputNum

func (C *CSForKeyTest) OutputNum() int

func (*CSForKeyTest) SignalNum

func (C *CSForKeyTest) SignalNum() int

1 x out; sym1 y sym2 这个case中,x看做输出,和out看做公开输入,没有隐私输入 m=6, l=3

func (*CSForKeyTest) String

func (C *CSForKeyTest) String() string

func (*CSForKeyTest) Unmarshal

func (C *CSForKeyTest) Unmarshal(bytes []byte) ([]byte, error)

type Curve

type Curve struct {
	SupportFFT bool
	Module     big.Int
	A, B       *BigNumForTest
	Gx, Gy     *BigNumForTest
	Older      big.Int

	Square   big.Int
	G2x, G2y *XBigNumForTest
}

Curve Y^2=X^3+ax+b mod Module

func (*Curve) BatchScalarMultiplicationG1

func (c *Curve) BatchScalarMultiplicationG1(scalars []*big.Int, ret []crypto.Point)

BatchScalarMultiplicationG1 batch multiplication

func (*Curve) BatchScalarMultiplicationG2

func (c *Curve) BatchScalarMultiplicationG2(scalars []*big.Int, ret []crypto.Point)

BatchScalarMultiplicationG2 batch multiplication

func (*Curve) GetBase

func (c *Curve) GetBase(position crypto.Position) crypto.Point

GetBase get base

func (*Curve) GetModule

func (c *Curve) GetModule() *big.Int

GetModule get module

func (*Curve) GetRootOfUnity

func (c *Curve) GetRootOfUnity(u uint64) (crypto.FieldElement, uint64, error)

GetRootOfUnity 找到v阶子群的元根,v是大于u的最小的2的幂

func (*Curve) IsOnCurve

func (c *Curve) IsOnCurve(point crypto.Point) error

IsOnCurve is on curve

func (*Curve) Marshal

func (c *Curve) Marshal() []byte

Marshal to bytes

func (*Curve) Name

func (c *Curve) Name() string

Name get name

func (*Curve) NewCurvePoint

func (c *Curve) NewCurvePoint(scalar *big.Int) *CurvePoint

NewCurvePoint new curve point

func (*Curve) NewPoint

func (c *Curve) NewPoint(position crypto.Position) crypto.Point

NewPoint new point

func (*Curve) NewScalar

func (c *Curve) NewScalar() crypto.FieldElement

NewScalar new scalar

func (*Curve) NewTwistPoint

func (c *Curve) NewTwistPoint(scalar *big.Int) *TwistPoint

NewTwistPoint new point

func (*Curve) Pair

func (c *Curve) Pair(point []crypto.Point, point2 []crypto.Point) crypto.Point

Pair compute pairing

func (*Curve) PairCheck

func (c *Curve) PairCheck(point []crypto.Point, point2 []crypto.Point) bool

PairCheck compute pairing

func (*Curve) PutScalar

func (c *Curve) PutScalar(_ crypto.FieldElement)

PutScalar put scalar to pool

func (*Curve) Unmarshal

func (c *Curve) Unmarshal(data []byte) ([]byte, error)

Unmarshal parse

type CurvePoint

type CurvePoint struct {
	C     *Curve
	X, Y  *BigNumForTest
	IsInf bool
	Coef  crypto.FieldElement
}

CurvePoint point

func (*CurvePoint) Add

func (c *CurvePoint) Add(p1 crypto.Point, p2 crypto.Point) crypto.Point

Add add

func (*CurvePoint) DLP

func (c *CurvePoint) DLP() *BigNumForTest

DLP ECDLP

func (*CurvePoint) Double

func (c *CurvePoint) Double(p crypto.Point) crypto.Point

Double double

func (*CurvePoint) GetPairing

func (c *CurvePoint) GetPairing() crypto.Pairing

GetPairing get pairing

func (*CurvePoint) GetPosition

func (c *CurvePoint) GetPosition() crypto.Position

GetPosition get position

func (*CurvePoint) IsInfinity

func (c *CurvePoint) IsInfinity() bool

IsInfinity return bool

func (*CurvePoint) Marshal

func (c *CurvePoint) Marshal() []byte

Marshal to bytes

func (*CurvePoint) Neg

func (c *CurvePoint) Neg(point crypto.Point) crypto.Point

Neg neg

func (*CurvePoint) ScalarBaseMult

func (c *CurvePoint) ScalarBaseMult(e *big.Int) crypto.Point

ScalarBaseMult scalar multiplication with Base

func (*CurvePoint) ScalarMult

func (c *CurvePoint) ScalarMult(a crypto.Point, scalar *big.Int) crypto.Point

ScalarMult scalar multiplication

func (*CurvePoint) Set

func (c *CurvePoint) Set(p crypto.Point) crypto.Point

Set set value

func (*CurvePoint) SetInfinity

func (c *CurvePoint) SetInfinity()

SetInfinity set infinity

func (*CurvePoint) Unmarshal

func (c *CurvePoint) Unmarshal(m []byte) ([]byte, error)

Unmarshal parse

type R1csForTest

type R1csForTest struct {
	L, R, O []map[int]crypto.FieldElement
}

R1csForTest r1cs

func (*R1csForTest) ConstraintsNum

func (r *R1csForTest) ConstraintsNum() uint64

ConstraintsNum constraints number

func (*R1csForTest) GetSignalByID

func (r *R1csForTest) GetSignalByID(nowid int) (id, reoffset int, prefix string, value crypto.FieldElement)

GetSignalByID get signal by ID

func (*R1csForTest) Next

func (r *R1csForTest) Next(pos *int) (index int, a, b, c map[int]crypto.FieldElement)

Next next

func (*R1csForTest) NextVariable

func (r *R1csForTest) NextVariable(buf []crypto.FieldElement) (int, []crypto.FieldElement)

NextVariable next Variable

type SuperLogger

type SuperLogger interface {
	SetEnableCaller(enable bool)
	crypto.Logger
}

SuperLogger super logger

type TwistPoint

type TwistPoint struct {
	C     *Curve
	X, Y  *XBigNumForTest
	IsInf bool
}

TwistPoint extern point

func (*TwistPoint) Add

func (t *TwistPoint) Add(p1 crypto.Point, p2 crypto.Point) crypto.Point

Add add

func (*TwistPoint) Double

func (t *TwistPoint) Double(p crypto.Point) crypto.Point

Double double

func (*TwistPoint) GetPairing

func (t *TwistPoint) GetPairing() crypto.Pairing

GetPairing get pairing

func (*TwistPoint) GetPosition

func (t *TwistPoint) GetPosition() crypto.Position

GetPosition get position

func (*TwistPoint) IsInfinity

func (t *TwistPoint) IsInfinity() bool

IsInfinity is infinity

func (*TwistPoint) Marshal

func (t *TwistPoint) Marshal() []byte

Marshal marshal

func (*TwistPoint) Neg

func (t *TwistPoint) Neg(point crypto.Point) crypto.Point

Neg neg

func (*TwistPoint) ScalarBaseMult

func (t *TwistPoint) ScalarBaseMult(e *big.Int) crypto.Point

ScalarBaseMult scalar multiplication with Base

func (*TwistPoint) ScalarMult

func (t *TwistPoint) ScalarMult(a crypto.Point, scalar *big.Int) crypto.Point

ScalarMult scalar multiplication

func (*TwistPoint) Set

func (t *TwistPoint) Set(p crypto.Point) crypto.Point

Set set value

func (*TwistPoint) SetInfinity

func (t *TwistPoint) SetInfinity()

SetInfinity set infinity

func (*TwistPoint) Unmarshal

func (t *TwistPoint) Unmarshal(m []byte) ([]byte, error)

Unmarshal unmarshal

type XBigNumForTest

type XBigNumForTest struct {
	P  big.Int
	IS big.Int
	V  *big.Int
	Vi *big.Int
}

XBigNumForTest for test

func NewXBigNum

func NewXBigNum(P, I, V, Vi *big.Int) *XBigNumForTest

NewXBigNum new big number

func (*XBigNumForTest) Add

Add add

func (*XBigNumForTest) Copy

Copy copy

func (*XBigNumForTest) Div

Div div

func (*XBigNumForTest) Double

Double double

func (*XBigNumForTest) Equal

func (b *XBigNumForTest) Equal(element crypto.FieldElement) bool

Equal is equal

func (*XBigNumForTest) Exp

func (b *XBigNumForTest) Exp(element crypto.FieldElement, bytes []byte) crypto.FieldElement

Exp exp

func (*XBigNumForTest) From

func (b *XBigNumForTest) From(in *big.Int) crypto.FieldElement

From parse *big.Rat

func (*XBigNumForTest) FromRegular

func (b *XBigNumForTest) FromRegular(content []byte) crypto.FieldElement

FromRegular From regular

func (*XBigNumForTest) GetModule

func (b *XBigNumForTest) GetModule(b2 *big.Int)

GetModule get module

func (*XBigNumForTest) Inv

Inv inv

func (*XBigNumForTest) IsNeg

func (b *XBigNumForTest) IsNeg() bool

IsNeg is negative

func (*XBigNumForTest) IsOne

func (b *XBigNumForTest) IsOne() bool

IsOne is one

func (*XBigNumForTest) IsZero

func (b *XBigNumForTest) IsZero() bool

IsZero is zero

func (*XBigNumForTest) MarshalJSON

func (b *XBigNumForTest) MarshalJSON() ([]byte, error)

MarshalJSON json.Marshaler

func (*XBigNumForTest) MontBytes

func (b *XBigNumForTest) MontBytes(res []byte) []byte

MontBytes Montgomery Byte String

func (*XBigNumForTest) Mul

Mul (V1·V2+IS·Vi1·Vi2, V1·Vi2+V2·Vi1)

func (*XBigNumForTest) Neg

Neg neg

func (*XBigNumForTest) Regular

func (b *XBigNumForTest) Regular(bytes []byte) []byte

Regular regular

func (*XBigNumForTest) Set

Set set

func (*XBigNumForTest) SetInt64

func (b *XBigNumForTest) SetInt64(u int64) crypto.FieldElement

SetInt64 set uint64

func (*XBigNumForTest) SetOne

func (b *XBigNumForTest) SetOne() crypto.FieldElement

SetOne set one

func (*XBigNumForTest) SetRandom

func (b *XBigNumForTest) SetRandom(reader io.Reader) crypto.FieldElement

SetRandom set random

func (*XBigNumForTest) SetUint64

func (b *XBigNumForTest) SetUint64(u uint64) crypto.FieldElement

SetUint64 set uint64

func (*XBigNumForTest) SetZero

func (b *XBigNumForTest) SetZero() crypto.FieldElement

SetZero set zero

func (*XBigNumForTest) Square

Square square

func (*XBigNumForTest) String

func (b *XBigNumForTest) String() string

String fmt.Stringer

func (*XBigNumForTest) Sub

Sub sub

func (*XBigNumForTest) ToBigInt

func (b *XBigNumForTest) ToBigInt(rat *big.Int) *big.Int

ToBigInt convert to big.Rat

func (*XBigNumForTest) UnmarshalJSON

func (b *XBigNumForTest) UnmarshalJSON(in []byte) error

UnmarshalJSON json.UnMarshaler

Jump to

Keyboard shortcuts

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