Skip to content

Commit

Permalink
feat(snarky_bindings): add rot function to Gates module
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMinkov committed Oct 12, 2023
1 parent a6b9460 commit 1f7443d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions ocaml/lib/snarky_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,41 @@ module Gates = struct
compact
} )
} )

let rot word rotated excess
(bound_limb0, bound_limb1, bound_limb2, bound_limb3)
( bound_crumb0
, bound_crumb1
, bound_crumb2
, bound_crumb3
, bound_crumb4
, bound_crumb5
, bound_crumb6
, bound_crumb7 ) two_to_rot =
Impl.with_label "rot64_gate" (fun () ->
Impl.assert_
{ annotation = Some __LOC__
; basic =
Kimchi_backend_common.Plonk_constraint_system.Plonk_constraint.T
(Rot64
{ (* Current row *) word
; rotated
; excess
; bound_limb0
; bound_limb1
; bound_limb2
; bound_limb3
; bound_crumb0
; bound_crumb1
; bound_crumb2
; bound_crumb3
; bound_crumb4
; bound_crumb5
; bound_crumb6
; bound_crumb7 (* Coefficients *)
; two_to_rot (* Rotation scalar 2^rot *)
} )
} )
end

module Bool = struct
Expand Down Expand Up @@ -317,6 +352,8 @@ let snarky =
val gates =
object%js
method rangeCheck0 = Gates.range_check0

method rot = Gates.rot
end

val bool =
Expand Down
16 changes: 16 additions & 0 deletions ocaml/lib/snarky_bindings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ val snarky :
* Field.t
-> Impl.field
-> unit )
Js.meth
; rot :
( Field.t
-> Field.t
-> Field.t
-> Field.t * Field.t * Field.t * Field.t
-> Field.t
* Field.t
* Field.t
* Field.t
* Field.t
* Field.t
* Field.t
* Field.t
-> Impl.field
-> unit )
Js.meth >
Js.t
Js.readonly_prop
Expand Down

0 comments on commit 1f7443d

Please sign in to comment.