fiat

package
v0.0.0-...-02f8a93 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: BSD-3-Clause, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ITERATIONS = ((49 * LEN_PRIME) + 57) / 17
View Source
const LEN_PRIME = 256
View Source
const LIMBS = 4
View Source
const SAT_LIMBS = LIMBS + 1 /* we might need 2 more bits to represent m in twos complement */
View Source
const SM2ElementLen = 32
View Source
const SM2ScalarElementLen = 32
View Source
const WORD_SIZE = 64

Variables

This section is empty.

Functions

This section is empty.

Types

type SM2Element

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

SM2Element is an integer modulo 2^256 - 2^224 - 2^96 + 2^64 - 1.

The zero value is a valid zero element.

func (*SM2Element) Add

func (e *SM2Element) Add(t1, t2 *SM2Element) *SM2Element

Add sets e = t1 + t2, and returns e.

func (*SM2Element) Bytes

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

Bytes returns the 32-byte big-endian encoding of e.

func (*SM2Element) Equal

func (e *SM2Element) Equal(t *SM2Element) int

Equal returns 1 if e == t, and zero otherwise.

func (*SM2Element) GetRaw

func (e *SM2Element) GetRaw() *[4]uint64

GetRaw returns reference to internal state so that data could be manipulated. Use with caution as this violates encapsulation.

func (*SM2Element) Invert

func (z *SM2Element) Invert(x *SM2Element) *SM2Element

func (*SM2Element) IsZero

func (e *SM2Element) IsZero() int

IsZero returns 1 if e == 0, and zero otherwise.

func (*SM2Element) Mul

func (e *SM2Element) Mul(t1, t2 *SM2Element) *SM2Element

Mul sets e = t1 * t2, and returns e.

func (*SM2Element) MultiSelect

func (v *SM2Element) MultiSelect(precomputed *[]*[4]uint64, width int, bits byte, fallback *SM2Element, fallbackCond int)

func (*SM2Element) One

func (e *SM2Element) One() *SM2Element

One sets e = 1, and returns e.

func (*SM2Element) Opp

func (e *SM2Element) Opp(t *SM2Element) *SM2Element

func (*SM2Element) Select

func (v *SM2Element) Select(a, b *SM2Element, cond int) *SM2Element

Select sets v to a if cond == 1, and to b if cond == 0.

func (*SM2Element) Set

func (e *SM2Element) Set(t *SM2Element) *SM2Element

Set sets e = t, and returns e.

func (*SM2Element) SetBytes

func (e *SM2Element) SetBytes(v []byte) (*SM2Element, error)

SetBytes sets e = v, where v is a big-endian 32-byte encoding, and returns e. If v is not 32 bytes or it encodes a value higher than 2^256 - 2^224 - 2^96 + 2^64 - 1, SetBytes returns nil and an error, and e is unchanged.

func (*SM2Element) SetRaw

func (e *SM2Element) SetRaw(raw [4]uint64) *SM2Element

SetRaw copies data from raw array into element internal data structure directly, bypassing any potential conversion and sanity checks

func (*SM2Element) Square

func (e *SM2Element) Square(t *SM2Element) *SM2Element

Square sets e = t * t, and returns e.

func (*SM2Element) Sub

func (e *SM2Element) Sub(t1, t2 *SM2Element) *SM2Element

Sub sets e = t1 - t2, and returns e.

func (*SM2Element) ToBigInt

func (e *SM2Element) ToBigInt() *big.Int

type SM2ScalarElement

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

SM2ScalarElement is an integer modulo n (0xFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123).

The zero value is a valid zero element.

func (*SM2ScalarElement) Add

Add sets e = t1 + t2, and returns e.

func (*SM2ScalarElement) Bytes

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

Bytes returns the 32-byte big-endian encoding of e.

func (*SM2ScalarElement) Equal

func (e *SM2ScalarElement) Equal(t *SM2ScalarElement) int

Equal returns 1 if e == t, and zero otherwise.

func (*SM2ScalarElement) Invert

func (*SM2ScalarElement) IsZero

func (e *SM2ScalarElement) IsZero() int

IsZero returns 1 if e == 0, and zero otherwise.

func (*SM2ScalarElement) Mul

Mul sets e = t1 * t2, and returns e.

func (*SM2ScalarElement) One

One sets e = 1, and returns e.

func (*SM2ScalarElement) Select

func (v *SM2ScalarElement) Select(a, b *SM2ScalarElement, cond int) *SM2ScalarElement

Select sets v to a if cond == 1, and to b if cond == 0.

func (*SM2ScalarElement) Set

Set sets e = t, and returns e.

func (*SM2ScalarElement) SetBytes

func (e *SM2ScalarElement) SetBytes(v []byte) (*SM2ScalarElement, error)

SetBytes sets e = v, where v is a big-endian 32-byte encoding, and returns e. If v is not 32 bytes or it encodes a value higher than n (0xFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123), SetBytes returns nil and an error, and e is unchanged.

func (*SM2ScalarElement) Square

Square sets e = t * t, and returns e.

func (*SM2ScalarElement) Sub

Sub sets e = t1 - t2, and returns e.

func (*SM2ScalarElement) ToBigInt

func (e *SM2ScalarElement) ToBigInt() *big.Int

Jump to

Keyboard shortcuts

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