fiat

package standard library
go1.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package fiat implements prime order fields using formally verified algorithms from the Fiat Cryptography project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type P521Element

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

P521Element is an integer modulo 2^521 - 1.

The zero value is a valid zero element.

func (*P521Element) Add

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

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

func (*P521Element) Bytes

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

Bytes returns the 66-byte little-endian encoding of e.

func (*P521Element) Equal

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

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

func (*P521Element) Invert

func (e *P521Element) Invert(t *P521Element) *P521Element

Invert sets e = 1/t, and returns e.

If t == 0, Invert returns e = 0.

func (*P521Element) IsZero

func (e *P521Element) IsZero() int

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

func (*P521Element) Mul

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

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

func (*P521Element) One

func (e *P521Element) One() *P521Element

One sets e = 1, and returns e.

func (*P521Element) Select

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

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

func (*P521Element) Set

func (e *P521Element) Set(t *P521Element) *P521Element

Set sets e = t, and returns e.

func (*P521Element) SetBytes

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

SetBytes sets e = v, where v is a little-endian 66-byte encoding, and returns e. If v is not 66 bytes or it encodes a value higher than 2^521 - 1, SetBytes returns nil and an error, and e is unchanged.

func (*P521Element) Square

func (e *P521Element) Square(t *P521Element) *P521Element

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

func (*P521Element) Sub

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

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

Jump to

Keyboard shortcuts

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