mcl

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PointG1

type PointG1 struct {
	*bls.G1
}

PointG1 -

func NewPointG1

func NewPointG1() *PointG1

NewPointG1 creates a new point on G1 initialized with base point

func (*PointG1) Add

func (po *PointG1) Add(p crypto.Point) (crypto.Point, error)

Add returns the result of adding receiver with Point p given as parameter, so that their scalars add homomorphically

func (*PointG1) Clone

func (po *PointG1) Clone() crypto.Point

Clone returns a clone of the receiver.

func (*PointG1) Equal

func (po *PointG1) Equal(p crypto.Point) (bool, error)

Equal tests if receiver is equal with the Point p given as parameter. Both Points need to be derived from the same Group

func (*PointG1) GetUnderlyingObj

func (po *PointG1) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*PointG1) IsInterfaceNil

func (po *PointG1) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PointG1) MarshalBinary

func (po *PointG1) MarshalBinary() ([]byte, error)

MarshalBinary converts the point into its byte array representation

func (*PointG1) Mul

func (po *PointG1) Mul(s crypto.Scalar) (crypto.Point, error)

Mul returns the result of multiplying receiver by the scalarInt s.

func (*PointG1) Neg

func (po *PointG1) Neg() crypto.Point

Neg returns the negation of receiver

func (*PointG1) Null

func (po *PointG1) Null() crypto.Point

Null returns the neutral identity element.

func (*PointG1) Pick

func (po *PointG1) Pick() (crypto.Point, error)

Pick returns a new random or pseudo-random Point.

func (*PointG1) Set

func (po *PointG1) Set(p crypto.Point) error

Set sets the receiver equal to another Point p.

func (*PointG1) Sub

func (po *PointG1) Sub(p crypto.Point) (crypto.Point, error)

Sub returns the result of subtracting from receiver the Point p given as parameter, so that their scalars subtract homomorphically

func (*PointG1) UnmarshalBinary

func (po *PointG1) UnmarshalBinary(point []byte) error

UnmarshalBinary reconstructs a point from its byte array representation

type PointG2

type PointG2 struct {
	*bls.G2
}

PointG2 -

func NewPointG2

func NewPointG2() *PointG2

NewPointG2 creates a new point on G2 initialized with base point

func (*PointG2) Add

func (po *PointG2) Add(p crypto.Point) (crypto.Point, error)

Add returns the result of adding receiver with Point p given as parameter, so that their scalars add homomorphically

func (*PointG2) Clone

func (po *PointG2) Clone() crypto.Point

Clone returns a clone of the receiver.

func (*PointG2) Equal

func (po *PointG2) Equal(p crypto.Point) (bool, error)

Equal tests if receiver is equal with the Point p given as parameter. Both Points need to be derived from the same Group

func (*PointG2) GetUnderlyingObj

func (po *PointG2) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*PointG2) IsInterfaceNil

func (po *PointG2) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PointG2) MarshalBinary

func (po *PointG2) MarshalBinary() ([]byte, error)

MarshalBinary converts the point into its byte array representation

func (*PointG2) Mul

func (po *PointG2) Mul(s crypto.Scalar) (crypto.Point, error)

Mul returns the result of multiplying receiver by the scalarInt s.

func (*PointG2) Neg

func (po *PointG2) Neg() crypto.Point

Neg returns the negation of receiver

func (*PointG2) Null

func (po *PointG2) Null() crypto.Point

Null returns the neutral identity element.

func (*PointG2) Pick

func (po *PointG2) Pick() (crypto.Point, error)

Pick returns a new random or pseudo-random Point.

func (*PointG2) Set

func (po *PointG2) Set(p crypto.Point) error

Set sets the receiver equal to another Point p.

func (*PointG2) Sub

func (po *PointG2) Sub(p crypto.Point) (crypto.Point, error)

Sub returns the result of subtracting from receiver the Point p given as parameter, so that their scalars subtract homomorphically

func (*PointG2) UnmarshalBinary

func (po *PointG2) UnmarshalBinary(point []byte) error

UnmarshalBinary reconstructs a point from its byte array representation

type PointGT

type PointGT struct {
	*bls.GT
}

PointGT -

func NewPointGT

func NewPointGT() *PointGT

NewPointGT creates a new point on GT initialized with identity

func (*PointGT) Add

func (po *PointGT) Add(p crypto.Point) (crypto.Point, error)

Add returns the result of adding receiver with Point p given as parameter, so that their scalars add homomorphically

func (*PointGT) Clone

func (po *PointGT) Clone() crypto.Point

Clone returns a clone of the receiver.

func (*PointGT) Equal

func (po *PointGT) Equal(p crypto.Point) (bool, error)

Equal tests if receiver is equal with the Point p given as parameter. Both Points need to be derived from the same Group

func (*PointGT) GetUnderlyingObj

func (po *PointGT) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*PointGT) IsInterfaceNil

func (po *PointGT) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PointGT) MarshalBinary

func (po *PointGT) MarshalBinary() ([]byte, error)

MarshalBinary converts the point into its byte array representation

func (*PointGT) Mul

func (po *PointGT) Mul(s crypto.Scalar) (crypto.Point, error)

Mul returns the result of multiplying receiver by the scalarInt s.

func (*PointGT) Neg

func (po *PointGT) Neg() crypto.Point

Neg returns the negation of receiver

func (*PointGT) Null

func (po *PointGT) Null() crypto.Point

Null returns the neutral identity element.

func (*PointGT) Pick

func (po *PointGT) Pick() (crypto.Point, error)

Pick returns a new random or pseudo-random Point.

func (*PointGT) Set

func (po *PointGT) Set(p crypto.Point) error

Set sets the receiver equal to another Point p.

func (*PointGT) Sub

func (po *PointGT) Sub(p crypto.Point) (crypto.Point, error)

Sub returns the result of subtracting from receiver the Point p given as parameter, so that their scalars subtract homomorphically

func (*PointGT) UnmarshalBinary

func (po *PointGT) UnmarshalBinary(point []byte) error

UnmarshalBinary reconstructs a point from its byte array representation

type Scalar

type Scalar struct {
	Scalar *bls.Fr
}

Scalar -

func NewScalar

func NewScalar() *Scalar

NewScalar creates a scalar instance

func (*Scalar) Add

func (sc *Scalar) Add(s crypto.Scalar) (crypto.Scalar, error)

Add returns the modular sum of receiver with scalarInt s given as parameter

func (*Scalar) Clone

func (sc *Scalar) Clone() crypto.Scalar

Clone creates a new Scalar with same value as receiver

func (*Scalar) Div

func (sc *Scalar) Div(s crypto.Scalar) (crypto.Scalar, error)

Div returns the modular division between receiver and scalarInt s given as parameter

func (*Scalar) Equal

func (sc *Scalar) Equal(s crypto.Scalar) (bool, error)

Equal tests if receiver is equal with the scalarInt s given as parameter. Both scalars need to be derived from the same Group

func (*Scalar) GetUnderlyingObj

func (sc *Scalar) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*Scalar) Inv

func (sc *Scalar) Inv(s crypto.Scalar) (crypto.Scalar, error)

Inv returns the modular inverse of scalarInt s given as parameter

func (*Scalar) IsInterfaceNil

func (sc *Scalar) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Scalar) MarshalBinary

func (sc *Scalar) MarshalBinary() ([]byte, error)

MarshalBinary encodes the receiver into a binary form and returns the result.

func (*Scalar) Mul

func (sc *Scalar) Mul(s crypto.Scalar) (crypto.Scalar, error)

Mul returns the modular product of receiver with scalarInt s given as parameter

func (*Scalar) Neg

func (sc *Scalar) Neg() crypto.Scalar

Neg returns the modular negation of receiver

func (*Scalar) One

func (sc *Scalar) One() crypto.Scalar

One sets the receiver to the multiplicative identity (1)

func (*Scalar) Pick

func (sc *Scalar) Pick() (crypto.Scalar, error)

Pick returns a fresh random or pseudo-random scalarInt

func (*Scalar) Set

func (sc *Scalar) Set(s crypto.Scalar) error

Set sets the receiver to Scalar s given as parameter

func (*Scalar) SetBytes

func (sc *Scalar) SetBytes(s []byte) (crypto.Scalar, error)

SetBytes sets the scalarInt from a byte-slice, reducing if necessary to the appropriate modulus.

func (*Scalar) SetInt64

func (sc *Scalar) SetInt64(v int64)

SetInt64 sets the receiver to a small integer value v given as parameter

func (*Scalar) Sub

func (sc *Scalar) Sub(s crypto.Scalar) (crypto.Scalar, error)

Sub returns the modular difference between receiver and scalarInt s given as parameter

func (*Scalar) UnmarshalBinary

func (sc *Scalar) UnmarshalBinary(s []byte) error

UnmarshalBinary decodes a scalarInt from its byte array representation and sets the receiver to this value

func (*Scalar) Zero

func (sc *Scalar) Zero() crypto.Scalar

Zero returns the the additive identity (0)

type SuiteBLS12

type SuiteBLS12 struct {
	G1 *groupG1
	G2 *groupG2
	GT *groupGT
	// contains filtered or unexported fields
}

SuiteBLS12 provides an implementation of the Suite interface for BLS12-381

func NewSuiteBLS12

func NewSuiteBLS12() *SuiteBLS12

NewSuiteBLS12 returns a wrapper over a BLS12 curve.

func (*SuiteBLS12) CheckPointValid

func (s *SuiteBLS12) CheckPointValid(pointBytes []byte) error

CheckPointValid returns error if the point is not valid (zero is also not valid), otherwise nil

func (*SuiteBLS12) CreateKeyPair

func (s *SuiteBLS12) CreateKeyPair() (crypto.Scalar, crypto.Point)

CreateKeyPair returns a pair of private public BLS keys. The private key is a scalarInt, while the public key is a Point on G2 curve

func (*SuiteBLS12) CreatePoint

func (s *SuiteBLS12) CreatePoint() crypto.Point

CreatePoint creates a new point

func (*SuiteBLS12) CreatePointForScalar

func (s *SuiteBLS12) CreatePointForScalar(scalar crypto.Scalar) (crypto.Point, error)

CreatePointForScalar creates a new point corresponding to the given scalar

func (*SuiteBLS12) CreateScalar

func (s *SuiteBLS12) CreateScalar() crypto.Scalar

CreateScalar creates a new Scalar

func (*SuiteBLS12) GetUnderlyingSuite

func (s *SuiteBLS12) GetUnderlyingSuite() interface{}

GetUnderlyingSuite returns the underlying suite

func (*SuiteBLS12) IsInterfaceNil

func (s *SuiteBLS12) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*SuiteBLS12) PointLen

func (s *SuiteBLS12) PointLen() int

PointLen returns the max length of point in nb of bytes

func (*SuiteBLS12) RandomStream

func (s *SuiteBLS12) RandomStream() cipher.Stream

RandomStream returns a cipher.Stream that returns a key stream from crypto/rand.

func (*SuiteBLS12) ScalarLen

func (s *SuiteBLS12) ScalarLen() int

ScalarLen returns the maximum length of scalars in bytes

func (*SuiteBLS12) String

func (s *SuiteBLS12) String() string

String returns the string for the group

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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