I liked the ideas in that article. Dealing only with non-negative numbers might simplify some things.
Also removing “normalization” from LSHIFT and RSHIFT is the right thing - Elements implementations remove leading zeroes, and coupled with sign bit that is not actually considered after the shift, it makes modelling these opcodes with Z3 needlessly complex, and also normalization can introduce malleability: 5 LSHIFT
can take 0x01, 0x0100, 0x010000 with the same result.
Relying on __uint128_t
support in GCC and clang is a bit iffy… Would that mean that other compilers will be somehow discouraged ?
I think there’s still need for a way to easily convert to fixed-with numbers. Maybe a generic opcode that would take number of bytes, and zero-pads or truncates if necessary ? Pobably truncation should succeed only if removed bytes are all zero, and script should fail otherwise
For example, 4 FIXNUM
would make LE32 from the argument, 8 FIXNUM
will make LE64, 32 FIXNUM
will make a 256-bit number