[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#878980: Patch



tags 878980 + patch
thanks

Attached is a patch that fixes the FTBFS. It's based on upstream commit 7c6071f6b15a162f04bfa367eff8e88a64afce89.
Index: belenios-1.4+dfsg/src/lib/election.ml
===================================================================
--- belenios-1.4+dfsg.orig/src/lib/election.ml
+++ belenios-1.4+dfsg/src/lib/election.ml
@@ -49,11 +49,6 @@ module MakeSimpleMonad (G : GROUP) = str
     fun () ->
       let r = random_string (Lazy.force prng) size in
       Z.(of_bits r mod q)
-
-  type elt = G.t ballot
-  let cast x () = ballots := x :: !ballots
-  let fold f x () = List.fold_left (fun accu b -> f () b accu ()) x !ballots
-  let cardinal () = List.length !ballots
 end
 
 (** Distributed key generation *)
Index: belenios-1.4+dfsg/src/lib/election.mli
===================================================================
--- belenios-1.4+dfsg.orig/src/lib/election.mli
+++ belenios-1.4+dfsg/src/lib/election.mli
@@ -39,15 +39,6 @@ module MakeSimpleMonad (G : GROUP) : sig
   (** [random q] returns a random number modulo [q]. It uses a secure
       random number generator lazily initialized by a 128-bit seed
       shared by all instances. *)
-
-  (** {2 Ballot box management} *)
-
-  include Signatures.MONADIC_MAP_RO
-  with type 'a m := 'a t
-  and type elt = G.t ballot
-  and type key := unit
-
-  val cast : elt -> unit t
 end
 (** Simple election monad that keeps all ballots in memory. *)
 
Index: belenios-1.4+dfsg/src/lib/signatures.mli
===================================================================
--- belenios-1.4+dfsg.orig/src/lib/signatures.mli
+++ belenios-1.4+dfsg/src/lib/signatures.mli
@@ -105,25 +105,6 @@ module type RANDOM = sig
   (** [random q] returns a random number modulo [q]. *)
 end
 
-(** Read operations of a monadic map. *)
-module type MONADIC_MAP_RO = sig
-  type 'a m
-  (** The type of monadic values. *)
-
-  type elt
-  (** The type of map values. *)
-
-  type key
-  (** The type of map keys. *)
-
-  val fold : (key -> elt -> 'a -> 'a m) -> 'a -> 'a m
-  (** [fold f a] computes [(f kN vN ... (f k2 v2 (f k1 v1 a))...)],
-      where [k1/v1 ... kN/vN] are all key/value pairs. *)
-
-  val cardinal : int m
-  (** Return the number of bindings. *)
-end
-
 (** Election data needed for cryptographic operations. *)
 type 'a election = {
   e_params : 'a params;
Index: belenios-1.4+dfsg/src/tool/tool_election.ml
===================================================================
--- belenios-1.4+dfsg.orig/src/tool/tool_election.ml
+++ belenios-1.4+dfsg/src/tool/tool_election.ml
@@ -125,7 +125,7 @@ module Make (P : PARSED_PARAMS) : S = st
 
   let cast (b, hash) =
     if Lazy.force check_signature_present b && E.check_ballot election b
-    then M.cast b ()
+    then ()
     else Printf.ksprintf failwith "ballot %s failed tests" hash
 
   let ballots_check = lazy (
@@ -133,12 +133,13 @@ module Make (P : PARSED_PARAMS) : S = st
   )
 
   let encrypted_tally = lazy (
-    match Lazy.force ballots_check with
+    match Lazy.force ballots with
       | None -> failwith "ballots.jsons is missing"
-      | Some () ->
-        M.fold (fun () b t ->
-          M.return (E.combine_ciphertexts (E.extract_ciphertext b) t)
-        ) (E.neutral_ciphertext election) ()
+      | Some ballots ->
+        List.fold_left (fun accu (b, _) ->
+            E.combine_ciphertexts (E.extract_ciphertext b) accu
+          ) (E.neutral_ciphertext election) ballots,
+        List.length ballots
   )
 
   let vote privcred ballot =
@@ -158,16 +159,16 @@ module Make (P : PARSED_PARAMS) : S = st
     if Array.forall (fun x -> not G.(x =~ pk)) pks then (
       print_msg "W: your key is not present in public_keys.jsons";
     );
-    let tally = Lazy.force encrypted_tally in
+    let tally, _ = Lazy.force encrypted_tally in
     let factor = E.compute_factor tally sk () in
     assert (E.check_factor tally pk factor);
     string_of_partial_decryption G.write factor
 
   let finalize factors =
     let factors = Array.map (partial_decryption_of_string G.read) factors in
-    let tally = Lazy.force encrypted_tally in
+    let tally, nballots = Lazy.force encrypted_tally in
     assert (Array.forall2 (E.check_factor tally) pks factors);
-    let result = E.combine_factors (M.cardinal ()) tally factors in
+    let result = E.combine_factors nballots tally factors in
     assert (E.check_result pks result);
     string_of_result G.write result
 
@@ -179,7 +180,7 @@ module Make (P : PARSED_PARAMS) : S = st
     (match get_result () with
     | Some result ->
       let result = result_of_string G.read result in
-      assert (Lazy.force encrypted_tally = result.encrypted_tally);
+      assert (fst (Lazy.force encrypted_tally) = result.encrypted_tally);
       assert (E.check_result pks result)
     | None -> print_msg "W: no result to check"
     );

Reply to: