common

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ScalarByteSize = 32

Variables

This section is empty.

Functions

func BigToBytes

func BigToBytes(bi *big.Int) []byte

func RequireCanonicalInfinity added in v0.4.0

func RequireCanonicalInfinity(b []byte, isInfinity bool, canonical func() []byte)

RequireCanonicalInfinity panics if a decoded identity was not given in its canonical encoding. gnark-crypto's BLS12 decoders also accept an all-zero uncompressed buffer as the identity.

func SetBytesExact added in v0.4.0

func SetBytesExact(b []byte, size int, setBytes func([]byte) (int, error))

SetBytesExact decodes b with setBytes (typically a gnark-crypto SetBytes method, which returns the number of bytes consumed) and panics unless b is exactly size bytes long and setBytes consumed all of it.

gnark-crypto's point decoders accept buffers longer than the encoding and ignore the trailing bytes, and select the compressed or uncompressed format from the flag bits of the first byte. Requiring len(b) == size and full consumption makes decoding injective and pins the format to the one the caller asked for (see also RequireCanonicalInfinity). On-curve and subgroup checks are left to setBytes.

Types

type BaseZr added in v0.1.0

type BaseZr struct {
	big.Int
	Modulus big.Int
	// contains filtered or unexported fields
}

func NewBaseZrFromBytesCanonical added in v0.4.0

func NewBaseZrFromBytesCanonical(modulus *big.Int, b []byte) (*BaseZr, error)

NewBaseZrFromBytesCanonical decodes b as a big-endian scalar modulo modulus and returns an error unless len(b) == ScalarByteSize and the encoded value is strictly smaller than modulus, i.e. unless b is the (unique) encoding that Bytes produces for that scalar. Drivers whose Zr type is BaseZr use it to implement driver.CanonicalZrDecoder.

func (*BaseZr) BigInt added in v0.1.0

func (b *BaseZr) BigInt() *big.Int

func (*BaseZr) Bytes added in v0.1.0

func (b *BaseZr) Bytes() []byte

func (*BaseZr) Clone added in v0.1.0

func (b *BaseZr) Clone(a driver.Zr)

func (*BaseZr) Copy added in v0.1.0

func (b *BaseZr) Copy() driver.Zr

func (*BaseZr) Equals added in v0.1.0

func (b *BaseZr) Equals(p driver.Zr) bool

Equals reports whether b and p represent the same residue modulo the group order.

func (*BaseZr) InvModOrder added in v0.1.0

func (b *BaseZr) InvModOrder()

func (*BaseZr) InvModP added in v0.1.0

func (b *BaseZr) InvModP(p driver.Zr)

func (*BaseZr) IsOne added in v0.1.0

func (b *BaseZr) IsOne() bool

func (*BaseZr) IsZero added in v0.1.0

func (b *BaseZr) IsZero() bool

func (*BaseZr) Minus added in v0.1.0

func (b *BaseZr) Minus(a driver.Zr) driver.Zr

func (*BaseZr) Mod added in v0.1.0

func (b *BaseZr) Mod(a driver.Zr)

func (*BaseZr) Mul added in v0.1.0

func (b *BaseZr) Mul(a driver.Zr) driver.Zr

func (*BaseZr) Neg added in v0.1.0

func (b *BaseZr) Neg()

func (*BaseZr) Plus added in v0.1.0

func (b *BaseZr) Plus(a driver.Zr) driver.Zr

func (*BaseZr) PowMod added in v0.1.0

func (b *BaseZr) PowMod(x driver.Zr) driver.Zr

func (*BaseZr) String added in v0.1.0

func (b *BaseZr) String() string

type CurveBase added in v0.1.0

type CurveBase struct {
	Modulus big.Int
}

func (*CurveBase) GroupOrder added in v0.1.0

func (c *CurveBase) GroupOrder() driver.Zr

func (*CurveBase) HashToZr added in v0.1.0

func (c *CurveBase) HashToZr(data []byte) driver.Zr

func (*CurveBase) ModAdd added in v0.1.0

func (c *CurveBase) ModAdd(a1, b1, m driver.Zr) driver.Zr

func (*CurveBase) ModAddMul added in v0.1.0

func (p *CurveBase) ModAddMul(a1 []driver.Zr, b1 []driver.Zr, modulo driver.Zr) driver.Zr

func (*CurveBase) ModAddMul2 added in v0.1.0

func (p *CurveBase) ModAddMul2(a1 driver.Zr, c1 driver.Zr, b1 driver.Zr, c2 driver.Zr, m driver.Zr) driver.Zr

func (*CurveBase) ModAddMul2InPlace added in v0.1.0

func (p *CurveBase) ModAddMul2InPlace(result driver.Zr, a1, c1, b1, c2, m driver.Zr)

func (*CurveBase) ModAddMul3 added in v0.1.0

func (p *CurveBase) ModAddMul3(a1 driver.Zr, a2 driver.Zr, b1 driver.Zr, b2 driver.Zr, c1 driver.Zr, c2 driver.Zr, m driver.Zr) driver.Zr

func (*CurveBase) ModAddMul3InPlace added in v0.1.0

func (p *CurveBase) ModAddMul3InPlace(result driver.Zr, a1, a2, b1, b2, c1, c2, m driver.Zr)

func (*CurveBase) ModMul added in v0.1.0

func (c *CurveBase) ModMul(a1, b1, m driver.Zr) driver.Zr

func (*CurveBase) ModMulInPlace added in v0.1.0

func (p *CurveBase) ModMulInPlace(result, a, b, m driver.Zr)

func (*CurveBase) ModNeg added in v0.1.0

func (c *CurveBase) ModNeg(a1, m driver.Zr) driver.Zr

func (*CurveBase) ModSub added in v0.1.0

func (c *CurveBase) ModSub(a1, b1, m driver.Zr) driver.Zr

func (*CurveBase) NewRandomZr added in v0.1.0

func (c *CurveBase) NewRandomZr(rng io.Reader) driver.Zr

func (*CurveBase) NewZrFromBigInt added in v0.1.0

func (c *CurveBase) NewZrFromBigInt(i *big.Int) driver.Zr

func (*CurveBase) NewZrFromBytes added in v0.1.0

func (c *CurveBase) NewZrFromBytes(b []byte) driver.Zr

func (*CurveBase) NewZrFromInt64 added in v0.1.0

func (c *CurveBase) NewZrFromInt64(i int64) driver.Zr

func (*CurveBase) NewZrFromUint64 added in v0.1.0

func (c *CurveBase) NewZrFromUint64(i uint64) driver.Zr

func (*CurveBase) Rand added in v0.1.0

func (p *CurveBase) Rand() (io.Reader, error)

Jump to

Keyboard shortcuts

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