Commit 982bc05b authored by Stephane Glondu's avatar Stephane Glondu

Support result where factors are not in the same order as pks

The webserver may create such results...
parent cd01fbc2
......@@ -24,6 +24,13 @@ let ( |> ) x f = f x
module Array = struct
include Array
let exists f a =
let n = Array.length a in
(let rec check i =
if i >= 0 then f a.(i) || check (pred i)
else false
in check (pred n))
let forall f a =
let n = Array.length a in
(let rec check i =
......
......@@ -23,6 +23,7 @@ val ( |> ) : 'a -> ('a -> 'b) -> 'b
module Array : sig
include module type of Array
val exists : ('a -> bool) -> 'a array -> bool
val forall : ('a -> bool) -> 'a array -> bool
val forall2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val fforall : ('a -> bool) -> 'a array array -> bool
......
......@@ -407,7 +407,10 @@ module MakeElection (G : GROUP) (M : RANDOM) = struct
let check_result pks r =
let {encrypted_tally; partial_decryptions; result; _} = r in
check_ciphertext encrypted_tally &&
Array.forall2 (check_factor encrypted_tally) pks partial_decryptions &&
(* decryption factors may be not in the same order as pks! *)
Array.forall (fun pk ->
Array.exists (check_factor encrypted_tally pk) partial_decryptions
) pks &&
let dummy = Array.mmap (fun _ -> G.one) encrypted_tally in
let factors = Array.fold_left (fun a b ->
Array.mmap2 ( *~ ) a b.decryption_factors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment