Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Variables
- func BatchInvert[T Element[T]](s array.MutArray[T]) array.MutArray[T]
- func BigInt[F Element[F]](val big.Int) F
- func BigInts[F Element[F]](values []big.Int) []F
- func FromBigEndianBytes[F Element[F]](bytes []byte) F
- func One[F Element[F]]() F
- func Pow[F Element[F]](val F, n uint64) F
- func SplitWord[F Element[F]](val word.BigEndian, widths []uint) ([]F, bool)
- func TwoPowN[F Element[F]](n uint) F
- func Uint1[F Element[F]](val bool) F
- func Uint64[F Element[F]](val uint64) F
- func Zero[F Element[F]]() F
- type Config
- type Element
Constants ¶
This section is empty.
Variables ¶
var BLS12_377 = Config{"BLS12_377", 252, 160}
BLS12_377 is the defacto default field at this time.
var FIELD_CONFIGS = []Config{ GF_251, GF_8209, KOALABEAR_16, BLS12_377, }
FIELD_CONFIGS determines the set of supported fields.
var GF_251 = Config{"GF_251", 7, 4}
GF_251 is teany tiny prime field used exclusively for testing.
var GF_8209 = Config{"GF_8209", 13, 8}
GF_8209 is small prime field used exclusively for testing.
var KOALABEAR_16 = Config{"KOALABEAR_16", 30, 16}
KOALABEAR_16 corresponds to the KoalaBear field with a 16bit register size.
Functions ¶
func BatchInvert ¶
BatchInvert efficiently inverts the list of elements s, in place.
func FromBigEndianBytes ¶
FromBigEndianBytes constructs a word from an array of bytes given in big endian order.
func SplitWord ¶
SplitWord splits a BigEndian word into one or more limbs in a given field F, where each has a given width. If the given value cannot be split into the given widths (i.e. because it overflows their combined width), false is returned to signal a splitting failure.
func Uint1 ¶ added in v1.2.21
Uint1 construct a field element from a boolean value, where false returns 0 and true returns 1.
Types ¶
type Config ¶
type Config struct {
// Name suitable for identifying the config. This is only really used for
// improving error reporting, etc.
Name string
// Maximum field bandwidth available in the field.
BandWidth uint
// Maximum register width to use with this field.
RegisterWidth uint
}
Config provides a simple mechanism for configuring the field agnosticity pipeline.
type Element ¶
type Element[Operand any] interface { fmt.Stringer word.Word[Operand] // Add x+y Add(y Operand) Operand // Return the value of this word as a big integer. BigInt() *big.Int // Check whether this value is zero (or not). IsZero() bool // Check whether this value is one (or not). IsOne() bool // Return the modulus for the field in question. Modulus() *big.Int // Compute x * y Mul(y Operand) Operand // Compute x⁻¹, or 0 if x = 0. Inverse() Operand // Compute x - y Sub(y Operand) Operand // Text returns the numerical value of x in the given base. Text(base int) string }
An Element of a prime-order field.