circuit_additionL1.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include "circuit_additionL1.hpp"
  2. void circuit_additionL1(PublicKey public_key, PrivateKey private_key)
  3. {
  4. ecris(CURVE);
  5. F2 un=0,zero=0, somme=0;
  6. BitEvalL1<curvepoint_fp_t> bit_chiffre_curve_0, bit_chiffre_curve_1, chiffre_curve_somme;
  7. chiffrement(bit_chiffre_curve_0,0,public_key);
  8. chiffrement(bit_chiffre_curve_1,1,public_key);
  9. dechiffrement(zero,bit_chiffre_curve_0,private_key);
  10. dechiffrement(un,bit_chiffre_curve_1,private_key);
  11. zout(zero,un);
  12. cout << "cas #1 0+0" << endl;
  13. //ecris(affichage de bit_chiffre_curve_0);
  14. //bit_chiffre_curve_0.print();
  15. chiffre_curve_somme=additionL1(bit_chiffre_curve_0,bit_chiffre_curve_0,public_key);
  16. //ecris(affichage de chiffre_curve_somme);
  17. //chiffre_curve_somme.print();
  18. dechiffrement(somme,chiffre_curve_somme,private_key);
  19. zout(somme);
  20. cout << "cas #2 0+1" << endl;
  21. chiffre_curve_somme=additionL1(bit_chiffre_curve_0,bit_chiffre_curve_1,public_key);
  22. dechiffrement(somme,chiffre_curve_somme,private_key);
  23. zout(somme);
  24. cout << "cas #3 1+0" << endl;
  25. //bit_chiffre_curve_0.print();
  26. //bit_chiffre_curve_1.print();
  27. chiffre_curve_somme=additionL1(bit_chiffre_curve_1,bit_chiffre_curve_0,public_key);
  28. dechiffrement(somme,chiffre_curve_somme,private_key);
  29. zout(somme);
  30. cout << "cas #4 1+1" << endl;
  31. chiffre_curve_somme=additionL1(bit_chiffre_curve_1,bit_chiffre_curve_1,public_key);
  32. dechiffrement(somme,chiffre_curve_somme,private_key);
  33. zout(somme);
  34. JUMP;
  35. ecris(TWIST);
  36. un=0,zero=0, somme=0;
  37. BitEvalL1<twistpoint_fp2_t> bit_chiffre_twist_0, bit_chiffre_twist_1, chiffre_twist_somme;
  38. chiffrement(bit_chiffre_twist_0,0,public_key);
  39. chiffrement(bit_chiffre_twist_1,1,public_key);
  40. dechiffrement(zero,bit_chiffre_twist_0,private_key);
  41. dechiffrement(un,bit_chiffre_twist_1,private_key);
  42. zout(zero,un);
  43. cout << "cas #1 0+0" << endl;
  44. //ecris(affichage de bit_chiffre_twist_0);
  45. //bit_chiffre_twist_0.print();
  46. chiffre_twist_somme=additionL1(bit_chiffre_twist_0,bit_chiffre_twist_0,public_key);
  47. //ecris(affichage de chiffre_twist_somme);
  48. //chiffre_twist_somme.print();
  49. dechiffrement(somme,chiffre_twist_somme,private_key);
  50. zout(somme);
  51. cout << "cas #2 0+1" << endl;
  52. chiffre_twist_somme=additionL1(bit_chiffre_twist_0,bit_chiffre_twist_1,public_key);
  53. dechiffrement(somme,chiffre_twist_somme,private_key);
  54. zout(somme);
  55. cout << "cas #3 1+0" << endl;
  56. //bit_chiffre_twist_0.print();
  57. //bit_chiffre_twist_1.print();
  58. chiffre_twist_somme=additionL1(bit_chiffre_twist_1,bit_chiffre_twist_0,public_key);
  59. dechiffrement(somme,chiffre_twist_somme,private_key);
  60. zout(somme);
  61. cout << "cas #4 1+1" << endl;
  62. chiffre_twist_somme=additionL1(bit_chiffre_twist_1,bit_chiffre_twist_1,public_key);
  63. dechiffrement(somme,chiffre_twist_somme,private_key);
  64. zout(somme);
  65. JUMP;
  66. cout << "taille d'un chiffré de niveau 1 de type curve = " << sizeof(bit_chiffre_curve_0) << " octets" << endl;
  67. cout << "taille d'un chiffré de niveau 1 de type twist = " << sizeof(bit_chiffre_twist_0) << " octets" << endl;
  68. //cout << "taille en octets de la somme de deux chiffrés de niveau 1 de type curve =" << sizeof(chiffre_curve_somme)<< endl;
  69. //cout << "taille en octets de la somme de deux chiffrés de niveau 1 de type twist" << sizeof(chiffre_twist_somme)<< endl;
  70. }