math

package
v0.0.0-...-cdfdded Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuadraticEqual

func QuadraticEqual(a, b QuadraticElem) bool

QuadraticEqual validate if 2 quadratic Galois field elements' value is equal to each other

Types

type EllipticPoint

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

EllipticPoint presents a point on the elliptic curve

func EllipticMul

func EllipticMul(lhs, rhs EllipticPoint) EllipticPoint

EllipticMul returns the product of the given elliptic curve points

func EllipticPow

func EllipticPow(g EllipticPoint, x GaloisElem) EllipticPoint

EllipticPow returns the result of power calculation on elliptic curve

func GetGenerator

func GetGenerator() EllipticPoint

GetGenerator returns a generator of the elliptic curve

func HashToEllipticPt

func HashToEllipticPt(h []byte) EllipticPoint

HashToEllipticPt maps a hash value to an Elliptic curve point

func ParseEllipticPt

func ParseEllipticPt(s string) (EllipticPoint, error)

ParseEllipticPt trys to restore an elliptic curve point from given string

func RandEllipticPt

func RandEllipticPt() (EllipticPoint, error)

RandEllipticPt returns a random point on the elliptic curve in our Galois field.

func (*EllipticPoint) Bytes

func (p *EllipticPoint) Bytes() []byte

Bytes converts a EllipticPoint instance to a byte slice

func (*EllipticPoint) Marshal

func (p *EllipticPoint) Marshal() string

Marshal converts a EllipticPoint instance to a Base64 encoded string

type GaloisElem

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

GaloisElem presents an element in Galois field

func BytesToGaloisElem

func BytesToGaloisElem(b []byte) GaloisElem

BytesToGaloisElem sets a slice of bytes to the value of an Galois field element. Note that the result is in gFR.

func GaloisAdd

func GaloisAdd(lhs, rhs GaloisElem) GaloisElem

GaloisAdd return the sum of the given Galois fields elements Note that this require all the given elements comes from same field

func GaloisMul

func GaloisMul(lhs, rhs GaloisElem) GaloisElem

GaloisMul returns the product of the given Galois field elements Note that the result is in gFR

func HashQuadraticToGalois

func HashQuadraticToGalois(a QuadraticElem) GaloisElem

HashQuadraticToGalois maps a quadratic element to Galois field Note that the result is in gFR

func HashToGaloisElem

func HashToGaloisElem(h []byte) GaloisElem

HashToGaloisElem maps a hash value to an Galois field element. Note that the results is in gFR.

func ParseGaloisElem

func ParseGaloisElem(s string) (GaloisElem, error)

ParseGaloisElem trys to restore a GaloisElem instance by parsing given Base64 encoding string WARNING: the result is in gFR field

func RandGaloisElem

func RandGaloisElem() (GaloisElem, error)

RandGaloisElem returns a random element in the Galois field. Note that the result is in gFR.

func (*GaloisElem) Bytes

func (e *GaloisElem) Bytes() []byte

Bytes converts a GaloisElem instance to a byte slice

func (*GaloisElem) Equal

func (e *GaloisElem) Equal(a GaloisElem) bool

Equal validate if 2 GaloisElem instances are mathematically equal

func (*GaloisElem) Marshal

func (e *GaloisElem) Marshal() string

Marshal converts a GaloisElem instance to a base64 encoded string

type QuadraticElem

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

QuadraticElem presents an element in the quadratic Galois field

func BiLinearMap

func BiLinearMap(u, v EllipticPoint) QuadraticElem

BiLinearMap returns the result of bi-linear map of 2 elements in elliptic curve field

func ParseQuadraticElem

func ParseQuadraticElem(s string) (QuadraticElem, error)

ParseQuadraticElem try to restore a QuadraticElem instance by parsing given string

func QuadraticMul

func QuadraticMul(lhs, rhs QuadraticElem) QuadraticElem

QuadraticMul returns the product of given Galois-based quadratic field elements

func QuadraticPow

func QuadraticPow(b QuadraticElem, e GaloisElem) QuadraticElem

QuadraticPow returns the result of power calculation in a Galois-based quadratic field

func (*QuadraticElem) Bytes

func (e *QuadraticElem) Bytes() []byte

Bytes converts a QuadraticElem instance to a byte slice

func (*QuadraticElem) Marshal

func (e *QuadraticElem) Marshal() string

Marshal converts a QuadraticElem instance to a Base64 encoded string

Jump to

Keyboard shortcuts

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