rust-simplicity icon indicating copy to clipboard operation
rust-simplicity copied to clipboard

Reading / writing values from / to frames is broken

Open uncomputable opened this issue 1 year ago • 1 comments

The representation of a left value left(a): A + B is [0] * [?]^padL(A,B) * representation(a, A). The representation of a right value right(b): A + B is [1] * [?]^padR(A,B) * representation(b, B).

Neither the read method nor the write method handle this.

I think this remained undetected because we never initialize the Bit Machine with input values, nor do we ever read output values from the final output frame.

uncomputable avatar Feb 14 '24 09:02 uncomputable

To clarify, it's the read_value and write_value methods that are broken -- which indeed, are only used when providing programs with inputs or outputs.

I'm not terribly surprised these methods are broken. You're right that they've basically never been used and I guess there aren't very good tests since this predates all the ConstructNode/miniscript/text representation stuff. Sorry.

apoelstra avatar Feb 14 '24 14:02 apoelstra