Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(masm): refactor assembler into a more compiler-like architecture #1277

Merged
merged 69 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6612bf8
fix(assembly): always build as no_std with explicit std feature
bitwalker Feb 23, 2024
5e47ae0
chore(assembly): sort module declarations
bitwalker Feb 23, 2024
6a85c66
feat: add byte(reader|writer) adapters for libstd write/read traits
bitwalker Mar 1, 2024
efc0a75
feat: add assert_matches macro to core
bitwalker Mar 2, 2024
ad2252e
feat: add basic diagnostics infrastructure
bitwalker Mar 2, 2024
f7a8431
feat: introduce thiserror for defining error types
bitwalker Mar 2, 2024
0d30978
feat: introduce new and improved miden assembly parser
bitwalker Mar 2, 2024
60e3a3b
feat: implement miden assembly source code formatter
bitwalker Mar 2, 2024
a6fd068
feat: introduce subset of new abstract syntax tree
bitwalker Mar 2, 2024
210dfa3
feat: add miden assembly syntax tree visitors
bitwalker Mar 2, 2024
d747981
wip(1/n): refactor procedure types
bitwalker Mar 2, 2024
b034c7c
wip(2/n): refactor invocation target type
bitwalker Mar 2, 2024
95d1001
wip(3/n): refactor library types and api
bitwalker Mar 2, 2024
da11059
wip(4/n): refactor instruction ast
bitwalker Mar 2, 2024
0821d37
wip:(5/n): refactor module ast
bitwalker Mar 2, 2024
df20146
wip(6/n): extend AstSerdeOptions with debug info config
bitwalker Mar 2, 2024
0a57cc2
wip(7/n): remove old code, update ast tests
bitwalker Mar 2, 2024
22a79ad
wip(8/n): implement semantic analysis
bitwalker Mar 2, 2024
f50b677
wip(9/n): implement module graph and call graph structures
bitwalker Mar 2, 2024
ea792ad
wip(10/n): refactor procedure cache
bitwalker Mar 2, 2024
ecc96e8
wip(11/10): refactor assembler interface
bitwalker Mar 7, 2024
b0c2c13
fix: update miden repl and stdlib with assembler changes
bitwalker Mar 3, 2024
2897c22
docs: update assembler documentation
bitwalker Mar 7, 2024
5e6b370
fix: fully specify thiserror/miette deps rather than relying purely o…
bitwalker Mar 8, 2024
18e9f07
fix: merge conflict
bitwalker Mar 8, 2024
ed3b4a4
fix: replace logos-based lexer with hand-written lexer
bitwalker Mar 9, 2024
860fc1c
fix: improve dynexec/procref test
bitwalker Mar 9, 2024
ce6979a
chore: clean up clippy warnings
bitwalker Mar 9, 2024
ba6da89
chore: update rust-version to latest stable for assembler
bitwalker Mar 9, 2024
7f334f9
fix(perf): make procedure name parsing actually efficient
bitwalker Mar 9, 2024
2b6ed7f
chore: fix rustdoc warnings
bitwalker Mar 9, 2024
9554ee1
fix: improve parser error messages
bitwalker Mar 9, 2024
a82ff86
feat: allow libraries fed to the assembler to be unsized types
bitwalker Mar 9, 2024
1872454
fix: ignore local project settings for zed
bitwalker Mar 10, 2024
4bf76d4
fix: ensure rustfmt enforces line-width guidelines on comments
bitwalker Mar 10, 2024
c8d2104
fix: ensure consistent spacing of items and comment width
bitwalker Mar 10, 2024
71a0b3a
fix: only render docs for exported procedures
bitwalker Mar 10, 2024
112db94
fix: clarify reason accessing discriminant value is safe
bitwalker Mar 11, 2024
38b59b8
docs: update comment formatting to follow 100 char rule
bobbinth Mar 14, 2024
aa868b5
docs: fix comment formatting and add section separators
bobbinth Mar 14, 2024
65cea31
feat: add compile trait to simplify interfaces accepting modules
bitwalker Mar 16, 2024
e5e2712
docs: document some undocumented traits/types
bitwalker Mar 16, 2024
418a7d3
fix: export pretty-assertions helpers from test-utils
bitwalker Mar 16, 2024
1bef681
fix: simplify a few grammar rules, improve precision of related diagn…
bitwalker Mar 16, 2024
d66a297
feat: simplify the assembler api using the new compile trait
bitwalker Mar 16, 2024
f430317
fix: turn free function for handling parse errors into trait impl
bitwalker Mar 16, 2024
4ca85ff
fix: address a couple of review comments
bitwalker Mar 16, 2024
91f08f2
chore: clean up winterfell deprecations
bitwalker Mar 16, 2024
7046b60
fix: some small tweaks to remove trailing whitespace in pretty-printe…
bitwalker Mar 19, 2024
8c473fb
fix: remove restriction on kernel imports
bitwalker Mar 19, 2024
d64524d
fix: use u8 for index in debug.stack decorator
bitwalker Mar 19, 2024
cffff84
fix: expose procedure.invoked/extend_invoked to downstream crates
bitwalker Mar 20, 2024
a6a1888
fix: replace some uses of text formatter with const_text
bitwalker Mar 20, 2024
55c73a3
docs: comment formatting, section headers, minor typo fixes
bobbinth Mar 21, 2024
da0569e
docs: minor comment fixes
bobbinth Mar 21, 2024
14b8c4e
chore: clean up some unused code, minor doc corrections
bitwalker Mar 21, 2024
a002a85
refactor: move various modulegraph-related items into module_graph mo…
bitwalker Mar 21, 2024
2628466
refactor: break up module graph implementation more granularly
bitwalker Mar 21, 2024
4ff23af
chore: remove code that was extracted to miden-formatting
bitwalker Mar 22, 2024
29180c7
fix: properly support distinction between errors and warnings
bitwalker Mar 22, 2024
69365d7
docs: update documented behavior of 'exec'
bitwalker Mar 22, 2024
2676d21
fix: add some callgraph tests, remove unused function, fix one bug re…
bitwalker Mar 26, 2024
55669cc
fix: address assorted review comments
bitwalker Mar 26, 2024
b46aaf0
chore: clean up implementation a bit, address some review feedback
bitwalker Mar 28, 2024
475dea1
chore: fix typos, comment formatting, add section headers
bobbinth Mar 31, 2024
307a17d
chore: comment formatting and section headers
bobbinth Apr 2, 2024
167b143
fix: address a few more review comments
bitwalker Apr 3, 2024
aeb5269
fix: a few small adjustments from review
bitwalker Apr 29, 2024
c639420
fix: build errors due to conflict, address some clippy warnings
bitwalker Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ stdlib/assets/std.masl

# VS Code
.vscode/

# Zed
.zed/
22 changes: 13 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[workspace]
members = [
"air",
"assembly",
"core",
"miden",
"processor",
"prover",
"stdlib",
"test-utils",
"verifier"
"air",
"assembly",
"core",
"miden",
"processor",
"prover",
"stdlib",
"test-utils",
"verifier",
]
resolver = "2"

Expand All @@ -22,3 +22,7 @@ inherits = "release"
debug = true
debug-assertions = true
overflow-checks = true

[patch.crates-io]
thiserror = { git = "https://github.com/bitwalker/thiserror", branch = "no-std" }
miette = { git = "https://github.com/bitwalker/miette", branch = "no-std" }
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move these forks to the https://github.com/0xPolygonMiden org?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to say yes? I guess the downside is that means all of the Polygon org rules are going to apply, so someone else will have to be involved to sign off on any updates we do to those crates, but they aren't likely to change much in the near term.

8 changes: 4 additions & 4 deletions air/src/constraints/chiplets/memory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ enum MemoryTestDeltaType {
/// in the specified column (context, address, or clock), then returns the evaluation of the memory
/// constraints on this frame.
///
/// - To test a valid write, the MemoryTestDeltaType must be Context or Address and the `old_values` and
/// `new_values` must change.
/// - To test a valid write, the MemoryTestDeltaType must be Context or Address and the `old_values`
/// and `new_values` must change.
/// - To test a valid read, the `delta_type` must be Clock and the `old_values` and `new_values`
/// must be equal.
fn get_constraint_evaluation(
Expand Down Expand Up @@ -132,8 +132,8 @@ fn get_constraint_evaluation(
/// - `selectors`: specifies the memory operation selectors in the next row which is being tested.
/// - `delta_type`: specifies the column over which the delta value should be calculated.
/// - `delta_row`: specifies the values of the context, address, and clock columns in the next row.
/// - `old_values`: specifies the old values, which are placed in the value columns of the
/// current row.
/// - `old_values`: specifies the old values, which are placed in the value columns of the current
/// row.
/// - `new_values`: specifies the new values, which are placed in the value columns of the next row.
fn get_test_frame(
selectors: Selectors,
Expand Down
2 changes: 1 addition & 1 deletion air/src/constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ where
/// Returns true when a u32 stack operation that requires range checks is being performed.
fn u32_rc_op(&self) -> F;

// --- Range check lookup accessors -----------------------------------------------------------------------
// --- Range check lookup accessors -----------------------------------------------------------

/// The value required for the first memory lookup when the memory chiplet requests range
/// checks. The value returned is the denominator used for including the value into the LogUp
Expand Down
35 changes: 19 additions & 16 deletions air/src/constraints/stack/field_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ pub fn enforce_constraints<E: FieldElement>(

/// Enforces constraints of the ADD operation. The ADD operation adds the first two elements
/// in the current trace. Therefore, the following constraints are enforced:
/// - The first element in the trace frame should be the addition of the first two elements in
/// the current trace. s0` - s0 - s1 = 0.
/// - The first element in the trace frame should be the addition of the first two elements in the
/// current trace. s0` - s0 - s1 = 0.
pub fn enforce_add_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
result: &mut [E],
Expand All @@ -117,10 +117,10 @@ pub fn enforce_add_constraints<E: FieldElement>(
1
}

/// Enforces constraints of the NEG operation. The NEG operation updates the top element
/// in the stack with its inverse. Therefore, the following constraints are enforced:
/// - The first element in the next frame should be the negation of first element in the
/// current frame, therefore, their sum should be 0. s0` + s0 = 0.
/// Enforces constraints of the NEG operation. The NEG operation updates the top element in the
/// stack with its inverse. Therefore, the following constraints are enforced:
/// - The first element in the next frame should be the negation of first element in the current
/// frame, therefore, their sum should be 0. s0` + s0 = 0.
pub fn enforce_neg_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
result: &mut [E],
Expand All @@ -135,8 +135,8 @@ pub fn enforce_neg_constraints<E: FieldElement>(

/// Enforces constraints of the MUL operation. The MUL operation multiplies the first two elements
/// in the current trace. Therefore, the following constraints are enforced:
/// - The first element in the next frame should be the product of the first two elements in
/// the current frame. s0` - s0 * s1 = 0
/// - The first element in the next frame should be the product of the first two elements in the
/// current frame. s0` - s0 * s1 = 0
pub fn enforce_mul_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
result: &mut [E],
Expand All @@ -154,8 +154,8 @@ pub fn enforce_mul_constraints<E: FieldElement>(

/// Enforces constraints of the INV operation. The INV operation updates the top element
/// in the stack with its inverse. Therefore, the following constraints are enforced:
/// - The next element in the next frame should be the inverse of first element in the
/// current frame. s0` * s0 = 1.
/// - The next element in the next frame should be the inverse of first element in the current
/// frame. s0` * s0 = 1.
pub fn enforce_inv_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
result: &mut [E],
Expand Down Expand Up @@ -277,8 +277,9 @@ pub fn enforce_eq_constraints<E: FieldElement>(
// Enforce that either c or difference between a & b is zero.
result[0] = op_flag * are_equal(diff_top_elements * c, E::ZERO);

// It is the inverse of the diff of the top two element in the current frame if the diff is not ZERO;
// otherwise it could be anything. The value is fetched from the first register in the user op helper.
// It is the inverse of the diff of the top two element in the current frame if the diff is not
// ZERO; otherwise it could be anything. The value is fetched from the first register in the
// user op helper.
let diff_inv = frame.user_op_helper(0);

let helper_agg_value = E::ONE - diff_top_elements * diff_inv;
Expand All @@ -305,7 +306,8 @@ pub fn enforce_eqz_constraints<E: FieldElement>(
result[0] = op_flag * are_equal(a * b, E::ZERO);

// It is the inverse of the top element in the current frame if the top element is not ZERO; it
// could be anything otherwise. The value is fetched from the first register in the user op helper.
// could be anything otherwise. The value is fetched from the first register in the user op
// helper.
let inv = frame.user_op_helper(0);

let helper_agg_value = E::ONE - a * inv;
Expand All @@ -316,9 +318,10 @@ pub fn enforce_eqz_constraints<E: FieldElement>(
2
}

/// Enforces constraints of the EXPACC operation. The EXPACC operation computes a single turn of exponent
/// accumulation for the given inputs. Therefore, the following constraints are enforced:
/// - The first element in the next frame should be a binary which is enforced as a general constraint.
/// Enforces constraints of the EXPACC operation. The EXPACC operation computes a single turn of
/// exponent accumulation for the given inputs. Therefore, the following constraints are enforced:
/// - The first element in the next frame should be a binary which is enforced as a general
/// constraint.
/// - The exp value in the next frame should be the square of exp value in the current frame.
/// - The accumulation value in the next frame is the product of the accumulation value in the
/// current frame and the value which needs to be included in this turn.
Expand Down
16 changes: 8 additions & 8 deletions air/src/constraints/stack/field_ops/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,30 @@ fn test_not_stack_operation() {
fn test_and_stack_operation() {
let expected = [ZERO; NUM_CONSTRAINTS];

// ----------------- top elements are 0 and 0 -----------------------------------------------------
// ----------------- top elements are 0 and 0 -------------------------------------------------
let a = ZERO;
let b = ZERO;
let frame = get_and_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 0 and 1 -----------------------------------------------------
// ----------------- top elements are 0 and 1 -------------------------------------------------

let a = ZERO;
let b = ONE;
let frame = get_and_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 1 and 0 -----------------------------------------------------
// ----------------- top elements are 1 and 0 -------------------------------------------------

let a = ONE;
let b = ZERO;
let frame = get_and_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 1 and 1 -----------------------------------------------------
// ----------------- top elements are 1 and 1 -------------------------------------------------

let a = ONE;
let b = ONE;
Expand All @@ -194,30 +194,30 @@ fn test_and_stack_operation() {
fn test_or_stack_operation() {
let expected = [ZERO; NUM_CONSTRAINTS];

// ----------------- top elements are 0 and 0 -----------------------------------------------------
// ----------------- top elements are 0 and 0 -------------------------------------------------
let a = ZERO;
let b = ZERO;
let frame = get_or_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 0 and 1 -----------------------------------------------------
// ----------------- top elements are 0 and 1 -------------------------------------------------

let a = ZERO;
let b = ONE;
let frame = get_or_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 1 and 0 -----------------------------------------------------
// ----------------- top elements are 1 and 0 -------------------------------------------------

let a = ONE;
let b = ZERO;
let frame = get_or_test_frame(a, b);
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ----------------- top elements are 1 and 1 -----------------------------------------------------
// ----------------- top elements are 1 and 1 -------------------------------------------------

let a = ONE;
let b = ONE;
Expand Down
8 changes: 4 additions & 4 deletions air/src/constraints/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub const NUM_GENERAL_CONSTRAINTS: usize = 17;
/// The degrees of constraints in the general stack operations. Each operation being executed
/// either shifts the stack to the left, right or doesn't effect it at all. Therefore, majority
/// of the general transitions of a stack item would be common across the operations and composite
/// flags were introduced to compute the individual stack item transition. A particular item lets say
/// at depth ith in the next stack frame can be transitioned into from ith depth (no shift op) or
/// (i+1)th depth(left shift) or (i-1)th depth(right shift) in the current frame. Therefore, the VM
/// would require only 16 general constraints to encompass all the 16 stack positions.
/// flags were introduced to compute the individual stack item transition. A particular item lets
/// say at depth ith in the next stack frame can be transitioned into from ith depth (no shift op)
/// or (i+1)th depth(left shift) or (i-1)th depth(right shift) in the current frame. Therefore, the
/// VM would require only 16 general constraints to encompass all the 16 stack positions.
/// The last constraint checks if the top element in the stack is a binary or not.
pub const CONSTRAINT_DEGREES: [usize; NUM_GENERAL_CONSTRAINTS] = [
// Each degree are being multiplied with the respective composite flags which are of degree 7.
Expand Down
10 changes: 6 additions & 4 deletions air/src/constraints/stack/op_flags/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ const DEGREE_4_OPCODE_ENDS: usize = DEGREE_4_OPCODE_STARTS + 31;
/// values which helps in reducing the number of field multiplication operations being used in the
/// calculation of the operation flag.
///
/// The operation flag values are computed separately for degree 7 and degree 6 and 4 stack operations.
/// Only one flag will be set to ONE and rest all would be ZERO for an execution trace. It also computes
/// the composite flags using individual stack operation flags for generic stack constraints.
/// The operation flag values are computed separately for degree 7 and degree 6 and 4 stack
/// operations. Only one flag will be set to ONE and rest all would be ZERO for an execution trace.
/// It also computes the composite flags using individual stack operation flags for generic stack
/// constraints.
pub struct OpFlags<E: FieldElement> {
degree7_op_flags: [E; NUM_DEGREE_7_OPS],
degree6_op_flags: [E; NUM_DEGREE_6_OPS],
Expand Down Expand Up @@ -195,7 +196,8 @@ impl<E: FieldElement> OpFlags<E> {

// flag when the items from first point onwards are copied over. It doesn't have noop.
let no_change_1_flag = f0000 - degree7_op_flags[0];
// flag when the items from second point onwards are shifted to the left. It doesn't have assert.
// flag when the items from second point onwards are shifted to the left. It doesn't have
// assert.
let left_change_1_flag = f0100 - degree7_op_flags[32];

// --- computation of the degree 6 operation flags ----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion air/src/constraints/stack/op_flags/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn composite_flags() {
assert_eq!(op_flags.control_flow(), ONE);
assert_eq!(op_flags.top_binary(), ZERO);

// ----------------------------------- left shift -----------------------------------------------
// ----------------------------------- left shift ---------------------------------------------

frame.current_mut()[DECODER_TRACE_OFFSET + IS_LOOP_FLAG_COL_IDX] = ONE;

Expand Down
13 changes: 7 additions & 6 deletions air/src/constraints/stack/overflow/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use vm_core::{Felt, FieldElement, Operation, ONE, ZERO};
fn test_stack_overflow_constraints() {
let expected = [ZERO; NUM_CONSTRAINTS];

// ------------------ right shift operation ----------------------------------------------------
// ------------------ right shift operation ---------------------------------------------------

let depth = 16 + rand_value::<u32>() as u64;
let mut frame = generate_evaluation_frame(Operation::Pad.op_code().into());
Expand All @@ -33,7 +33,7 @@ fn test_stack_overflow_constraints() {
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ------------------ left shift operation- depth 16 ----------------------------------------------------
// ------------------ left shift operation- depth 16 ------------------------------------------

let depth = 16;
let mut frame = generate_evaluation_frame(Operation::Drop.op_code().into());
Expand All @@ -52,7 +52,7 @@ fn test_stack_overflow_constraints() {
let result = get_constraint_evaluation(frame);
assert_eq!(expected, result);

// ------------------ left shift operation- depth 17 ----------------------------------------------------
// ------------------ left shift operation- depth 17 ------------------------------------------

let depth = 17;
let mut frame = generate_evaluation_frame(Operation::Drop.op_code().into());
Expand Down Expand Up @@ -99,9 +99,10 @@ fn test_stack_depth_air() {
// block with a control block opcode.
let mut frame = generate_evaluation_frame(Operation::Split.op_code().into());

// At the start of a control block, the second part of the hasher state gets populated with h2. Therefore, the 7th
// hasher element alone can't be used as a flag if it's the end of a call block, and the stack depth air constraint
// will fail in all control flow operations, which shifts the stack either to the right or left.
// At the start of a control block, the second part of the hasher state gets populated with h2.
// Therefore, the 7th hasher element alone can't be used as a flag if it's the end of a call
// block, and the stack depth air constraint will fail in all control flow operations, which
// shifts the stack either to the right or left.
frame.current_mut()[CLK_COL_IDX] = ZERO;
frame.current_mut()[B0_COL_IDX] = Felt::new(depth);
frame.current_mut()[STACK_TRACE_OFFSET] = ONE;
Expand Down
30 changes: 14 additions & 16 deletions air/src/constraints/stack/stack_manipulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ pub fn enforce_dup_movup_n_constraints<E: FieldElement>(

/// Enforces constraints of the SWAP operation. The SWAP operation swaps the first
/// two elements in the stack. Therefore, the following constraints are enforced:
/// - The first element in the current frame should be equal to the second element in the
/// next frame.
/// - The second element in the current frame should be equal to the first element in the
/// next frame.
/// - The first element in the current frame should be equal to the second element in the next
/// frame.
/// - The second element in the current frame should be equal to the first element in the next
/// frame.
pub fn enforce_swap_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
result: &mut [E],
Expand All @@ -190,17 +190,16 @@ pub fn enforce_swap_constraints<E: FieldElement>(
/// - The SWAPW operation swaps the elements 0,1,2,3 with 4,5,6,7 in the stack.
/// - The SWAPW2 operation swaps the elements 0,1,2,3 with 8,9,10,11 in the stack.
/// - The SWAPW3 operation swaps the elements 0,1,2,3 with 12,13,14,15 in the stack.
/// - The SWAPDW operation swaps the elements 0,1,2,3,4,5,6,7 with 8,9,10,11,12,13,14,15
/// in the stack.
/// - The SWAPDW operation swaps the elements 0,1,2,3,4,5,6,7 with 8,9,10,11,12,13,14,15 in the
/// stack.
///
/// Therefore, the following constraints are enforced:
/// - During any frame, only one of these operation can be present (it is possible that
/// none of these operations are present), therefore, the respective stack item can only
/// transition into certain state and we can use this to combine these transition into
/// one constraints where each transition are weighted by their respective flag. for eg.
/// in the case of SWAPW3 the first item of the stack gets replaced with the 12 items and
/// vice versa, therefore, only SWAPW3 transition will be ONE and rest all flags would be
/// ZERO.
/// - During any frame, only one of these operation can be present (it is possible that none of
/// these operations are present), therefore, the respective stack item can only transition into
/// certain state and we can use this to combine these transition into one constraints where each
/// transition are weighted by their respective flag. for eg. in the case of SWAPW3 the first item
/// of the stack gets replaced with the 12 items and vice versa, therefore, only SWAPW3 transition
/// will be ONE and rest all flags would be ZERO.
#[allow(clippy::needless_range_loop)]
pub fn enforce_swapwx_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
Expand Down Expand Up @@ -274,9 +273,8 @@ pub fn enforce_movdnn_constraints<E: FieldElement>(
/// is 1. The stack remains the same if the top element is 0.
///
/// Therefore, the following constraints are enforced:
/// - The top two elements or elements 1,2,3,4 should be swapped in the case of CSWAP and
/// CSWAPW respectively if the top element is 1, the state remains the same if the top
/// element is 0.
/// - The top two elements or elements 1,2,3,4 should be swapped in the case of CSWAP and CSWAPW
/// respectively if the top element is 1, the state remains the same if the top element is 0.
#[allow(clippy::needless_range_loop)]
pub fn enforce_cswapx_constraints<E: FieldElement>(
frame: &EvaluationFrame<E>,
Expand Down
Loading
Loading