/* * Copyright 2018 Scytl Secure Electronic Voting SA * * All rights reserved * * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package */ /* global forge */ /* global CL */ /* global OV */ /* jshint maxlen: 6666 */ /* global TD */ describe('Partial choice code api', function() { 'use strict'; var TD = require('./mocks/testdata.json'); it('should generate partial choice codes', function() { var encParms = OV.parseEncryptionParams(TD.authResponse); var options = [ new CL.commons.mathematical.ZpGroupElement(new forge.jsbn.BigInteger('3'), encParms.p, encParms.q), new CL.commons.mathematical.ZpGroupElement(new forge.jsbn.BigInteger('5'), encParms.p, encParms.q), new CL.commons.mathematical.ZpGroupElement(new forge.jsbn.BigInteger('7'), encParms.p, encParms.q) ]; var exponent = new forge.jsbn.BigInteger('34987025184313239'); var partialChoiceCodes = OV.generatePartialChoiceCodes(options, encParms, exponent); expect(partialChoiceCodes.length).toBe(3); expect(partialChoiceCodes[0].toString()).toBe('9986735796339922851132698117263338793469847412905017488327871512582887462121603631070878124698925687253367283823397728207754813164342128784023826179105290512290203109575998512961942343360028979832215626996038117069354453410501522465467219989791291166666117799352952462582251191941547213691297660736124602863982706112046216323831630839358876616934570836742749390389617456975289279432325110076200560243315090490538641785081984931048446616237949633036265041171749271866015933582048288450686615162569657351442943677074009524648636723992338244688398041241450246405650607021177240658360094549239016220972024713542883920155'); expect(partialChoiceCodes[1].toString()).toBe('1344259078921186109292930897620463819546817876766466284111332179686328304604754391869342743957392390423366057890700955590039216502298779605129222988274283912428839896867501728399195548197507816969253474996347908040378401293457751436966172841272855857997277788384604190531661340331765745617239618219592626937671132760959300626166485365010443313847214586408687321361674010737320070618085119913671552680129394029144556238374510650564708765009628152679300047192580396543818187579094668536529533821454819873876549699192820807368313197886301618391039465217179925756659310075593706069265849365198043789874401771285020985232'); expect(partialChoiceCodes[2].toString()).toBe('10377576473055795969259679036301270470023783840222303597658849830954729974280680179536380807204593710610436212369019464912536313499285841053933137545031268324944718769331176891968044459777408967104385004694749877927465755102834299400417894349506977356290924319023971710281475273509226597598310986444887536314288678355065876217512572005830958822382791095406228240833051702651529090528195110013374772031202980245745421615050739787190787909114127801081746704132620600809034841747608371408287682669349009391766088416346269598958028859118996479299423934338174574596499451054709629455559401437623375985252963081688388024614'); }); });