-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Lines 251 to 255 in 027b422
| <tr> | |
| <td>(<em>X</em> and <em>Y</em>) or <em>Z</em></td> | |
| <td><code>andor(<em>X</em>,<em>Y</em>,<em>Z</em>)</code></td> | |
| <td><samp><em>[X]</em> NOTIF <em>[Z]</em> ELSE <em>[Y]</em> ENDIF</samp></td> | |
| </tr> |
For andor(X,Y,Z) the semantics is listed as (X and Y) or Z, while the code [X] NOTIF [Z] ELSE [Y] ENDIF when applied to the truth table for the three variables does not correspond to the truth table that results from (X and Y) or Z expression.
This can be shown with the following script (using python-bitcoinlib):
from bitcoin.core import *
from bitcoin.core.script import *
from bitcoin.core.scripteval import *
print(f'X Y Z | E A')
print(f'-----------')
for X in (0, 1):
for Y in (0, 1):
for Z in (0, 1):
script = CScript([X, OP_NOTIF, Z, OP_ELSE, Y, OP_ENDIF])
stack=[]
EvalScript(stack, script, CTransaction(), 0)
expected = (X and Y) or Z
actual = int(bool(stack[0]))
print(f'{X} {Y} {Z} | {expected} {actual}')the output:
X Y Z | E A
-----------
0 0 0 | 0 0
0 0 1 | 1 1
0 1 0 | 0 0
0 1 1 | 1 1
1 0 0 | 0 0
1 0 1 | 1 0
1 1 0 | 1 1
1 1 1 | 1 1
We can see that for X=1 Y=0 Z=1 the result of (X and Y) or Z does not correspond to the result of evaluating the script.
Either the logical expression in the 'Semantics' column has to be (X or Z) and ((not X) or Y), or the script in the Bitcoin script column has to be changed to have the semantics of (X and Y) or Z
jachiang
Metadata
Metadata
Assignees
Labels
No labels