validation-data.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. /* jshint node:true */
  9. 'use strict';
  10. var CommonTestData = require('./common-data');
  11. var elGamal = require('../../lib/index');
  12. var mathematical = require('scytl-mathematical');
  13. module.exports = ValidationTestData;
  14. /**
  15. * Provides the input validation data needed by the ElGamal service unit tests.
  16. */
  17. function ValidationTestData() {
  18. var commonTestData = new CommonTestData();
  19. var nonObject_ = 999;
  20. var emptyObject_ = {};
  21. var nonSecureRandomService_ = elGamal.newService();
  22. var nonSecureRandomGenerator_ = elGamal.newService();
  23. var nonMathematicalService_ = elGamal.newService();
  24. var nonBoolean_ = '';
  25. var nonString_ = 999;
  26. var nonJsonString_ = 'Not a JSON string';
  27. var nonArray_ = '';
  28. var nonStringArray_ = [];
  29. nonStringArray_.push(1);
  30. nonStringArray_.push(2);
  31. nonStringArray_.push(3);
  32. var nonMathObject_ = elGamal.newService();
  33. var nonMathObjectArray_ = [];
  34. nonMathObjectArray_.push(nonMathObject_ + '1');
  35. nonMathObjectArray_.push(nonMathObject_ + '2');
  36. nonMathObjectArray_.push(nonMathObject_ + '3');
  37. var nonElGamalObject_ = mathematical.newService();
  38. var publicKeyFromAnotherGroup_ = commonTestData.getLargePublicKey();
  39. var privateKeyFromAnotherGroup_ = commonTestData.getLargePrivateKey();
  40. var elementsFromAnotherGroup_ =
  41. commonTestData.getElementsFromLargeZpSubgroup();
  42. var exponentsFromAnotherGroup_ =
  43. commonTestData.getExponentsFromLargeZpSubgroup();
  44. this.getNonObject = function() {
  45. return nonObject_;
  46. };
  47. this.getEmptyObject = function() {
  48. return emptyObject_;
  49. };
  50. this.getNonSecureRandomService = function() {
  51. return nonSecureRandomService_;
  52. };
  53. this.getNonSecureRandomGenerator = function() {
  54. return nonSecureRandomGenerator_;
  55. };
  56. this.getNonMathematicalService = function() {
  57. return nonMathematicalService_;
  58. };
  59. this.getNonBoolean = function() {
  60. return nonBoolean_;
  61. };
  62. this.getNonString = function() {
  63. return nonString_;
  64. };
  65. this.getNonJsonString = function() {
  66. return nonJsonString_;
  67. };
  68. this.getNonArray = function() {
  69. return nonArray_;
  70. };
  71. this.getNonStringArray = function() {
  72. return nonStringArray_;
  73. };
  74. this.getNonMathObject = function() {
  75. return nonMathObject_;
  76. };
  77. this.getNonMathObjectArray = function() {
  78. return nonMathObjectArray_;
  79. };
  80. this.getNonElGamalObject = function() {
  81. return nonElGamalObject_;
  82. };
  83. this.getPublicKeyFromAnotherGroup = function() {
  84. return publicKeyFromAnotherGroup_;
  85. };
  86. this.getPrivateKeyFromAnotherGroup = function() {
  87. return privateKeyFromAnotherGroup_;
  88. };
  89. this.getElementsFromAnotherGroup = function() {
  90. return elementsFromAnotherGroup_;
  91. };
  92. this.getExponentsFromAnotherGroup = function() {
  93. return exponentsFromAnotherGroup_;
  94. };
  95. }