# Variable length moduli in evm384 ## Ideas ### Option 1 Determine the modulus size based on counting completely empty limbs in the modulus (64-bit limbs) ### Option 2 Have different opcodes for different modulus sizes ### Option 3 Supply a modulus size as an argument The best approach here seems to be to allow a multiple of 64-bits of modulus sizes up to the maximum supported by the opcode, i.e. mulmodmont384 would be able to work with 64, 128, 192, 256, 320, and 384-bit moduli. Encoding could be a single 8-bit value `limb_count` after `r_inv`. `limb_count` would equal to number of limbs - 1. The gas cost of this opcode could be set the worst case (384-bit) or have a step function. Q: what happens when top limbs are dirty? Ignored? Error? Q: are 64/128/192/256/320/384 all useful? Are any non-multiple-of-64 a needed/useful modulus? ### Option 4 Option 3, but `limb_count` would also determine the memory width occupied by each argument. ### Option 5 Option 4, but without any cap on `limb_count`. ## Implementation/Details