TritonVM / triton-vm

Triton is a virtual machine that comes with Algebraic Execution Tables (AET) and Arithmetic Intermediate Representations (AIR) for use in combination with a STARK proof system.
https://triton-vm.org
Apache License 2.0
223 stars 35 forks source link

Make `ConstraintType` enum public #263

Closed Sword-Smith closed 1 month ago

Sword-Smith commented 2 months ago

I'm writing some code in tasm-lib where I could use the ConstraintType enum for a convenient closure. As it looks now, I have to define a local enum type which is just a copy of ConstraintType. I guess I could also use a derivation of EnumCount on the ConstraintType.

I just wrote this code:

        #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, EnumCount)]
        enum ConstraintType {
            Initial,
            Consistency,
            Transition,
            Terminal,
        }

        let zerofier_inverse_pointer = library.kmalloc(
            (EXTENSION_DEGREE * ConstraintType::COUNT)
                .try_into()
                .unwrap(),
        );

        let zerofier_write_address = |x: ConstraintType| {
            zerofier_inverse_pointer
                + BFieldElement::new((EXTENSION_DEGREE * x as usize).try_into().unwrap())
        };