Skip to content

Commit d456013

Browse files
committed
Witness caching fix and uninit input check fix
1 parent 753431d commit d456013

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/ecCircuits.ml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ module TestBack : CBackend = struct
348348
b
349349
and doit_r (n: C.node_r) : bool =
350350
match n with
351-
| C.Input (-1, -1) -> false
351+
| C.Input (-1, -1) -> true
352352
| C.Input _
353-
| C.False -> true
353+
| C.False -> false
354354
| C.And (n1, n2) -> (doit n1) || (doit n2)
355355
in
356356
fun b -> doit b
@@ -1298,7 +1298,14 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
12981298
assert (w = Backend.size_of_reg bs);
12991299
`CArray (Backend.insert r (pos * w) bs, w),
13001300
merge_inputs inps cinps
1301-
with Invalid_argument _ -> assert false
1301+
with
1302+
Invalid_argument _ -> assert false
1303+
| Assert_failure e ->
1304+
Format.eprintf "Array set size mismatch arr[%d (bits)@%d (block size)], w@%d@."
1305+
(Backend.size_of_reg r)
1306+
w
1307+
(Backend.size_of_reg bs);
1308+
raise (Assert_failure e)
13021309

13031310
(* FIXME: review this functiono | FIXME: Not axiomatized in QFABV.ec file *)
13041311
let array_oflist (circs : circuit list) (dfl: circuit) (len: int) : circuit =
@@ -1342,7 +1349,7 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
13421349
| [ `Circuit dfl; `List cs ] -> array_oflist cs dfl size
13431350
| _ -> assert false
13441351
end
1345-
| (arr, `Set) -> begin match args with
1352+
| (_arr, `Set) -> begin match args with
13461353
| [ `Circuit ((`CArray _, _) as arr);
13471354
`Constant i;
13481355
`Circuit ((`CBitstring _, _) as bs) ] ->
@@ -1917,6 +1924,11 @@ let circuit_of_form
19171924
hyps, cache_get cache idn
19181925
| Fop (pth, _) ->
19191926
begin
1927+
if pth = EcCoreLib.CI_Witness.p_witness then
1928+
(Format.eprintf "Assigning witness to var of type %a@."
1929+
EcPrinting.(pp_type (PPEnv.ofenv env)) f_.f_ty;
1930+
hyps, circuit_uninit env (f_.f_ty))
1931+
else
19201932
match Mp.find_opt pth !op_cache with
19211933
| Some op ->
19221934
hyps, op
@@ -1930,6 +1942,7 @@ let circuit_of_form
19301942
| OB_oper (Some (OP_Plain f)) ->
19311943
doit cache hyps f
19321944
| _ when pth = EcCoreLib.CI_Witness.p_witness ->
1945+
assert false;
19331946
hyps, circuit_uninit env (f_.f_ty)
19341947
| _ ->
19351948
begin match EcFol.op_kind (destr_op f_ |> fst) with
@@ -2040,7 +2053,9 @@ let circuit_of_form
20402053
in
20412054
let v = match pstate_get_opt pstate v with
20422055
| Some v -> v
2043-
| None -> circuit_uninit env f_.f_ty (* Allow uninitialized program variables *)
2056+
| None ->
2057+
Format.eprintf "Assigning unassigned program variable %a of type %a@." EcPrinting.(pp_pv (PPEnv.ofenv env)) pv EcPrinting.(pp_type (PPEnv.ofenv env)) f_.f_ty;
2058+
circuit_uninit env f_.f_ty (* Allow uninitialized program variables *)
20442059
in
20452060
hyps, v
20462061
| Fglob (id, mem) -> raise (CircError "glob not supported")

0 commit comments

Comments
 (0)