fp25519

package
v0.0.0-...-4223e8c Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package fp25519 provides prime field arithmetic over GF(2^255-19).

Index

Constants

View Source
const Size = 32

Size in bytes of an element.

Variables

This section is empty.

Functions

func Add

func Add(z, x, y *Elt)

Add calculates z = x+y mod p.

func AddSub

func AddSub(x, y *Elt)

AddSub calculates (x,y) = (x+y mod p, x-y mod p).

func Cmov

func Cmov(x, y *Elt, n uint)

Cmov assigns y to x if n is 1.

func Cswap

func Cswap(x, y *Elt, n uint)

Cswap interchanges x and y if n is 1.

func Inv

func Inv(z, x *Elt)

Inv calculates z = 1/x mod p.

func InvSqrt

func InvSqrt(z, x, y *Elt) (isQR bool)

InvSqrt calculates z = sqrt(x/y) iff x/y is a quadratic-residue, which is indicated by returning isQR = true. Otherwise, when x/y is a quadratic non-residue, z will have an undetermined value and isQR = false.

func IsZero

func IsZero(x *Elt) bool

IsZero returns true if x is equal to 0.

func Modp

func Modp(z *Elt)

Modp ensures that z is between [0,p-1].

func Mul

func Mul(z, x, y *Elt)

Mul calculates z = x*y mod p.

func Neg

func Neg(z, x *Elt)

Neg calculates z = -x.

func SetOne

func SetOne(x *Elt)

SetOne assigns x=1.

func Sqr

func Sqr(z, x *Elt)

Sqr calculates z = x^2 mod p.

func Sub

func Sub(z, x, y *Elt)

Sub calculates z = x-y mod p.

func ToBytes

func ToBytes(b []byte, x *Elt) error

ToBytes stores in b the little-endian byte representation of x.

Types

type Elt

type Elt [Size]byte

Elt is a prime field element.

func P

func P() Elt

P returns the prime modulus 2^255-19.

func (Elt) String

func (e Elt) String() string

Jump to

Keyboard shortcuts

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