Currently OP MOD is considered nonstandard in the Bitcoin protocol, but we can for example combine OP SHA1 and OP GREATERTHAN to gain a similar effect.


How can we combine OP_SHA1 and OP_GREATERTHAN to calculate modulus? Or in other words, how can we do the following things using bitcoin scripting:

  1. Calculate a mod b with counter c

  2. Start with counter 0, keep adding 1 and stop if OP_GREATERTHAN for b and c returns zero.

  3. Write counter increments a times in clockwise order and modulus is last number.

    Example: 8 mod 4 will result in 1 2 3 0 1 2 3 0 which is zero.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.