Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit bdf40f94 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move the sample group to lib

parent be93ff2c
......@@ -8,14 +8,8 @@ let hashB x = Cryptokit.(x |>
(* 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 G = Election.DefaultGroup;;
assert G.(Election.check_finite_field ~p ~q ~g);;
module M = Election.MakeSimpleMonad(G);;
......@@ -152,7 +146,7 @@ let list_save_to filename writer xs =
let save_to_disk () =
let election = { election with
e_public_key = { g; p; q; y }
e_public_key = G.({ g; p; q; y })
} in
let ballots = Array.of_list (M.fold_ballots (fun x xs () -> x::xs) [] ()) in
let dir = Printf.sprintf "demo/data/%s" (Uuidm.to_string election.e_uuid) in
......
......@@ -2,14 +2,8 @@ open Util
(* 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 G = Election.DefaultGroup;;
assert G.(Election.check_finite_field ~p ~q ~g);;
(* Some helpers *)
......@@ -25,7 +19,7 @@ let public_key_of_token uuid x =
pbkdf2 ~prf:MAC.hmac_sha256 ~iterations:1000 ~size:1 ~salt x |>
transform_string (Hexa.encode ())
in
let x = Z.(of_string_base 16 hex mod q) in
let x = Z.(of_string_base 16 hex mod G.q) in
let y = G.(g **~ x) in
Z.to_string y
......
......@@ -62,10 +62,7 @@ let election, election_fingerprint =
let {g; p; q; y} = election.e_public_key
let () = 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 G = (val Election.finite_field ~g ~p ~q : Election.FF_GROUP)
module M = Election.MakeSimpleMonad(G)
(* Load and check trustee keys, if present *)
......
......@@ -3,14 +3,8 @@ open Serializable_t
(* 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 G = Election.DefaultGroup;;
assert G.(Election.check_finite_field ~p ~q ~g);;
module M = Election.MakeSimpleMonad(G);;
......
......@@ -25,10 +25,16 @@ let check_finite_field ~p ~q ~g =
check_modulo p q &&
Z.(powm g q p =% one)
module type FF_GROUP = sig
include GROUP with type t = Z.t
val p : Z.t
end
let finite_field ~p ~q ~g =
let module G = struct
open Z
type t = Z.t
let p = p
let q = q
let one = Z.one
let g = g
......@@ -43,7 +49,13 @@ let finite_field ~p ~q ~g =
let z = Z.of_string_base 16 (sha256_hex x) in
Z.(z mod q)
let compare = Z.compare
end in (module G : GROUP with type t = Z.t)
end in (module G : FF_GROUP)
let p = Z.of_string "16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071"
let q = Z.of_string "61329566248342901292543872769978950870633559608669337131139375508370458778917"
let g = Z.of_string "14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533"
module DefaultGroup = (val finite_field ~p ~q ~g : FF_GROUP)
(** Parameters *)
......
......@@ -2,14 +2,22 @@
open Signatures
val finite_field : p:Z.t -> q:Z.t -> g:Z.t ->
(module GROUP with type t = Z.t)
module type FF_GROUP = sig
include GROUP with type t = Z.t
val p : Z.t
end
(** Multiplicative subgroup of F[p]. *)
val finite_field : p:Z.t -> q:Z.t -> g:Z.t -> (module FF_GROUP)
(** [finite_field p q g] builds the multiplicative subgroup of F[p],
generated by [g], of order [q]. *)
val check_finite_field : p:Z.t -> q:Z.t -> g:Z.t -> bool
(** Check consistency of finite field parameters. *)
module DefaultGroup : FF_GROUP
(** A sample group suitable for cryptography. *)
val check_election : (module ELECTION_PARAMS) -> bool
(** Check consistency of election parameters. *)
......
......@@ -160,8 +160,7 @@ lwt election_table =
}) in
let {g; p; q; y} = election.e_public_key in
let module G = (val
Election.finite_field ~p ~q ~g :
Signatures.GROUP with type t = Z.t
Election.finite_field ~p ~q ~g : Election.FF_GROUP
) in
let module P = struct
module G = G
......
......@@ -3,14 +3,8 @@ open Serializable_t
(* 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 G = Election.DefaultGroup;;
assert G.(Election.check_finite_field ~p ~q ~g);;
module M = Election.MakeSimpleMonad(G);;
......@@ -41,7 +35,7 @@ let y = KG.combine public_keys
let election = {
e_description = "This is a test election.";
e_name = "Test election";
e_public_key = {g; p; q; y};
e_public_key = G.({g; p; q; y});
e_questions =
[|
{
......
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