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 45962529 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add save_to_disk to sandbox + sample election

parent 7339562d
......@@ -31,6 +31,14 @@ type 'a trustee_public_key = {
(** {2 Elections} *)
type ff_pubkey = {
g : number;
p : number;
q : number;
y : number;
} <ocaml field_prefix="ff_">
<doc text="Parameters for a multiplicative subgroup of a finite field, with a public key.">
type question = {
answers : string list <ocaml repr="array">;
min : int;
......
{"description":"This is a test election","name":"Test election","public_key":{"g":"14887492224963187634282421537186040801304008017743492304481737382571933937568724473847106029915040150784031882206090286938661464458896494215273989547889201144857352611058572236578734319505128042602372864570426550855201448111746579871811249114781674309062693442442368697449970648232621880001709535143047913661432883287150003429802392229361583608686643243349727791976247247948618930423866180410558458272606627111270040091203073580238905303994472202930783207472394578498507764703191288249547659899997131166130259700604433891232298182348403175947450284433411265966789131024573629546048637848902243503970966798589660808533","p":"16328632084933010002384055033805457329601614771185955389739167309086214800406465799038583634953752941675645562182498120750264980492381375579367675648771293800310370964745767014243638518442553823973482995267304044326777047662957480269391322789378384619428596446446984694306187644767462460965622580087564339212631775817895958409016676398975671266179637898557687317076177218843233150695157881061257053019133078545928983562221396313169622475509818442661047018436264806901023966236718367204710755935899013750306107738002364137917426595737403871114187750804346564731250609196846638183903982387884578266136503697493474682071","q":"61329566248342901292543872769978950870633559608669337131139375508370458778917","y":"960089513133146228978023284199280670630285984494042288837019983706390871817022127040124041937525262316682954598919302007230699696520785973107966673222862992785234183308644619197036933595621845598327114597067699152865204537432368227190424821765131105232729902658164905996264584179179553830699475933269146754939624673150395257255429170745848415737856731871241898108120250732003712756483710952545808221332781988029542942539900547597307621533447572698940812568555166211135615694085107050267728159680911349633547978243347515013023748964021304131660998501005804101932354773542988689665970986489866632168895370372383214347"},"questions":[{"answers":["a","b","c","d","e"],"min":0,"max":1,"question":"Question 1?"},{"answers":["a","b","c","d","e","f"],"min":2,"max":3,"question":"Question 2?"},{"answers":["a","b","c"],"min":1,"max":1,"question":"Question 3?"}],"uuid":"42e7b114-f01c-45f0-a3a6-fd7949f0dea7","short_name":"test"}
\ No newline at end of file
"34683588876921265544480198037642795021516865715068976541337390056210958643599"
"44999779094401951865105138823261903610219891437233791559009933848321905711224"
"1807600573888674357550145954761585064688727452007744454305612249160759366248"
"2296432221249158035537408338905374486350366792849401374620054721628087118656"
"37602057755139741163837111262560007333935856137690139227971840964975529995749"
"46596140943583224221232097117957776849201083826252167465571515497729123486707"
"43429218238909840720262617327584427497217719171129416706251576454357367714995"
"34778265497711318995952683431512902410038727211293056691731482989669639395235"
"34356515976876417439271042239327966262599222771320631284819618404595035567341"
"22843099659911141417868868339247064734434756967296082865100622266643636266725"
"615238013630823432584566081558733797267758621049443291067538239483156219956"
{"pok":{"challenge":"481097243293841721102947970645348352496156307773","response":"9939923015422583815992828075484904269418869289997493103265918555308418135425"},"public_key":"4603179544694810831874876491638327373797816386905908234468073800273051834148109059191437420038458480395689233583077211942045957696860673273770474754536206289167509892727459081253310529796196367937283055324463737234871532186467870132942555011515611735723334287441899493272836930647488001989678206047653780470719218452425716221477109179909406941965475059459987957552887236484920386870757053539985665109856569088767226953999604342843090099454962717262768431867221622999546381435202744227597257919897874180871628189276872867633157608963936938667028264824303599456058019616221424015455269658656805958861220760337275287480"}
{"pok":{"challenge":"382173501663512107363451494296638071612961190488","response":"34000837416903875132252370204181082692778200658539233443519100469128900382098"},"public_key":"5259673898267279359280874269478365223547065044180754898092768444150526094585545730611715796239454530244192404029407060263711926417212088663452897144976037105550149996290577502748814364417465905213485629546897766012859364951503170475811711568964792939933710875046772427986341193081754351437627951692620060650544983614328686569388390866083724826824064949238182712840397667994822075122093540085933193824985670977829787346544942730384155083190730379620969793280430676938783982403184920855027375427240131823223681582386998611575880644413651284255382081467115543657850844956907820077740067261373547950015890757491479011748"}
{"pok":{"challenge":"806840408871590115219802234489674063170890032334","response":"6963531062061210841431560695823332656227109164650495706184613531063531245425"},"public_key":"9080855634374805189078732492431940299424409851295164760085821183802861700866217772970659366649105441997233579065141897803042542411429225432639825592740370093958308474923715166615533495864927642221468078691848410173221549914916618869726574498149273272072183280880477016848093299492947796613440824757079363528999930611039696605863826612789595221378500137229536290759512319923275533825051007682583470649005028122181510516175477771202525210153616713875162273887764724858066746943903400815973118814013794634302501693226601054736786810876810095741350288249138522031030691971513527406872920827685496691504961339259795572718"}
{"pok":{"challenge":"979262127127221599265228726655262020066837394738","response":"56138196671531365655263764939494135320861243381627442376624588626320677355374"},"public_key":"6443420319704493392653892003151318916473211359245304969369833564149809115187827842871779507229763132771372647842584489529195397606929067858988037809680951607909337741855341785971441457383156327912138600739265937613040009128569535484539611115274535779959094818085540341100349072360333125868142495870417724478176455086031935471493536755054358877370137775038212384139953628158764523939318410582331387280437592375582029123031998838344080379835411782275022229533029586714575778219419065786895164378138687271820161017750636529210795351794622229936211607306219604338069365367181418140793014006437643350001505985334147186649"}
{"pok":{"challenge":"208627228161306448556404784246895941988980034740","response":"2451713385683103206448386325647128002328268013719546996402490856708900919215"},"public_key":"10558160271892203526486643813445432081709919368561085941377102310333854198607200652321930402303642597129360284420670213983935634481371252323889779749580463071238409161075370382521165152407365235704398916746457197142618159087309307965287979514619993287047500176451215651548199637278982567180407639444690715877416200020971099151909653496622803892472595601586155725592693350733479896576494380727442366209122523075293762953418864157354128184596213126541398965643897639497771210718696474123947767050845598073393652725558722762719671057043229598861553677403641059367312216190474448527659516927004510156946486445922532863504"}
{"pok":{"challenge":"426071206087251475055047512053610792266590025524","response":"30191662278005766094721771543218150350310988469079970073868628164697115763065"},"public_key":"11645159201281780643539462398961263264217236280474994778346974427908086028543593818232239217981835035419152112151145972411872245170605770638053383274978833298373762487454703792370893938286716786191601138113199362514653839307012356366216587487567904747833888990981912442777855795018644607104985654677953762096092814636101468628777323902250665917875418361898505839468140365503646132440266550934478484684834394072726105358561469272344298086857662820518300826221869835912505941997143844794014375050854034080215710404493312182969512027661811120510649835658612104261908191025990604466988295983078611830513439227000873931760"}
{"pok":{"challenge":"154865941106404452123474498306966474775968164150","response":"2574873721408962049563393518859093428075833472170585737671679815549589017440"},"public_key":"5825104098853586185554576408187182568254452456193400528226022785246889178448205287642216770449335303723448982423244751930554367024256378181997792143737774182237866745291308823539156658952876653249155573193402152842806345235832360988736759107857923488700381816106029199465939813176570095262875193353360335781204067064106068377395132645652682638747274995804593988736030975034450500286828731881512139365780627686090957856642001787459260477552431525303307468136099608044649797919202067095498682213462931126176253506803608483828830895827867970205590512944695513824539785027736797425726644918708946550206517662616424183428"}
{"pok":{"challenge":"1144453636486870138656139838474417451978104129652","response":"275358280829621037322341439683645539516489522571248319149062083084771970816"},"public_key":"15932402568535242801659075244031232108104636427938056622398954967319433351797636432247268413254831657931243986095778741799143251923777759769338220682680353449102472505781120630680576809859380886397518181556311827234473855252509644653574293992583031028266690343678669477131851221235365225487923853060801694906984810811825441111911714723810540029545150818654418298870978958341234058400429167305946295629015497908716061354231426194500863192660730862294000943614492085496890712413549200442738611285561798980196098608885635126329721806584147398001041201955930593288173734642849257835583892753551773253470660785017474573733"}
{"pok":{"challenge":"1068375047402915171340975635650031348077087219533","response":"43375573455707140252960684648381424791932356461944540293258953996373960059253"},"public_key":"15864803104215045949862847306938546118450120085755227639121320068516225114227649355152846381780484218228194826768716639103631142477995066889702875099632044938857476295720319461350192690587214035892101786465445432586536874757652511001764056083452558069582421418382256241966852412171237405641642472686708783827102306583094254611039699111786208230335459710471082048743345048827971938373232209859576079222797390440811210816327675319083806895027124268121777643076871349635492086252681024327113735748872750408479704769982528499528546943562600470361521556120019340251547234491634270027338236628755416562810397859011612497754"}
{"pok":{"challenge":"1295227277172989110612910854024834113790906137542","response":"53576285214183812149803255380709401549903056781830548392347481691040368006367"},"public_key":"7902123700668039759439104889678879522157480270175490436001652118533983600613081397893712357763399886402619437980541294578151146938455533878337596004023104640967488636223790962755977077849572330207496598119172063703429250264754014681526061904961472958066335080337709325235383677297371719373036020124026143578568479244524415324954544979558763125471710787866020034195674932830225141010670588838439538493439379905484493555274190593762079892225814288434807384575814714519733871345260543016362662202528000377056201415734158600076874411650607683945219002341652565725256598186942154390090983156092148853523761130441021544922"}
{"pok":{"challenge":"395520415236904384389671799943627471461521266430","response":"5066500452706811160841922701462490542489600710985294861078689158234912358718"},"public_key":"1805628750246316434477787020567183666322505605131708660617379230625570402231767137818020582680806425713587621060527286110551483374338790663581470924915068418530850429547551805616479266407594660671225543020711562780135162291420921966480139477868424472293595037120666409040488074921201547820334150628864882759409800192767737822432120845919593229636720516356881428846413474252145230506033021121794502731700827468592326280353134084147844610314764382942931163482428565197677521725507639439376922966929677912782722808135541605403698073588823967401272196056708716251345783568142213453452063073242752586832710546960583633062"}
This diff is collapsed.
......@@ -117,3 +117,42 @@ assert (E.check_result result);;
let tally = E.extract_tally result;;
assert (tally = [|[| 1; 0; 1; 0; 0 |]; [|0; 4; 0; 4; 3; 0|]; [| 1; 1; 2 |]|]);;
(* Save to disk *)
let ( / ) = Filename.concat
let save_to filename writer x =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
writer ob x;
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
let list_save_to filename writer xs =
let oc = open_out filename in
let ob = Bi_outbuf.create_channel_writer oc in
Array.iter (fun x ->
writer ob x;
Bi_outbuf.add_char ob '\n';
) xs;
Bi_outbuf.flush_channel_writer ob;
close_out oc;;
let save_to_disk () =
let election = { election with
e_public_key = { ff_g = g; ff_p = p; ff_q = q; ff_y = y }
} in
let ballots = Array.of_list (M.fold (fun x xs () -> x::xs) [] ()) in
let dir = Printf.sprintf "tests/data/{%s}"
(Uuidm.to_string election.e_uuid)
in
Unix.mkdir dir 0o755;
let open Serializable_j in
let number = Serializable_builtin_j.write_number in
save_to (dir/"election.json") (write_election write_ff_pubkey) election;
list_save_to (dir/"private_keys.jsons") number private_keys;
list_save_to (dir/"public_keys.jsons") (write_trustee_public_key number) public_keys;
list_save_to (dir/"ballots.jsons") (write_ballot number) ballots;
save_to (dir/"result.json") (write_result number) result;
();;
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