Skip to content

Conversation

@crivasr
Copy link
Contributor

@crivasr crivasr commented Aug 19, 2025

The modulo and quotient lookup tables were not large enough to cover the full range of values produced during multiplication. Intermediate results correctly ranged from 0 to 127, but after adding the quotient from division by 16 (maximum value 7), results could reach up to 134.

This caused OP_PICK to sometimes access data out of bounds, leading to one of two issues:

  • An InvalidStackOperation error if the stack had insufficient elements.
  • Incorrect results if unrelated values were present (e.g., in the mulh case).

@crivasr crivasr changed the title fix multiplication in bitcoin script fix multiplication in bitcoin script (VMX-CPU-012, VMX-CPU-013) Aug 20, 2025
@crivasr crivasr changed the base branch from main to dev September 16, 2025 15:15
@jonasmartin jonasmartin merged commit b75ae1d into dev Sep 16, 2025
@crivasr crivasr deleted the multiplication-fix branch October 2, 2025 15:44
@crivasr crivasr restored the multiplication-fix branch October 2, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants