aiken/crypto/int256
This module implements arithmetic operations in a constrained 256-bit integer field. Operations are performed modulo , providing a field for cryptographic operations that require 32-byte values.
The module provides functionality for basic arithmetic operations (addition, subtraction, multiplication) within this constrained field, as well as conversion functions between different representations.
Types
Alias
State = bitwise.State<Bits256>
Constants
Functions
Constructing
Constructs a new Bits256 element from a Big-Endian (most-significant bits first) ByteArray.
Constructs a new Bits256 element from a Little-Endian (least-significant bits first) ByteArray.
Constructs a new Bits256 element from an integer, ensuring it’s within the valid range of the field.
Modifying
Exponentiates a Bits256 element by a non-negative integer exponent, using repeated squaring.
Note that this function returns zero for negative exponents.
A faster version of scale for the case where the exponent is a power of two.
That is, the exponent for some non-negative integer .
Combining
Adds two Bits256 elements, ensuring the result stays within the finite field range.
Adds a ByteArray to a Bits256 element, interpreting bytes as a big-endian number.
Multiplies two Bits256 elements, with the result constrained within the finite field.
Multiplies a Bits256 element by a ByteArray, interpreting bytes as a big-endian number.
Subtracts one Bits256 element from another, with the result wrapped within the finite field range.
Subtracts a ByteArray from a Bits256 element, interpreting bytes as a big-endian number.
Transforming
Converts a Bits256 element to a Big-Endian (most-significant bits first) ByteArray.
Converts a Bits256 element to a Little-Endian (least-significant bits first) ByteArray.
Constructs a new Bits256 element from a Big-Endian (most-significant bits first) ByteArray.
Constructs a new Bits256 element from a Little-Endian (least-significant bits first) ByteArray.
Constructs a new Bits256 element from an integer, ensuring it’s within the valid range of the field.
Exponentiates a Bits256 element by a non-negative integer exponent, using repeated squaring.
Note that this function returns zero for negative exponents.
A faster version of scale for the case where the exponent is a power of two.
That is, the exponent for some non-negative integer .
Combining
Adds two Bits256 elements, ensuring the result stays within the finite field range.
Adds a ByteArray to a Bits256 element, interpreting bytes as a big-endian number.
Multiplies two Bits256 elements, with the result constrained within the finite field.
Multiplies a Bits256 element by a ByteArray, interpreting bytes as a big-endian number.
Subtracts one Bits256 element from another, with the result wrapped within the finite field range.
Subtracts a ByteArray from a Bits256 element, interpreting bytes as a big-endian number.
Transforming
Converts a Bits256 element to a Big-Endian (most-significant bits first) ByteArray.
Converts a Bits256 element to a Little-Endian (least-significant bits first) ByteArray.
Adds two Bits256 elements, ensuring the result stays within the finite field range.
Adds a ByteArray to a Bits256 element, interpreting bytes as a big-endian number.
Multiplies two Bits256 elements, with the result constrained within the finite field.
Multiplies a Bits256 element by a ByteArray, interpreting bytes as a big-endian number.
Subtracts one Bits256 element from another, with the result wrapped within the finite field range.
Subtracts a ByteArray from a Bits256 element, interpreting bytes as a big-endian number.
Converts a Bits256 element to a Big-Endian (most-significant bits first) ByteArray.
Converts a Bits256 element to a Little-Endian (least-significant bits first) ByteArray.