Commit 56edcd81 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Monadic failure of compute_factor

parent 95668bb4
......@@ -66,6 +66,7 @@ module MakeSimpleMonad (G : GROUP) = struct
let ballots = ref []
let return x () = x
let bind x f = f (x ())
let fail e = raise e
let random q =
let size = Z.size q * Sys.word_size / 8 in
......@@ -333,7 +334,7 @@ module MakeElection (P : ELECTION_PARAMS) (M : RANDOM) = struct
sswap decryption_proofs >>= fun decryption_proofs ->
return {decryption_factors; decryption_proofs}
) else (
invalid_arg "Invalid ciphertext"
fail (Invalid_argument "Invalid ciphertext")
)
let check_factor c y f =
......
......@@ -20,6 +20,7 @@ module MakeSimpleMonad (G : GROUP) : sig
type 'a t = unit -> 'a
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val fail : exn -> 'a t
(** {2 Random number generation} *)
......
......@@ -45,6 +45,7 @@ module type MONAD = sig
type 'a t
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val fail : exn -> 'a t
end
(** Random number generation. *)
......
Supports Markdown
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