Commit 4892092a authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Threshold: (client-side) partial decryption

parent 7a17b8c7
......@@ -74,12 +74,21 @@ let compute_partial_decryption _ =
document##getElementById (Js.string "private_key") >>= fun e ->
Dom_html.CoerceTo.input e >>= fun e ->
let pk_str = Js.to_string e##value in
basic_check_private_key pk_str;
let private_key =
try number_of_string pk_str
with e ->
Printf.ksprintf
failwith "Error in format of private key: %s" (Printexc.to_string e)
try
let epk = get_textarea "encrypted_private_key" in
let module PKI = Trustees.MakePKI (P.G) (DirectRandom) in
let module C = Trustees.MakeChannels (P.G) (DirectRandom) (PKI) in
let sk = PKI.derive_sk pk_str and dk = PKI.derive_dk pk_str in
let vk = P.G.(g **~ sk) in
let epk = C.recv dk vk epk in
(partial_decryption_key_of_string epk).pdk_decryption_key
with Not_found ->
basic_check_private_key pk_str;
try number_of_string pk_str
with e ->
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
set_textarea "pd" (string_of_partial_decryption P.G.write factor);
......
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