jonasnick / GreatRSI

Great Restored Script Interpreter
6 stars 2 forks source link

XOR script implemention inconsistent with satoshi #3

Open ajtowns opened 3 days ago

ajtowns commented 3 days ago

https://github.com/jonasnick/GreatRSI/blob/664be9d7f0de4df5c56e91c5a1f8c13ccde12eec/GreatRSI/Script.lean#L350

I think this is inconsistent with Satoshi's code:

https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/script.cpp#L464

which extends the shorter stack element with 0-bytes before doing AND/OR/XOR operations. This affects the behaviour of the test case in Winternitz.ChainTest where the randomization values are short.

I think the GSR spec in https://github.com/rustyrussell/bips/pull/1 is consistent with Satoshi's code, though I find it a bit confusing to read.

ajtowns commented 3 days ago

Oh, or I'm completely wrong, and the OP code is fine, it's just ByteArray.xor that's inconsistent?