Consensys/corset

`Option::unwrap()` crash for `byte@prove` in Perspective

Opened this issue · 1 comments

(see also #185)

Minimal test for reproduction:

(module test)
(defcolumns (P1 :binary@prove) (P2 :binary@prove))
(defperspective p1 P1 ((A :byte@prove)))
(defperspective p2 P2 ((B :byte@prove)))
(defconstraint c1 (:perspective p1) (eq! A 10))

Then the command corset wizard-iop test.lisp gives:

thread 'main' panicked at src/exporters/wizardiop.rs:51:44:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Observe that, if say B is marked only :byte then we get this output:

test__A_xor_B := build.RegisterCommit("test.A_xor_B", build.Settings.Traces.Test)
test__P1 := build.RegisterCommit("test.P1", build.Settings.Traces.Test)
test__P2 := build.RegisterCommit("test.P2", build.Settings.Traces.Test)

build.Range("test_a_arbitrary", test__A_xor_B, 256)
build.GlobalConstraint("test.P1-binarity", test__P1.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__P1.AsVariable())))
build.GlobalConstraint("test.P2-binarity", test__P2.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__P2.AsVariable())))
build.GlobalConstraint("test.c1", test__P1.AsVariable().Mul(test__A_xor_B.AsVariable().Sub(symbolic.NewConstant("10"))))

Curious, though its presumably arising because its trying to create two occurrences of build.Range("test_a_arbitrary", test__A_xor_B, 256)

though its presumably arising because its trying to create two occurrences of build.Range("test_a_arbitrary", test__A_xor_B, 256)

That's because it's currently iterating over columns, whereas it should iterate over registers :/