Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 6369d8a9 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Make the DirectRandom monad direct

parent 97a94ca2
......@@ -36,18 +36,17 @@ let question_length q =
(** Direct random monad *)
module DirectRandom = struct
type 'a t = unit -> 'a
let return x () = x
let bind x f = f (x ())
type 'a t = 'a
let return x = x
let bind x f = f x
let fail e = raise e
let prng = lazy (pseudo_rng (random_string secure_rng 16))
let random q =
let size = Z.bit_length q / 8 + 1 in
fun () ->
let r = random_string (Lazy.force prng) size in
Z.(of_bits r mod q)
let r = random_string (Lazy.force prng) size in
Z.(of_bits r mod q)
end
(** Homomorphic elections *)
......
......@@ -31,7 +31,7 @@ module DirectRandom : sig
(** {2 Monadic definitions} *)
include Signatures.MONAD with type 'a t = unit -> 'a
include Signatures.MONAD with type 'a t = 'a
(** {2 Random number generation} *)
......
......@@ -184,7 +184,7 @@ module Ttkeygen : CMDLINER_MODULE = struct
let module T = Trustees.MakePedersen (G) (M) (P) (C) in
match step with
| 1 ->
let key, cert = T.step1 () () in
let key, cert = T.step1 () in
let id = sha256_hex cert.s_message in
Printf.eprintf "I: certificate %s has been generated\n%!" id;
let pub = "certificate", id ^ ".cert", 0o444, string_of_cert cert in
......@@ -208,7 +208,7 @@ module Ttkeygen : CMDLINER_MODULE = struct
let certs = get_certs () in
let threshold = get_mandatory_opt "--threshold" threshold in
let key = get_mandatory_opt "--key" key |> string_of_file in
let polynomial = T.step3 certs key threshold () in
let polynomial = T.step3 certs key threshold in
Printf.printf "%s\n%!" (string_of_polynomial polynomial)
| 4 ->
let certs = get_certs () in
......@@ -230,7 +230,7 @@ module Ttkeygen : CMDLINER_MODULE = struct
let certs = get_certs () in
let key = get_mandatory_opt "--key" key |> string_of_file in
let vinput = read_line () |> vinput_of_string in
let voutput = T.step5 certs key vinput () in
let voutput = T.step5 certs key vinput in
Printf.printf "%s\n%!" (string_of_voutput G.write voutput)
| 6 ->
let certs = get_certs () in
......
......@@ -66,7 +66,7 @@ module Make (P : PARSED_PARAMS) : S = struct
priv, pub, hashed
let generate () =
CG.generate () () |> compute_pub_and_hash
CG.generate () |> compute_pub_and_hash
end
......
......@@ -162,7 +162,7 @@ module Make (P : PARSED_PARAMS) : S = struct
CD.derive election.e_params.e_uuid cred
)
in
let b = E.create_ballot election ?sk (E.make_randomness election ()) ballot () in
let b = E.create_ballot election ?sk (E.make_randomness election) ballot in
assert (E.check_ballot election b);
string_of_ballot G.write b
......@@ -173,7 +173,7 @@ module Make (P : PARSED_PARAMS) : S = struct
print_msg "W: your key is not present in public_keys.jsons";
);
let tally, _ = Lazy.force encrypted_tally in
let factor = E.compute_factor tally sk () in
let factor = E.compute_factor tally sk in
assert (E.check_factor tally pk factor);
string_of_partial_decryption G.write factor
......@@ -192,7 +192,7 @@ module Make (P : PARSED_PARAMS) : S = struct
print_msg "W: your key is not present in threshold parameters"
);
let tally, _ = Lazy.force encrypted_tally in
let factor = E.compute_factor tally pdk () in
let factor = E.compute_factor tally pdk in
assert (E.check_factor tally pvk factor);
string_of_partial_decryption G.write factor
......
......@@ -81,7 +81,7 @@ let compute_partial_decryption _ =
Printf.ksprintf
failwith "Error in format of private key: %s" (Printexc.to_string e)
in
let factor = E.compute_factor encrypted_tally private_key () in
let factor = E.compute_factor encrypted_tally private_key in
set_textarea "pd" (string_of_partial_decryption P.G.write factor);
Js.some ()
......
......@@ -56,8 +56,8 @@ module Make (P : PARSED_PARAMS) : S = struct
type keypair = { id : string; priv : string; pub : string }
let trustee_keygen () =
let private_key = KG.generate () () in
let public_key = KG.prove private_key () in
let private_key = KG.generate () in
let public_key = KG.prove private_key in
assert (KG.check public_key);
let id = String.sub
(sha256_hex (G.to_string public_key.trustee_public_key))
......
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