Commit 271d892e authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Start compatibility layer

parent e8c55296
Serializable_t
Crypto_sigs
Crypto
ElGamal
Serializable_t
Serializable_compat_t
Serializable_compat
StdExtra
Core_datatypes_j
Serializable_t
Serializable_j
Serializable_compat_t
Serializable_compat_j
Serializable_compat
Common
Crypto
ElGamal
<doc text="Serializable datatypes (compatibility layer)">
(** {1 Core types} *)
type number <ocaml predef from="Core_datatypes"> = abstract
......@@ -72,7 +74,7 @@ type 'a election = {
(** {1 Ballots} *)
type 'a choice = {
type 'a choice <ocaml predef from="Serializable" t="ciphertext"> = {
alpha : 'a;
beta : 'a;
}
......
open Serializable_compat_t
let of_question q =
let {q_answers; q_min; q_max; q_question; _} = q in
let q_max = match q_max with
| Some i -> i
| None -> Array.length q_answers
in
let open Serializable_t in
{q_answers; q_min; q_max; q_question}
let of_election e =
let {
e_description; e_name; e_public_key;
e_questions; e_uuid; e_short_name;
_
} = e in
let e_public_key = e_public_key.y in
let e_questions = Array.map of_question e_questions in
let open Serializable_t in
{
e_description; e_name; e_public_key;
e_questions; e_uuid; e_short_name
}
let of_proof p =
let {dp_challenge; dp_response; _} = p in
let open Serializable_t in
{challenge = dp_challenge; response = dp_response}
let of_proofs ps = Array.map of_proof ps
let of_answer a =
let {choices; individual_proofs; overall_proof} = a in
let individual_proofs = Array.map of_proofs individual_proofs in
let overall_proof = of_proofs overall_proof in
let open Serializable_t in
{choices; individual_proofs; overall_proof}
let of_ballot b =
let {answers; election_hash; election_uuid} = b in
let answers = Array.map of_answer answers in
let open Serializable_t in
{answers; election_hash; election_uuid}
(** Compatibility layer with the Helios reference implementation *)
open Serializable_compat_t
val of_election : 'a election -> 'a Serializable_t.election
val of_ballot : 'a ballot -> 'a Serializable_t.ballot
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