Static_isStaticcheckAdd assertions to the proof to check if value is a valid member of type T.
-This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
-the element of type T to put assertions on.
Static ReadonlyCOL_StaticemptyStaticfromStaticfromJSONStaticfromConvert provable type from a normal JS type.
-StatictoA function that takes value (optional), an element of type T, as argument and
-returns an array of any type that make up the "auxiliary" (non-provable) data of value.
Optionalvalue: { value: Field[][] }the element of type T to generate the auxiliary data array from, optional.
-If not provided, a default value for auxiliary data is returned.
An array of any type describing how this T element is made up of "auxiliary" (non-provable) data.
Static OptionaltoOptional method which transforms a provable type into its canonical representation.
-This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations.
-An example is the ForeignField class, which allows non-native field elements to exist in unreduced form.
-The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
-For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
-toCanonical() converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
-The identity function will also be used when the toCanonical() is not present on a type.
StatictoA function that takes value, an element of type T, as argument and returns
-an array of Field elements that make up the provable data of value.
the element of type T to generate the Field array from.
A Field array describing how this T element is made up of Field elements.
StatictoStatictoJSONStatictoConvert provable type to a normal JS type.
-Performs equality check on two Byte16 values.
-Another Byte16 instance.
-Converts the Byte16 instance back into an array of 16 bytes. -NONPROVABLE: This function should only be used for testing purposes. -The output is in AES column‑major order.
-An array of 16 numbers, each between 0 and 255.
-Converts a Byte16 instance into a 4x4 matrix of Field elements (each one byte) -in standard AES column‑major order.
-A 4x4 matrix of Field elements.
-Returns a Field representation of the full 128-bit value.
-Field representation of the Byte16 instance.
-Converts the Byte16 instance into a 32-character hex string. -NONPROVABLE: For testing only.
-A 32-character hex string.
-StaticfromConverts a BigInt value into a Byte16 instance. -NONPROVABLE: Can be used as witness
-the big integer to convert, must be 128 bits
-new Byte16 class
-StaticfromConverts an array of 16 bytes into a Byte16 instance. -NONPROVABLE: This function should only be used for testing purposes.
-Assumes the input is in AES column‑major order:
-An array of 16 numbers, each between 0 and 255.
-A Byte16 instance.
-StaticfromConverts a 4x4 matrix (in column‑major order) into a Byte16 instance.
-4x4 matrix of byte‑sized Field elements.
-A Byte16 instance.
-StaticfromConverts a Field value into a Byte16 instance.
-field must fit into 128 bits, otherwise behaviour is undefined
-A Byte16 instance representing the field value.
-StaticfromConverts a 32-character hex string into a Byte16 instance. -NONPROVABLE: For testing only.
-The hex string must be 32 characters long.
-A 32-character hex string.
-A Byte16 instance.
-StaticsizeReturn the size of the T type in terms of Field type, as Field is the primitive type.
A number representing the size of the T type in terms of Field type.
StaticxorStaticZeroStatic_isStaticcheckAdd assertions to the proof to check if value is a valid member of type T.
-This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
-StaticemptyStaticfromStaticfromJSONStaticfromConvert provable type from a normal JS type.
-StatictoA function that takes value (optional), an element of type T, as argument and
-returns an array of any type that make up the "auxiliary" (non-provable) data of value.
Optionalvalue: { cipher: Byte16 }the element of type T to generate the auxiliary data array from, optional.
-If not provided, a default value for auxiliary data is returned.
An array of any type describing how this T element is made up of "auxiliary" (non-provable) data.
Static OptionaltoOptional method which transforms a provable type into its canonical representation.
-This is needed for types that have multiple representations of the same underlying value, -and might even not have perfect completeness for some of those representations.
-An example is the ForeignField class, which allows non-native field elements to exist in unreduced form.
-The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
-For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
-toCanonical() converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
-The identity function will also be used when the toCanonical() is not present on a type.
StatictoA function that takes value, an element of type T, as argument and returns
-an array of Field elements that make up the provable data of value.
StatictoStatictoJSONStatictoConvert provable type to a normal JS type.
-A Finite Field which implements Rijndael's Finite Field operations. -Operates on values less than 256 and is used to generate sbox values on the fly -Its most important for providing non-linearity within the AES encryption scheme
-Create a new ForeignField from a bigint, number, string or another ForeignField.
-let x = new ForeignField(5);
-
-
-Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants.
-Gadgets.ForeignField.assertLessThan() and handle appropriately.The internal representation of a foreign field element, as a tuple of 3 limbs.
-Static_Static_modulusStatic_provableStatic_variantsSibling classes that represent different ranges of field elements.
-StaticAlmostConstructor for field elements that are "almost reduced", i.e. lie in the range [0, 2^ceil(log2(p))).
-StaticBigintStaticCanonicalConstructor for field elements that are fully reduced, i.e. lie in the range [0, p).
-StaticmodulusStaticprovableProvable<ForeignField>, see Provable
StaticsizeStaticUnreducedConstructor for unreduced field elements.
-Add two Rijndael numbers together, this is equivalent to an xor operation
-Assert that this field element lies in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus.
-Returns the field element as a AlmostForeignField.
-For a more efficient version of this for multiple field elements, see assertAlmostReduced.
-Note: this does not ensure that the field elements is in the canonical range [0, p). -To assert that stronger property, there is assertCanonical. -You should typically use assertAlmostReduced though, because it is cheaper to prove and sufficient for -ensuring validity of all our non-native field arithmetic methods.
-Assert that this field element is fully reduced, -i.e. lies in the range [0, p), where p is the foreign field modulus.
-Returns the field element as a CanonicalForeignField.
-Assert equality with a ForeignField-like value
-Optionalmessage: stringAssert equality with a ForeignField-like value
-Optionalmessage: stringAssert equality with a ForeignField-like value
-Optionalmessage: stringDivides the current number by another. This is equivalent to multiplying by an inverse
-the numerator in the division
-Computes the inverse of the current value, the inverse always satisifes the relationship p * (p^-1) = 1
-Checks whether this field element is a constant.
-See FieldVar to understand constants vs variables.
-Multiply two Rijndael numbers
-the second number to multiply with
-result from multiplication
-Convert this field element to a bigint.
-Unpack a field element to its bits, as a Bool[] array.
-This method is provable!
-Optionallength: numberConvert this field element to a constant.
-See FieldVar to understand constants vs variables.
-Warning: This function is only useful in Provable.witness or Provable.asProver blocks, -that is, in situations where the prover computes a value outside provable code.
-Instance version of Provable<ForeignField>.toFields, see Provable.toFields
Static_multMultiply a Rijndael number by x (represented as 2 in the field)
-StaticassertAssert that one or more field elements lie in the range [0, 2^k), -where k = ceil(log2(p)) and p is the foreign field modulus.
-This is most efficient than when checking a multiple of 3 field elements at once.
-StaticcheckStaticfromCoerce the input to a ForeignField.
-Coerce the input to a ForeignField.
-StaticfromCreate a field element from its bits, as a Bool[] array.
This method is provable!
-StaticfromWrap field into RijndaelFiniteField, note that field should be less than 256
-Input field to wrap
-StaticrandomStaticsumSum (or difference) of multiple finite field elements.
-let z = ForeignField.sum([3, 2, 1], [-1, 1]); // 3 - 2 + 1
z.assertEquals(2);
-
-
-This method expects a list of ForeignField-like values, x0,...,xn,
-and a list of "operations" op1,...,opn where every op is 1 or -1 (plus or minus),
-and returns
x0 + op1*x1 + ... + opn*xn
where the sum is computed in finite field arithmetic.
-Important: For more than two summands, this is significantly more efficient -than chaining calls to ForeignField.add and ForeignField.sub.
-StaticxorPerforms bitwise xor used in Rijndael addition
-first input
-second input
-resulting xor result
-Static_emptyStatic_innerStatic_nextStatic_provableStaticemptyStaticfromStaticfromStaticprovableStaticemptyIterate through the list in a fixed number of steps any apply a given callback on each element.
-Proves that the iteration traverses the entire list. -Once past the last element, dummy elements will be passed to the callback.
-Note: There are no guarantees about the contents of dummy elements, so the callback is expected
-to handle the isDummy flag separately.
Remove the last element from the list and return it.
-If the list is empty, returns a dummy element.
-Remove the last element from the list and return it.
-This proves that the list is non-empty, and fails otherwise.
-Return the last element, but only remove it if condition is true.
If the list is empty, returns a dummy element.
-Low-level, minimal version of pop() which lets the caller decide whether there is an element to pop.
I.e. this proves:
-Note that if the caller passes true but the list is empty, this will fail.
-If the caller passes false but the list is non-empty, this succeeds and just doesn't pop off an element.
Push a new element to the list.
-Push a new element to the list, if the condition is true.
StaticcreateCreate a Merkle list type
-Optionally, you can tell create() how to do the hash that pushes a new list element, by passing a nextHash function.
Performs full sbox substitution by performing an inverse followed by a matrix multiplication
-value to transform
-Field value after transformation
-A provable AES implementation using o1js
-npm ci
-
-
-
npm run build
npm run start
-
-
-Or if you want to use the dev build
-npm run dev
-
-
-npm run lint
npm run format
-
-
-Unit tests:
-npm run test
-
-
-If you want to test zk programs locally as well:
-npm run test:zk
-
-
-To run a summary of constraints in all library functions:
-npm run build
node ./build/test/circuitSummary.js
-
-
-| Key | -Value | -
|---|---|
| Total rows | -50185 | -
| Generic | -18617 | -
| Xor16 | -10984 | -
| Zero | -10984 | -
| Rot64 | -4800 | -
| RangeCheck0 | -4800 | -
ConstConstConstConstConstConstConst
Represents a 128-bit field element for AES encryption
-