Browse Source

fixing the compiler errors so that the test will actually run in a way that can be seen

tristangurtler 3 years ago
parent
commit
ef19d901de
6 changed files with 21 additions and 32 deletions
  1. 4 4
      bgn2/inc/BGN.hpp
  2. 1 0
      bgn2/inc/Curvepoint.hpp
  3. 8 8
      bgn2/src/BGN.cpp
  4. 5 5
      bgn2/src/Curvepoint.cpp
  5. 3 3
      bgn2/src/PublicKey.cpp
  6. 0 12
      bgn2/src/Quadripoint.cpp

+ 4 - 4
bgn2/inc/BGN.hpp

@@ -29,12 +29,12 @@ class BGN
         TwistBipoint rerandomize(const TwistBipoint& a) const;
         Quadripoint rerandomize(const Quadripoint& a) const;
 
-        const PublicKey& get_public_key() const;
-        const PrivateKey& get_private_key() const;
+        const BGNPublicKey& get_public_key() const;
+        const BGNPrivateKey& get_private_key() const;
 
 	private:
-		PublicKey public_key;
-		PrivateKey private_key;
+		BGNPublicKey public_key;
+		BGNPrivateKey private_key;
 };
 
 #endif /* __BGN_HPP */

+ 1 - 0
bgn2/inc/Curvepoint.hpp

@@ -4,6 +4,7 @@
 #include <ostream>
 #include <functional>
 
+#include "Scalar.hpp"
 #include "print_helpers.hpp"
 
 extern "C" {

+ 8 - 8
bgn2/src/BGN.cpp

@@ -103,19 +103,19 @@ Quadripoint BGN::homomorphic_multiplication(const CurveBipoint& a, const TwistBi
 	return public_key.homomorphic_multiplication(a, b);
 }
 
-void BGN::rerandomize(CurveBipoint& G_element) const
+CurveBipoint BGN::rerandomize(const CurveBipoint& G_element) const
 {
-    public_key.rerandomize(G_element);
+    return public_key.rerandomize(G_element);
 }
 
-void BGN::rerandomize(TwistBipoint& H_element) const
+TwistBipoint BGN::rerandomize(const TwistBipoint& H_element) const
 {
-    public_key.rerandomize(H_element);
+    return public_key.rerandomize(H_element);
 }
 
-void BGN::rerandomize(Quadripoint& Gt_element) const
+Quadripoint BGN::rerandomize(const Quadripoint& Gt_element) const
 {
-    public_key.rerandomize(Gt_element);
+    return public_key.rerandomize(Gt_element);
 }
 
 Scalar BGN::decrypt(const CurveBipoint& ciphertext)
@@ -133,12 +133,12 @@ Scalar BGN::decrypt(const Quadripoint& ciphertext)
 	return private_key.decrypt(ciphertext);
 }
 
-const PublicKey& BGN::get_public_key() const
+const BGNPublicKey& BGN::get_public_key() const
 {
 	return public_key;
 }
 
-const PrivateKey& BGN::get_private_key() const
+const BGNPrivateKey& BGN::get_private_key() const
 {
     return private_key;
 }

+ 5 - 5
bgn2/src/Curvepoint.cpp

@@ -14,7 +14,7 @@ Curvepoint Curvepoint::operator+(const Curvepoint& b) const
 {
     Curvepoint retval;
 
-    if (equal(point, b.point))
+    if (*this == b)
         curvepoint_fp_double(retval.point, point);
     else
         curvepoint_fp_add_vartime(retval.point, point, b.point);
@@ -85,12 +85,12 @@ bool Curvepoint::operator<(const Curvepoint& b) const
 
     for (int i = 11; i >= 0; i--)
     {
-        if (affine_this_point->m_x[i] > affine_b_point->m_x[i])
+        if (affine_this_point->m_x->v[i] > affine_b_point->m_x->v[i])
         {
             lessThan[0] = false;
             break;
         }
-        if (affine_this_point->m_x[i] < affine_b_point->m_x[i])
+        if (affine_this_point->m_x->v[i] < affine_b_point->m_x->v[i])
         {
             lessThan[0] = true;
             break;
@@ -99,12 +99,12 @@ bool Curvepoint::operator<(const Curvepoint& b) const
 
     for (int i = 11; i >= 0; i--)
     {
-        if (affine_this_point->m_y[i] > affine_b_point->m_y[i])
+        if (affine_this_point->m_y->v[i] > affine_b_point->m_y->v[i])
         {
             lessThan[1] = false;
             break;
         }
-        if (affine_this_point->m_y[i] < affine_b_point->m_y[i])
+        if (affine_this_point->m_y->v[i] < affine_b_point->m_y->v[i])
         {
             lessThan[1] = true;
             break;

+ 3 - 3
bgn2/src/PublicKey.cpp

@@ -92,7 +92,7 @@ Quadripoint BGNPublicKey::homomorphic_multiplication(const CurveBipoint& a, cons
     return pairing(a, b) + random_mask;
 }
 
-CurveBipoint rerandomize(const CurveBipoint& a) const
+CurveBipoint BGNPublicKey::rerandomize(const CurveBipoint& a) const
 {
     Scalar lambda;
     lambda.set_random();
@@ -103,7 +103,7 @@ CurveBipoint rerandomize(const CurveBipoint& a) const
     return a + random_mask;
 }
 
-TwistBipoint rerandomize(const TwistBipoint& a) const
+TwistBipoint BGNPublicKey::rerandomize(const TwistBipoint& a) const
 {
     Scalar lambda;
     lambda.set_random();
@@ -114,7 +114,7 @@ TwistBipoint rerandomize(const TwistBipoint& a) const
     return a + random_mask;
 }
 
-Quadripoint rerandomize(const Quadripoint& a) const
+Quadripoint BGNPublicKey::rerandomize(const Quadripoint& a) const
 {
     Quadripoint random_mask;
     CurveBipoint random_mask_curve;

+ 0 - 12
bgn2/src/Quadripoint.cpp

@@ -82,18 +82,6 @@ bool Quadripoint::operator!=(const Quadripoint& b) const
 	return !(*this == b);
 }
 
-Quadripoint Quadripoint::square() const
-{
-	Quadripoint retval;
-	
-	fp12e_square(retval[0], point[0]);
-	fp12e_square(retval[1], point[1]);
-	fp12e_square(retval[2], point[2]);
-	fp12e_square(retval[3], point[3]);
-
-	return retval;	
-}
-
 std::ostream& operator<<(std::ostream& os, const Quadripoint& output)
 {
 	os << "{[";