Word procedures
Module std::word contains utilities for manipulating words — sequences of four field elements.
See Terms and notations for more information.
| Procedure | Description |
|---|---|
| reverse | Reverses order of the first four elements on the stack. Inputs: [a, b, c, d, ...]Outputs: [d, c, b, a, ...]Cycles: 3 |
| eqz | Returns a boolean indicating whether the input word [0, 0, 0, 0].Inputs: [INPUT_WORD]Outputs: [is_word_empty]Where: - INPUT_WORD is the word to compare against [0, 0, 0, 0].- is_word_empty is a boolean indicating whether INPUT_WORD is all zeros.Cycles: 10 |
| testz | Returns a boolean indicating whether the input word [0, 0, 0, 0] Unlike eqz, this does not consume the inputs.Inputs: [INPUT_WORD]Outputs: [is_word_empty, INPUT_WORD]Where: - INPUT_WORD is the word to compare against [0, 0, 0, 0].- is_word_empty is a boolean indicating whether INPUT_WORD is all zeros.Cycles: 11 |
| gt | Returns true if LHS is strictly greater than RHS, false otherwise.It compares words using the same ordering as Merkle tree key comparison. This implementation avoids branching for performance reasons. Inputs: [RHS, LHS]Outputs: [is_lhs_greater]Cycles: 121 |
| gte | Returns true if LHS is greater than or equal to RHS.Inputs: [RHS, LHS]Outputs: [is_lhs_greater_or_equal]Cycles: 118 |
| lt | Returns true if LHS is strictly less than RHS, false otherwise.The implementation avoids branching for performance reasons. From an implementation standpoint this is exactly the same as word::gt except it uses lt rather than gt. See its docs for details.Inputs: [RHS, LHS]Outputs: [is_lhs_lesser]Cycles: 117 |
| lte | Returns true if LHS is strictly less than or equal to RHS, false otherwise.Inputs: [RHS, LHS]Outputs: [is_lhs_less_or_equal]Cycles: 122 |
| eq | Returns true if LHS is exactly equal to RHS, false otherwise.The implementation does not branch, and always performs the same number of comparisons. This is currently equivalent the eqw instruction.Inputs: [RHS, LHS].Outputs: [lhs_eq_rhs]Cycles: 13 |
| test_eq | Returns true if LHS is exactly equal to RHS, false otherwise. Preserves stack inputs.Like word::eq, the implementation does not branch, and always performs the same number of comparisons.Inputs: [RHS, LHS]Outputs: [lhs_eq_rhs, RHS, LHS]Cycles: 15 |