Movatterモバイル変換


[0]ホーム

URL:


field

packagestandard library
go1.25.5Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:5Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package field implements fast arithmetic modulo 2^255-19.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeElement

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

Element represents an element of the field GF(2^255-19). Note that thisis not a cryptographically secure group, and should only be used to interactwith edwards25519.Point coordinates.

This type works similarly to math/big.Int, and all arguments and receiversare allowed to alias.

The zero value is a valid zero element.

func (*Element)Absolute

func (v *Element) Absolute(u *Element) *Element

Absolute sets v to |u|, and returns v.

func (*Element)Add

func (v *Element) Add(a, b *Element) *Element

Add sets v = a + b, and returns v.

func (*Element)Bytes

func (v *Element) Bytes() []byte

Bytes returns the canonical 32-byte little-endian encoding of v.

func (*Element)Equal

func (v *Element) Equal(u *Element)int

Equal returns 1 if v and u are equal, and 0 otherwise.

func (*Element)Invert

func (v *Element) Invert(z *Element) *Element

Invert sets v = 1/z mod p, and returns v.

If z == 0, Invert returns v = 0.

func (*Element)IsNegative

func (v *Element) IsNegative()int

IsNegative returns 1 if v is negative, and 0 otherwise.

func (*Element)Mult32

func (v *Element) Mult32(x *Element, yuint32) *Element

Mult32 sets v = x * y, and returns v.

func (*Element)Multiply

func (v *Element) Multiply(x, y *Element) *Element

Multiply sets v = x * y, and returns v.

func (*Element)Negate

func (v *Element) Negate(a *Element) *Element

Negate sets v = -a, and returns v.

func (*Element)One

func (v *Element) One() *Element

One sets v = 1, and returns v.

func (*Element)Pow22523

func (v *Element) Pow22523(x *Element) *Element

Pow22523 set v = x^((p-5)/8), and returns v. (p-5)/8 is 2^252-3.

func (*Element)Select

func (v *Element) Select(a, b *Element, condint) *Element

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

func (*Element)Set

func (v *Element) Set(a *Element) *Element

Set sets v = a, and returns v.

func (*Element)SetBytes

func (v *Element) SetBytes(x []byte) (*Element,error)

SetBytes sets v to x, where x is a 32-byte little-endian encoding. If x isnot of the right length, SetBytes returns nil and an error, and thereceiver is unchanged.

Consistent withRFC 7748, the most significant bit (the high bit of thelast byte) is ignored, and non-canonical values (2^255-19 through 2^255-1)are accepted. Note that this is laxer than specified byRFC 8032, butconsistent with most Ed25519 implementations.

func (*Element)SqrtRatio

func (r *Element) SqrtRatio(u, v *Element) (R *Element, wasSquareint)

SqrtRatio sets r to the non-negative square root of the ratio of u and v.

If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatiosets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00,and returns r and 0.

func (*Element)Square

func (v *Element) Square(x *Element) *Element

Square sets v = x * x, and returns v.

func (*Element)Subtract

func (v *Element) Subtract(a, b *Element) *Element

Subtract sets v = a - b, and returns v.

func (*Element)Swap

func (v *Element) Swap(u *Element, condint)

Swap swaps v and u if cond == 1 or leaves them unchanged if cond == 0, and returns v.

func (*Element)Zero

func (v *Element) Zero() *Element

Zero sets v = 0, and returns v.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp