triton_air/
table_column.rs

1//! Enums that convert table column names into `usize` indices. Allows
2//! addressing columns by name rather than their hard-to-remember index.
3
4use std::hash::Hash;
5
6use strum::Display;
7use strum::EnumCount;
8use strum::EnumIter;
9
10use crate::table::AUX_CASCADE_TABLE_START;
11use crate::table::AUX_HASH_TABLE_START;
12use crate::table::AUX_JUMP_STACK_TABLE_START;
13use crate::table::AUX_LOOKUP_TABLE_START;
14use crate::table::AUX_OP_STACK_TABLE_START;
15use crate::table::AUX_PROCESSOR_TABLE_START;
16use crate::table::AUX_PROGRAM_TABLE_START;
17use crate::table::AUX_RAM_TABLE_START;
18use crate::table::AUX_U32_TABLE_START;
19use crate::table::CASCADE_TABLE_START;
20use crate::table::HASH_TABLE_START;
21use crate::table::JUMP_STACK_TABLE_START;
22use crate::table::LOOKUP_TABLE_START;
23use crate::table::OP_STACK_TABLE_START;
24use crate::table::PROCESSOR_TABLE_START;
25use crate::table::PROGRAM_TABLE_START;
26use crate::table::RAM_TABLE_START;
27use crate::table::U32_TABLE_START;
28
29#[repr(usize)]
30#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
31pub enum ProgramMainColumn {
32    /// An instruction's address.
33    Address,
34
35    /// The (opcode of the) instruction.
36    Instruction,
37
38    /// How often an instruction has been executed.
39    LookupMultiplicity,
40
41    /// The index in the vector of length [`Rate`] that is to be absorbed in the
42    /// Sponge in order to compute the program's digest.
43    /// In other words:
44    /// [`Address`] modulo [`Rate`].
45    ///
46    /// [`Address`]: ProgramMainColumn::Address
47    /// [`Rate`]: twenty_first::tip5::RATE
48    IndexInChunk,
49
50    /// The inverse-or-zero of [`Rate`] - 1 - [`IndexInChunk`].
51    /// Helper variable to guarantee [`IndexInChunk`]'s correct transition.
52    ///
53    /// [`IndexInChunk`]: ProgramMainColumn::IndexInChunk
54    /// [`Rate`]: twenty_first::tip5::RATE
55    MaxMinusIndexInChunkInv,
56
57    /// Padding indicator for absorbing the program into the Sponge.
58    IsHashInputPadding,
59
60    /// Padding indicator for rows only required due to the dominating length of
61    /// some other table.
62    IsTablePadding,
63}
64
65#[repr(usize)]
66#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
67pub enum ProgramAuxColumn {
68    /// The server part of the instruction lookup.
69    ///
70    /// The counterpart to [`InstructionLookupClientLogDerivative`][client].
71    ///
72    /// [client]: ProcessorAuxColumn::InstructionLookupClientLogDerivative
73    InstructionLookupServerLogDerivative,
74
75    /// An evaluation argument accumulating [`RATE`][rate] many instructions
76    /// before they are sent using
77    /// [`SendChunkEvalArg`](ProgramAuxColumn::SendChunkRunningEvaluation).
78    /// Resets to zero after each chunk.
79    /// Relevant for program attestation.
80    ///
81    /// [rate]: twenty_first::tip5::RATE
82    PrepareChunkRunningEvaluation,
83
84    /// An evaluation argument over all [`RATE`][rate]-sized chunks of
85    /// instructions, which are prepared in [`PrepareChunkEvalArg`][prep].
86    /// This bus is used for sending those chunks to the Hash Table.
87    /// Relevant for program attestation.
88    ///
89    /// The counterpart to
90    /// [`RcvChunkEvalArg`](HashAuxColumn::ReceiveChunkRunningEvaluation).
91    ///
92    /// [rate]: twenty_first::tip5::RATE
93    /// [prep]: ProgramAuxColumn::PrepareChunkRunningEvaluation
94    SendChunkRunningEvaluation,
95}
96
97#[repr(usize)]
98#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
99pub enum ProcessorMainColumn {
100    CLK,
101    IsPadding,
102    IP,
103    CI,
104    NIA,
105    IB0,
106    IB1,
107    IB2,
108    IB3,
109    IB4,
110    IB5,
111    IB6,
112    JSP,
113    JSO,
114    JSD,
115    ST0,
116    ST1,
117    ST2,
118    ST3,
119    ST4,
120    ST5,
121    ST6,
122    ST7,
123    ST8,
124    ST9,
125    ST10,
126    ST11,
127    ST12,
128    ST13,
129    ST14,
130    ST15,
131    OpStackPointer,
132    HV0,
133    HV1,
134    HV2,
135    HV3,
136    HV4,
137    HV5,
138    /// The number of clock jump differences of magnitude `CLK` in all
139    /// memory-like tables.
140    ClockJumpDifferenceLookupMultiplicity,
141}
142
143#[repr(usize)]
144#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
145pub enum ProcessorAuxColumn {
146    InputTableEvalArg,
147    OutputTableEvalArg,
148    InstructionLookupClientLogDerivative,
149    OpStackTablePermArg,
150    RamTablePermArg,
151    JumpStackTablePermArg,
152
153    /// For copying the hash function's input to the hash coprocessor.
154    HashInputEvalArg,
155    /// For copying the hash digest from the hash coprocessor.
156    HashDigestEvalArg,
157    /// For copying the RATE next to-be-absorbed to the hash coprocessor and the
158    /// RATE squeezed elements from the hash coprocessor, depending on the
159    /// executed instruction.
160    SpongeEvalArg,
161
162    /// The (running sum of the) logarithmic derivative for the Lookup Argument
163    /// with the U32 Table.
164    U32LookupClientLogDerivative,
165
166    /// The (running sum of the) logarithmic derivative for the clock jump
167    /// difference Lookup Argument with the memory-like tables.
168    ClockJumpDifferenceLookupServerLogDerivative,
169}
170
171#[repr(usize)]
172#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
173pub enum OpStackMainColumn {
174    CLK,
175    IB1ShrinkStack,
176    StackPointer,
177    FirstUnderflowElement,
178}
179
180#[repr(usize)]
181#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
182pub enum OpStackAuxColumn {
183    RunningProductPermArg,
184    /// The (running sum of the) logarithmic derivative for the clock jump
185    /// difference Lookup Argument with the Processor Table.
186    ClockJumpDifferenceLookupClientLogDerivative,
187}
188
189#[repr(usize)]
190#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
191pub enum RamMainColumn {
192    CLK,
193
194    /// Is [`INSTRUCTION_TYPE_READ`] for instruction `read_mem` and
195    /// [`INSTRUCTION_TYPE_WRITE`] for instruction `write_mem`. For padding
196    /// rows, this is set to [`PADDING_INDICATOR`].
197    ///
198    /// [`INSTRUCTION_TYPE_READ`]: crate::table::ram::INSTRUCTION_TYPE_READ
199    /// [`INSTRUCTION_TYPE_WRITE`]: crate::table::ram::INSTRUCTION_TYPE_WRITE
200    /// [`PADDING_INDICATOR`]: crate::table::ram::PADDING_INDICATOR
201    InstructionType,
202    RamPointer,
203    RamValue,
204    InverseOfRampDifference,
205    BezoutCoefficientPolynomialCoefficient0,
206    BezoutCoefficientPolynomialCoefficient1,
207}
208
209#[repr(usize)]
210#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
211pub enum RamAuxColumn {
212    RunningProductOfRAMP,
213    FormalDerivative,
214    BezoutCoefficient0,
215    BezoutCoefficient1,
216    RunningProductPermArg,
217    /// The (running sum of the) logarithmic derivative for the clock jump
218    /// difference Lookup Argument with the Processor Table.
219    ClockJumpDifferenceLookupClientLogDerivative,
220}
221
222#[repr(usize)]
223#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
224pub enum JumpStackMainColumn {
225    CLK,
226    CI,
227    JSP,
228    JSO,
229    JSD,
230}
231
232#[repr(usize)]
233#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
234pub enum JumpStackAuxColumn {
235    RunningProductPermArg,
236    /// The (running sum of the) logarithmic derivative for the clock jump
237    /// difference Lookup Argument with the Processor Table.
238    ClockJumpDifferenceLookupClientLogDerivative,
239}
240
241#[repr(usize)]
242#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
243pub enum HashMainColumn {
244    /// The indicator for the [`HashTableMode`][mode].
245    ///
246    /// [mode]: crate::table::hash::HashTableMode
247    Mode,
248
249    /// The current instruction. Only relevant for [`Mode`][mode]
250    /// [`Sponge`][mode_sponge] in order to distinguish between the
251    /// different Sponge instructions.
252    ///
253    /// [mode]: HashMainColumn::Mode
254    /// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
255    CI,
256
257    /// The number of the current round in the permutation. The round number
258    /// evolves as
259    /// - 0 → 1 → 2 → 3 → 4 → 5 (→ 0) in [`Mode`][mode]s
260    ///   [`ProgramHashing`][mode_prog_hash], [`Sponge`][mode_sponge] and
261    ///   [`Hash`][mode_hash],
262    /// - 0 → 0 in [`Mode`][mode] [`Sponge`][mode_sponge] if the current
263    ///   instruction [`CI`][ci] is `sponge_init`, as an exception to above
264    ///   rule, and
265    /// - 0 → 0 in [`Mode`][mode] [`Pad`][mode_pad].
266    ///
267    /// [ci]: HashMainColumn::CI
268    /// [mode]: HashMainColumn::Mode
269    /// [mode_prog_hash]: crate::table::hash::HashTableMode::ProgramHashing
270    /// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
271    /// [mode_hash]: crate::table::hash::HashTableMode::Hash
272    /// [mode_pad]: crate::table::hash::HashTableMode::Pad
273    RoundNumber,
274
275    State0HighestLkIn,
276    State0MidHighLkIn,
277    State0MidLowLkIn,
278    State0LowestLkIn,
279    State1HighestLkIn,
280    State1MidHighLkIn,
281    State1MidLowLkIn,
282    State1LowestLkIn,
283    State2HighestLkIn,
284    State2MidHighLkIn,
285    State2MidLowLkIn,
286    State2LowestLkIn,
287    State3HighestLkIn,
288    State3MidHighLkIn,
289    State3MidLowLkIn,
290    State3LowestLkIn,
291    State0HighestLkOut,
292    State0MidHighLkOut,
293    State0MidLowLkOut,
294    State0LowestLkOut,
295    State1HighestLkOut,
296    State1MidHighLkOut,
297    State1MidLowLkOut,
298    State1LowestLkOut,
299    State2HighestLkOut,
300    State2MidHighLkOut,
301    State2MidLowLkOut,
302    State2LowestLkOut,
303    State3HighestLkOut,
304    State3MidHighLkOut,
305    State3MidLowLkOut,
306    State3LowestLkOut,
307    State4,
308    State5,
309    State6,
310    State7,
311    State8,
312    State9,
313    State10,
314    State11,
315    State12,
316    State13,
317    State14,
318    State15,
319
320    State0Inv,
321    State1Inv,
322    State2Inv,
323    State3Inv,
324
325    Constant0,
326    Constant1,
327    Constant2,
328    Constant3,
329    Constant4,
330    Constant5,
331    Constant6,
332    Constant7,
333    Constant8,
334    Constant9,
335    Constant10,
336    Constant11,
337    Constant12,
338    Constant13,
339    Constant14,
340    Constant15,
341}
342
343#[repr(usize)]
344#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
345pub enum HashAuxColumn {
346    /// The evaluation argument corresponding to receiving instructions in
347    /// chunks of size [`RATE`][rate]. The chunks are hashed in Sponge mode.
348    /// This allows program attestation.
349    ///
350    /// The counterpart to
351    /// [`SendChunkEvalArg`](ProgramAuxColumn::SendChunkRunningEvaluation).
352    ///
353    /// [rate]: twenty_first::tip5::RATE
354    ReceiveChunkRunningEvaluation,
355
356    HashInputRunningEvaluation,
357    HashDigestRunningEvaluation,
358
359    SpongeRunningEvaluation,
360
361    CascadeState0HighestClientLogDerivative,
362    CascadeState0MidHighClientLogDerivative,
363    CascadeState0MidLowClientLogDerivative,
364    CascadeState0LowestClientLogDerivative,
365
366    CascadeState1HighestClientLogDerivative,
367    CascadeState1MidHighClientLogDerivative,
368    CascadeState1MidLowClientLogDerivative,
369    CascadeState1LowestClientLogDerivative,
370
371    CascadeState2HighestClientLogDerivative,
372    CascadeState2MidHighClientLogDerivative,
373    CascadeState2MidLowClientLogDerivative,
374    CascadeState2LowestClientLogDerivative,
375
376    CascadeState3HighestClientLogDerivative,
377    CascadeState3MidHighClientLogDerivative,
378    CascadeState3MidLowClientLogDerivative,
379    CascadeState3LowestClientLogDerivative,
380}
381
382#[repr(usize)]
383#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
384pub enum CascadeMainColumn {
385    /// Indicator for padding rows.
386    IsPadding,
387
388    /// The more significant bits of the lookup input.
389    LookInHi,
390
391    /// The less significant bits of the lookup input.
392    LookInLo,
393
394    /// The more significant bits of the lookup output.
395    LookOutHi,
396
397    /// The less significant bits of the lookup output.
398    LookOutLo,
399
400    /// The number of times the S-Box is evaluated, _i.e._, the value is looked
401    /// up.
402    LookupMultiplicity,
403}
404
405#[repr(usize)]
406#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
407pub enum CascadeAuxColumn {
408    /// The (running sum of the) logarithmic derivative for the Lookup Argument
409    /// with the Hash Table. In every row, the sum accumulates
410    /// `LookupMultiplicity / (X - Combo)` where `X` is a verifier-supplied
411    /// challenge and `Combo` is the weighted sum of
412    /// - `2^8·LookInHi + LookInLo`, and
413    /// - `2^8·LookOutHi + LookOutLo` with weights supplied by the verifier.
414    HashTableServerLogDerivative,
415
416    /// The (running sum of the) logarithmic derivative for the Lookup Argument
417    /// with the Lookup Table. In every row, accumulates the two summands
418    /// - `1 / combo_hi` where `combo_hi` is the verifier-weighted combination
419    ///   of `LookInHi` and `LookOutHi`, and
420    /// - `1 / combo_lo` where `combo_lo` is the verifier-weighted combination
421    ///   of `LookInLo` and `LookOutLo`.
422    LookupTableClientLogDerivative,
423}
424
425#[repr(usize)]
426#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
427pub enum LookupMainColumn {
428    /// Indicator for padding rows.
429    IsPadding,
430
431    /// The lookup input.
432    LookIn,
433
434    /// The lookup output.
435    LookOut,
436
437    /// The number of times the value is looked up.
438    LookupMultiplicity,
439}
440
441#[repr(usize)]
442#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
443pub enum LookupAuxColumn {
444    /// The (running sum of the) logarithmic derivative for the Lookup Argument
445    /// with the Cascade Table. In every row, accumulates the summand
446    /// `LookupMultiplicity / Combo` where `Combo` is the verifier-weighted
447    /// combination of `LookIn` and `LookOut`.
448    CascadeTableServerLogDerivative,
449
450    /// The running sum for the public evaluation argument of the Lookup Table.
451    /// In every row, accumulates `LookOut`.
452    PublicEvaluationArgument,
453}
454
455#[repr(usize)]
456#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
457pub enum U32MainColumn {
458    /// Marks the beginning of an independent section within the U32 table.
459    CopyFlag,
460
461    /// The number of bits that LHS and RHS have already been shifted by.
462    Bits,
463
464    /// The inverse-or-zero of the difference between
465    /// 1. the first disallowed number of bits to shift LHS and RHS by, _i.e.,_
466    ///    33, and
467    /// 2. the number of bits that LHS and RHS have already been shifted by.
468    BitsMinus33Inv,
469
470    /// Current Instruction, the instruction the processor is currently
471    /// executing.
472    CI,
473
474    /// Left-hand side of the operation.
475    LHS,
476
477    /// The inverse-or-zero of LHS. Needed to check whether `LHS` is unequal to
478    /// 0.
479    LhsInv,
480
481    /// Right-hand side of the operation.
482    RHS,
483
484    /// The inverse-or-zero of RHS. Needed to check whether `RHS` is unequal to
485    /// 0.
486    RhsInv,
487
488    /// The result (or intermediate result) of the instruction requested by the
489    /// processor.
490    Result,
491
492    /// The number of times the processor has executed the current instruction
493    /// with the same arguments.
494    LookupMultiplicity,
495}
496
497#[repr(usize)]
498#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
499pub enum U32AuxColumn {
500    /// The (running sum of the) logarithmic derivative for the Lookup Argument
501    /// with the Processor Table.
502    LookupServerLogDerivative,
503}
504
505/// A trait for the columns of the master main table. This trait is implemented
506/// for all enums relating to the main tables. This trait provides two methods:
507/// - one to get the index of the column in the “local” main table, _i.e., not
508///   the master base table, and
509/// - one to get the index of the column in the master main table.
510pub trait MasterMainColumn {
511    /// The index of the column in the “local” main table, _i.e., not the master
512    /// base table.
513    fn main_index(&self) -> usize;
514
515    /// The index of the column in the master main table.
516    fn master_main_index(&self) -> usize;
517}
518
519impl MasterMainColumn for ProgramMainColumn {
520    #[inline]
521    fn main_index(&self) -> usize {
522        (*self) as usize
523    }
524
525    #[inline]
526    fn master_main_index(&self) -> usize {
527        PROGRAM_TABLE_START + self.main_index()
528    }
529}
530
531impl MasterMainColumn for ProcessorMainColumn {
532    #[inline]
533    fn main_index(&self) -> usize {
534        (*self) as usize
535    }
536
537    #[inline]
538    fn master_main_index(&self) -> usize {
539        PROCESSOR_TABLE_START + self.main_index()
540    }
541}
542
543impl MasterMainColumn for OpStackMainColumn {
544    #[inline]
545    fn main_index(&self) -> usize {
546        (*self) as usize
547    }
548
549    #[inline]
550    fn master_main_index(&self) -> usize {
551        OP_STACK_TABLE_START + self.main_index()
552    }
553}
554
555impl MasterMainColumn for RamMainColumn {
556    #[inline]
557    fn main_index(&self) -> usize {
558        (*self) as usize
559    }
560
561    #[inline]
562    fn master_main_index(&self) -> usize {
563        RAM_TABLE_START + self.main_index()
564    }
565}
566
567impl MasterMainColumn for JumpStackMainColumn {
568    #[inline]
569    fn main_index(&self) -> usize {
570        (*self) as usize
571    }
572
573    #[inline]
574    fn master_main_index(&self) -> usize {
575        JUMP_STACK_TABLE_START + self.main_index()
576    }
577}
578
579impl MasterMainColumn for HashMainColumn {
580    #[inline]
581    fn main_index(&self) -> usize {
582        (*self) as usize
583    }
584
585    #[inline]
586    fn master_main_index(&self) -> usize {
587        HASH_TABLE_START + self.main_index()
588    }
589}
590
591impl MasterMainColumn for CascadeMainColumn {
592    #[inline]
593    fn main_index(&self) -> usize {
594        (*self) as usize
595    }
596
597    #[inline]
598    fn master_main_index(&self) -> usize {
599        CASCADE_TABLE_START + self.main_index()
600    }
601}
602
603impl MasterMainColumn for LookupMainColumn {
604    #[inline]
605    fn main_index(&self) -> usize {
606        (*self) as usize
607    }
608
609    #[inline]
610    fn master_main_index(&self) -> usize {
611        LOOKUP_TABLE_START + self.main_index()
612    }
613}
614
615impl MasterMainColumn for U32MainColumn {
616    #[inline]
617    fn main_index(&self) -> usize {
618        (*self) as usize
619    }
620
621    #[inline]
622    fn master_main_index(&self) -> usize {
623        U32_TABLE_START + self.main_index()
624    }
625}
626
627/// A trait for the columns in the master auxiliary table. This trait is
628/// implemented for all enums relating to the auxiliary tables. The trait
629/// provides two methods:
630/// - one to get the index of the column in the “local” auxiliary table, _i.e._,
631///   not the master auxiliary table, and
632/// - one to get the index of the column in the master auxiliary table.
633pub trait MasterAuxColumn {
634    /// The index of the column in the “local” auxiliary table, _i.e._, not the
635    /// master extension table.
636    fn aux_index(&self) -> usize;
637
638    /// The index of the column in the master auxiliary table.
639    fn master_aux_index(&self) -> usize;
640}
641
642impl MasterAuxColumn for ProgramAuxColumn {
643    #[inline]
644    fn aux_index(&self) -> usize {
645        (*self) as usize
646    }
647
648    #[inline]
649    fn master_aux_index(&self) -> usize {
650        AUX_PROGRAM_TABLE_START + self.aux_index()
651    }
652}
653
654impl MasterAuxColumn for ProcessorAuxColumn {
655    #[inline]
656    fn aux_index(&self) -> usize {
657        (*self) as usize
658    }
659
660    #[inline]
661    fn master_aux_index(&self) -> usize {
662        AUX_PROCESSOR_TABLE_START + self.aux_index()
663    }
664}
665
666impl MasterAuxColumn for OpStackAuxColumn {
667    #[inline]
668    fn aux_index(&self) -> usize {
669        (*self) as usize
670    }
671
672    #[inline]
673    fn master_aux_index(&self) -> usize {
674        AUX_OP_STACK_TABLE_START + self.aux_index()
675    }
676}
677
678impl MasterAuxColumn for RamAuxColumn {
679    #[inline]
680    fn aux_index(&self) -> usize {
681        (*self) as usize
682    }
683
684    #[inline]
685    fn master_aux_index(&self) -> usize {
686        AUX_RAM_TABLE_START + self.aux_index()
687    }
688}
689
690impl MasterAuxColumn for JumpStackAuxColumn {
691    #[inline]
692    fn aux_index(&self) -> usize {
693        (*self) as usize
694    }
695
696    #[inline]
697    fn master_aux_index(&self) -> usize {
698        AUX_JUMP_STACK_TABLE_START + self.aux_index()
699    }
700}
701
702impl MasterAuxColumn for HashAuxColumn {
703    #[inline]
704    fn aux_index(&self) -> usize {
705        (*self) as usize
706    }
707
708    #[inline]
709    fn master_aux_index(&self) -> usize {
710        AUX_HASH_TABLE_START + self.aux_index()
711    }
712}
713
714impl MasterAuxColumn for CascadeAuxColumn {
715    #[inline]
716    fn aux_index(&self) -> usize {
717        (*self) as usize
718    }
719
720    #[inline]
721    fn master_aux_index(&self) -> usize {
722        AUX_CASCADE_TABLE_START + self.aux_index()
723    }
724}
725
726impl MasterAuxColumn for LookupAuxColumn {
727    #[inline]
728    fn aux_index(&self) -> usize {
729        (*self) as usize
730    }
731
732    #[inline]
733    fn master_aux_index(&self) -> usize {
734        AUX_LOOKUP_TABLE_START + self.aux_index()
735    }
736}
737
738impl MasterAuxColumn for U32AuxColumn {
739    #[inline]
740    fn aux_index(&self) -> usize {
741        (*self) as usize
742    }
743
744    #[inline]
745    fn master_aux_index(&self) -> usize {
746        AUX_U32_TABLE_START + self.aux_index()
747    }
748}
749
750#[cfg(test)]
751#[cfg_attr(coverage_nightly, coverage(off))]
752mod tests {
753    use strum::IntoEnumIterator;
754
755    use super::*;
756
757    #[test]
758    fn master_main_table_is_contiguous() {
759        let mut expected_column_index = 0;
760        for column in ProgramMainColumn::iter() {
761            assert_eq!(expected_column_index, column.master_main_index());
762            expected_column_index += 1;
763        }
764        for column in ProcessorMainColumn::iter() {
765            assert_eq!(expected_column_index, column.master_main_index());
766            expected_column_index += 1;
767        }
768        for column in OpStackMainColumn::iter() {
769            assert_eq!(expected_column_index, column.master_main_index());
770            expected_column_index += 1;
771        }
772        for column in RamMainColumn::iter() {
773            assert_eq!(expected_column_index, column.master_main_index());
774            expected_column_index += 1;
775        }
776        for column in JumpStackMainColumn::iter() {
777            assert_eq!(expected_column_index, column.master_main_index());
778            expected_column_index += 1;
779        }
780        for column in HashMainColumn::iter() {
781            assert_eq!(expected_column_index, column.master_main_index());
782            expected_column_index += 1;
783        }
784        for column in CascadeMainColumn::iter() {
785            assert_eq!(expected_column_index, column.master_main_index());
786            expected_column_index += 1;
787        }
788        for column in LookupMainColumn::iter() {
789            assert_eq!(expected_column_index, column.master_main_index());
790            expected_column_index += 1;
791        }
792        for column in U32MainColumn::iter() {
793            assert_eq!(expected_column_index, column.master_main_index());
794            expected_column_index += 1;
795        }
796    }
797
798    #[test]
799    fn master_aux_table_is_contiguous() {
800        let mut expected_column_index = 0;
801        for column in ProgramAuxColumn::iter() {
802            assert_eq!(expected_column_index, column.master_aux_index());
803            expected_column_index += 1;
804        }
805        for column in ProcessorAuxColumn::iter() {
806            assert_eq!(expected_column_index, column.master_aux_index());
807            expected_column_index += 1;
808        }
809        for column in OpStackAuxColumn::iter() {
810            assert_eq!(expected_column_index, column.master_aux_index());
811            expected_column_index += 1;
812        }
813        for column in RamAuxColumn::iter() {
814            assert_eq!(expected_column_index, column.master_aux_index());
815            expected_column_index += 1;
816        }
817        for column in JumpStackAuxColumn::iter() {
818            assert_eq!(expected_column_index, column.master_aux_index());
819            expected_column_index += 1;
820        }
821        for column in HashAuxColumn::iter() {
822            assert_eq!(expected_column_index, column.master_aux_index());
823            expected_column_index += 1;
824        }
825        for column in CascadeAuxColumn::iter() {
826            assert_eq!(expected_column_index, column.master_aux_index());
827            expected_column_index += 1;
828        }
829        for column in LookupAuxColumn::iter() {
830            assert_eq!(expected_column_index, column.master_aux_index());
831            expected_column_index += 1;
832        }
833        for column in U32AuxColumn::iter() {
834            assert_eq!(expected_column_index, column.master_aux_index());
835            expected_column_index += 1;
836        }
837    }
838}