@@ -209,6 +209,7 @@ module type CircuitInterface = sig
209209 val decompose : int -> int -> cbitstring cfun -> (cbitstring cfun ) list * (int * int )
210210 val permute : int -> (int -> int ) -> cbitstring cfun -> cbitstring cfun
211211 val align_inputs : circuit -> (int * int ) option list -> circuit
212+ val circuit_slice : circuit -> int -> int -> circuit
212213
213214 (* Wraps the backend call to deal with args/inputs *)
214215 module CircuitSpec : sig
@@ -1621,6 +1622,21 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
16211622 | `CTuple (r , ws ) -> (`CTuple (Backend. applys aligner r, ws), inps)
16221623 | `CBool b -> (`CBool (Backend. apply aligner b), inps)
16231624
1625+ let circuit_slice ((c , inps ): circuit ) (sz : width ) (offset : int ) =
1626+ match c with
1627+ | `CArray (r , w ) when sz mod w = 0 && offset mod w = 0 -> `CArray (Backend. slice r offset sz, w), inps
1628+ | `CArray (r , w ) ->
1629+ Format. eprintf " Flattening array to bitstring in order to slice@." ;
1630+ `CBitstring (Backend. slice r offset sz), inps
1631+ | `CBitstring r ->
1632+ `CBitstring (Backend. slice r offset sz), inps
1633+ | `CTuple (r , szs ) ->
1634+ Format. eprintf " Cannot slice tuple circuit@." ;
1635+ assert false
1636+ | `CBool b ->
1637+ Format. eprintf " Cannot slice boolean circuit@." ;
1638+ assert false
1639+
16241640 let split_renamer (n : count ) (in_w : width ) (inp : cinp ) : (cinp array) * (Backend.inp -> cbool_type option) =
16251641 match inp with
16261642 | {type_ = `CIBitstring w ; id} when w mod in_w = 0 ->
@@ -1940,6 +1956,7 @@ let circuit_of_form
19401956 else
19411957 let hyps, circ = match (EcEnv.Op. by_path pth env).op_kind with
19421958 | OB_oper (Some (OP_Plain f )) ->
1959+ (* Format.eprintf "[BDEP] Opening definition of function at path %s" (EcPath.tostring pth); *)
19431960 doit cache hyps f
19441961 | _ when pth = EcCoreLib.CI_Witness. p_witness ->
19451962 assert false ;
@@ -2304,7 +2321,8 @@ let circuit_has_uninitialized = circuit_has_uninitialized
23042321let circuit_aggregate_inps =
23052322 circuit_aggregate_inputs
23062323
2307- let circuit_slice (c : circuit ) (sz : int ) (offset : int ) = assert false
2324+ let circuit_slice (c : circuit ) (sz : int ) (offset : int ) =
2325+ circuit_slice c sz offset
23082326
23092327(* FIXME: this should use ids instead of strings *)
23102328let circuit_align_inputs =
0 commit comments