1use 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 Address,
34
35 Instruction,
37
38 LookupMultiplicity,
40
41 IndexInChunk,
49
50 MaxMinusIndexInChunkInv,
56
57 IsHashInputPadding,
59
60 IsTablePadding,
63}
64
65#[repr(usize)]
66#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
67pub enum ProgramAuxColumn {
68 InstructionLookupServerLogDerivative,
74
75 PrepareChunkRunningEvaluation,
83
84 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 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 HashInputEvalArg,
155 HashDigestEvalArg,
157 SpongeEvalArg,
161
162 U32LookupClientLogDerivative,
165
166 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 ClockJumpDifferenceLookupClientLogDerivative,
187}
188
189#[repr(usize)]
190#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
191pub enum RamMainColumn {
192 CLK,
193
194 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 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 ClockJumpDifferenceLookupClientLogDerivative,
239}
240
241#[repr(usize)]
242#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
243pub enum HashMainColumn {
244 Mode,
248
249 CI,
256
257 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 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 IsPadding,
387
388 LookInHi,
390
391 LookInLo,
393
394 LookOutHi,
396
397 LookOutLo,
399
400 LookupMultiplicity,
403}
404
405#[repr(usize)]
406#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
407pub enum CascadeAuxColumn {
408 HashTableServerLogDerivative,
415
416 LookupTableClientLogDerivative,
423}
424
425#[repr(usize)]
426#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
427pub enum LookupMainColumn {
428 IsPadding,
430
431 LookIn,
433
434 LookOut,
436
437 LookupMultiplicity,
439}
440
441#[repr(usize)]
442#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
443pub enum LookupAuxColumn {
444 CascadeTableServerLogDerivative,
449
450 PublicEvaluationArgument,
453}
454
455#[repr(usize)]
456#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
457pub enum U32MainColumn {
458 CopyFlag,
460
461 Bits,
463
464 BitsMinus33Inv,
469
470 CI,
473
474 LHS,
476
477 LhsInv,
480
481 RHS,
483
484 RhsInv,
487
488 Result,
491
492 LookupMultiplicity,
495}
496
497#[repr(usize)]
498#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter)]
499pub enum U32AuxColumn {
500 LookupServerLogDerivative,
503}
504
505pub trait MasterMainColumn {
511 fn main_index(&self) -> usize;
514
515 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
627pub trait MasterAuxColumn {
634 fn aux_index(&self) -> usize;
637
638 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}