Documentation ¶
Index ¶
- Variables
- func BytesPadBigEndian(i *big.Int, l int) []byte
- func GetRandomBytes(len int) []byte
- func GetRandomInt(order *big.Int) *big.Int
- func NAF(nIn *big.Int, k int) []int8
- func TimeTrack(start time.Time, name string)
- func Trace(strs ...fmt.Stringer)
- type BaseField
- type CurveElement
- func (elem *CurveElement) Add(elemIn *CurveElement) *CurveElement
- func (elem *CurveElement) CopyPow() PowElement
- func (elem *CurveElement) Invert() *CurveElement
- func (elem *CurveElement) MakeOnePow() PowElement
- func (elem *CurveElement) MulPoint(elemIn *CurveElement) *CurveElement
- func (elem *CurveElement) MulPow(elemIn PowElement) PowElement
- func (elem *CurveElement) MulScalar(n *big.Int) *CurveElement
- func (elem *CurveElement) NegateY() *CurveElement
- func (elem *CurveElement) Pow(in *ModInt) *CurveElement
- func (elem *CurveElement) PowZn(in *big.Int) *CurveElement
- func (elem *CurveElement) Square() *CurveElement
- func (elem *CurveElement) Sub(_ *CurveElement) *CurveElement
- type CurveField
- func (field *CurveField) GetGen() *CurveElement
- func (field *CurveField) MakeElement(x *big.Int, y *big.Int) *CurveElement
- func (field *CurveField) MakeElementFromBytes(elemBytes []byte) *CurveElement
- func (field *CurveField) MakeElementFromHash(h []byte) *CurveElement
- func (field *CurveField) MakeElementFromX(x *big.Int) *CurveElement
- type CurveParams
- type Field
- type ModInt
- func (bi *ModInt) Add(in *ModInt) *ModInt
- func (bi *ModInt) Copy() *ModInt
- func (bi *ModInt) Freeze()
- func (bi *ModInt) GetMod() *big.Int
- func (bi *ModInt) GetValue() *big.Int
- func (bi *ModInt) Invert() *ModInt
- func (bi *ModInt) IsValEqual(in *ModInt) bool
- func (bi *ModInt) Mul(in *ModInt) *ModInt
- func (bi *ModInt) Negate() *ModInt
- func (bi *ModInt) Pow(in *ModInt) *ModInt
- func (bi *ModInt) Square() *ModInt
- func (bi *ModInt) String() string
- func (bi *ModInt) Sub(in *ModInt) *ModInt
- type PointLike
- type PowElement
- type ZElement
- type ZField
Constants ¶
This section is empty.
Variables ¶
var MI_EIGHT = MakeModInt(8, true, MOD_ANY)
var MI_FOUR = MakeModInt(4, true, MOD_ANY)
var MI_ONE = MakeModInt(1, true, MOD_ANY)
var MI_SEVEN = MakeModInt(7, true, MOD_ANY)
var MI_THREE = MakeModInt(3, true, MOD_ANY)
var MI_TWO = MakeModInt(2, true, MOD_ANY)
var MI_ZERO = MakeModInt(0, true, MOD_ANY)
var MOD_ANY *big.Int = nil
for validation purposes this special value is assumed to match any other modulus
var ONE = big.NewInt(1)
var THREE = big.NewInt(3)
var TWO = big.NewInt(2)
var ZERO = big.NewInt(0)
Functions ¶
func GetRandomBytes ¶
Types ¶
type CurveElement ¶
type CurveElement struct { ElemParams *CurveParams PointLike }
func (*CurveElement) Add ¶
func (elem *CurveElement) Add(elemIn *CurveElement) *CurveElement
func (*CurveElement) CopyPow ¶
func (elem *CurveElement) CopyPow() PowElement
func (*CurveElement) Invert ¶
func (elem *CurveElement) Invert() *CurveElement
func (*CurveElement) MakeOnePow ¶
func (elem *CurveElement) MakeOnePow() PowElement
func (*CurveElement) MulPoint ¶
func (elem *CurveElement) MulPoint(elemIn *CurveElement) *CurveElement
func (*CurveElement) MulPow ¶
func (elem *CurveElement) MulPow(elemIn PowElement) PowElement
func (*CurveElement) MulScalar ¶
func (elem *CurveElement) MulScalar(n *big.Int) *CurveElement
func (*CurveElement) NegateY ¶
func (elem *CurveElement) NegateY() *CurveElement
func (*CurveElement) Pow ¶
func (elem *CurveElement) Pow(in *ModInt) *CurveElement
func (*CurveElement) PowZn ¶
func (elem *CurveElement) PowZn(in *big.Int) *CurveElement
func (*CurveElement) Square ¶
func (elem *CurveElement) Square() *CurveElement
func (*CurveElement) Sub ¶
func (elem *CurveElement) Sub(_ *CurveElement) *CurveElement
type CurveField ¶
type CurveField struct { CurveParams // contains filtered or unexported fields }
func MakeCurveField ¶
func (*CurveField) GetGen ¶
func (field *CurveField) GetGen() *CurveElement
func (*CurveField) MakeElement ¶
func (field *CurveField) MakeElement(x *big.Int, y *big.Int) *CurveElement
func (*CurveField) MakeElementFromBytes ¶
func (field *CurveField) MakeElementFromBytes(elemBytes []byte) *CurveElement
func (*CurveField) MakeElementFromHash ¶
func (field *CurveField) MakeElementFromHash(h []byte) *CurveElement
this function constructs a point on the curve from the input hash-derived bytes. since the input is assumed to be random when we use it as an initial X value it is not guaranteed to lie on the curve therefore - unlike MakeElementFromX - we iterate in a stable way to find a value that does satisfy the curve equation the size of the hash must be such that we can guarantee that its value as an integer is less than our target order
func (*CurveField) MakeElementFromX ¶
func (field *CurveField) MakeElementFromX(x *big.Int) *CurveElement
TODO: needs to account for sign
type CurveParams ¶
type CurveParams struct { BaseField // contains filtered or unexported fields }
func (*CurveParams) GetTargetField ¶
func (curveParams *CurveParams) GetTargetField() *ZField
type ModInt ¶
type ModInt struct {
// contains filtered or unexported fields
}
ModInt is intended to represent the base level of integer modular math for field computations. What may be a bit confusing (and I need to think about) is that I don't intend this to be a replacement for big.Int everywhere. The full name here is more explicit: field.ModInt - that is, a large integer that is a component of a field, which implies/requires modular math.
func MakeModIntRandom ¶
func (*ModInt) IsValEqual ¶
TODO: how do we want these functions to behave WRT nil? also TODO: should we validate for modulus? right now no ...
type PointLike ¶
type PointLike struct {
// contains filtered or unexported fields
}
func MakePointFromBytes ¶
func (*PointLike) IsValEqual ¶
type PowElement ¶
type PowElement interface { String() string CopyPow() PowElement MakeOnePow() PowElement MulPow(PowElement) PowElement }