• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 2863

05 Nov 2024 06:20PM UTC coverage: 30.754% (-16.6%) from 47.311%
2863

push

buildkite

web-flow
Merge pull request #16296 from MinaProtocol/dkijania/more_multi_jobs

more multi jobs in CI

20276 of 65930 relevant lines covered (30.75%)

8631.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/lib/snarky_group_map/checked_map.ml
1
open Core_kernel
10✔
2

3
module Aux (Impl : Snarky_backendless.Snark_intf.Run) = struct
4
  open Impl
5

6
  let non_residue : Field.Constant.t Lazy.t =
7
    let open Field.Constant in
8
    let rec go i = if not (is_square i) then i else go (i + one) in
15✔
9
    lazy (go (of_int 2))
15✔
10

11
  let sqrt_exn x =
12
    let y =
156✔
13
      exists Field.typ ~compute:(fun () ->
14
          Field.Constant.sqrt (As_prover.read_var x) )
×
15
    in
16
    assert_square y x ; y
156✔
17

18
  (* let sqrt_flagged : Field.t -> Field.t * Boolean.var = *)
19
  let sqrt_flagged x =
20
    (*
21
       imeckler: I learned this trick from Dan Boneh
22

23
       m a known non residue
24

25
       exists is_square : bool, y.
26
       if is_square then assert y*y = x else assert y*y = m * x
27

28
       <=>
29

30
       assert (y*y = if is_square then x else m * x)
31
    *)
32
    let is_square =
156✔
33
      exists Boolean.typ ~compute:(fun () ->
34
          Field.Constant.is_square (As_prover.read_var x) )
×
35
    in
36
    let m = Lazy.force non_residue in
156✔
37
    (sqrt_exn (Field.if_ is_square ~then_:x ~else_:(Field.scale x m)), is_square)
156✔
38
end
39

40
let wrap (type f) ((module Impl) : f Snarky_backendless.Snark0.m) ~potential_xs
41
    ~y_squared =
42
  let open Impl in
15✔
43
  let module A = Aux (Impl) in
44
  let open A in
45
  stage (fun x ->
46
      let x1, x2, x3 = potential_xs x in
52✔
47
      let y1, b1 = sqrt_flagged (y_squared ~x:x1)
52✔
48
      and y2, b2 = sqrt_flagged (y_squared ~x:x2)
52✔
49
      and y3, b3 = sqrt_flagged (y_squared ~x:x3) in
52✔
50
      Boolean.Assert.any [ b1; b2; b3 ] ;
51
      let x1_is_first = (b1 :> Field.t)
52✔
52
      and x2_is_first = (Boolean.((not b1) && b2) :> Field.t)
52✔
53
      and x3_is_first = (Boolean.((not b1) && (not b2) && b3) :> Field.t) in
52✔
54
      ( Field.((x1_is_first * x1) + (x2_is_first * x2) + (x3_is_first * x3))
55
      , Field.((x1_is_first * y1) + (x2_is_first * y2) + (x3_is_first * y3)) ) )
56

57
module Make
58
    (M : Snarky_backendless.Snark_intf.Run) (P : sig
59
      val params : M.field Group_map.Params.t
60
    end) =
61
struct
62
  open P
63
  include Group_map.Make (M.Field.Constant) (M.Field) (P)
64
  open M
65

66
  let to_group =
67
    let { Group_map.Spec.a; b } = Group_map.Params.spec params in
68
    unstage
7✔
69
      (wrap
7✔
70
         (module M)
71
         ~potential_xs
72
         ~y_squared:Field.(fun ~x -> (x * x * x) + scale x a + constant b) )
21✔
73
end
20✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc