Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. 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. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 92bf479f authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add trustee-keygen

parent 7320f7cb
......@@ -15,3 +15,7 @@ tree: _build/tree.html
_build/tree.html: _build/_digests
mkdir -p _build
tree -o $@ -H '..' -I '_build|_run|*~'
trustee-keygen:
ocamlbuild src/bin/trustee-keygen.native
@_build/src/bin/trustee-keygen.native
<**/*.{ml,mli,byte,native,odoc}>: debug, annot, thread, package(zarith), package(calendar), package(uuidm), package(cryptokit), package(atdgen), package(yojson)
<tests/**/*.{ml,mli,byte,native,odoc}>: package(lwt.unix), syntax(camlp4o), package(lwt.syntax)
<src/web/*.{ml,mli,byte,native,odoc}>: package(eliom.server), syntax(camlp4o), package(lwt.syntax)
<src/bin/*>: binary
......@@ -2,3 +2,5 @@ src/lib/lib.cma
src/web/server.cma
api.docdir/index.html
tests/legacy/README.html
src/bin/trustee-keygen.native
......@@ -17,6 +17,7 @@ let () = dispatch & function
| After_rules ->
Pathname.define_context "src/web" ["src/lib"];
Pathname.define_context "src/bin" ["src/lib"];
Pathname.define_context "tests/legacy" ["src/lib"];
Pathname.define_context "tests" ["src/lib"];
Pathname.define_context "." ["src/lib"];
......@@ -24,6 +25,8 @@ let () = dispatch & function
(* the following avoids an ocamlfind warning, it should be built-in *)
flag ["doc"; "thread"] (A"-thread");
flag ["binary"; "compile"] (S [A"-w"; A"-24"]);
rule "%.atd -> %_t.ml & %_t.mli" ~deps:["%.atd"] ~prods:["%_t.ml"; "%_t.mli"]
(atdgen_action [A"-t"]);
rule "%.atd -> %_j.ml & %_j.mli" ~deps:["%.atd"] ~prods:["%_j.ml"; "%_j.mli"]
......
open Util
open Serializable_t
let hash x = Cryptokit.(x |>
hash_string (Hash.sha256 ()) |>
transform_string (Hexa.encode ())
);;
(* Setup group *)
let g = Z.of_string "14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533";;
let p = Z.of_string "16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071";;
let q = Z.of_string "61329566248342901292543872769978950870633559608669337131139375508370458778917";;
assert (Election.check_finite_field ~p ~q ~g);;
module G = (
val Election.finite_field ~g ~p ~q : Signatures.GROUP with type t = Z.t
);;
module M = Election.MakeSimpleMonad(G);;
(* Generate key *)
module KG = Election.MakeSimpleDistKeyGen(G)(M);;
let private_key, public_key = KG.generate_and_prove () ();;
assert (KG.check public_key);;
(* Save to file *)
let id = String.sub
(hash (Z.to_string public_key.trustee_public_key))
0 8 |> String.uppercase
;;
Printf.printf "Keypair %s has been generated\n%!" id;;
let save id kind thing writer =
let filename = Printf.sprintf "%s.%s" id kind in
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob thing;
Bi_outbuf.flush_channel_writer ob;
close_out oc;
Printf.printf "%s key saved to %s\n%!" (String.capitalize kind) filename
;;
save id "public" public_key (Serializable_j.write_trustee_public_key Serializable_builtin_j.write_number);;
save id "private" private_key Serializable_builtin_j.write_number;;
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