Browse Source

Added functionality to allow new user proofs to work

tristangurtler 3 years ago
parent
commit
07b933c9dd
2 changed files with 14 additions and 2 deletions
  1. 2 1
      bgn2/inc/PublicKey.hpp
  2. 12 1
      bgn2/src/PublicKey.cpp

+ 2 - 1
bgn2/inc/PublicKey.hpp

@@ -14,7 +14,8 @@ class BGNPublicKey
 		void encrypt(CurveBipoint& G_element, const Scalar& cleartext) const;
 		void encrypt(TwistBipoint& H_element, const Scalar& cleartext) const;
 		void encrypt(CurveBipoint& G_element, TwistBipoint& H_element, const Scalar& cleartext) const;
-		CurveBipoint encrypt(Scalar& lambda, const Scalar& cleartext) const;
+		CurveBipoint curveEncrypt(Scalar& lambda, const Scalar& cleartext) const;
+		TwistBipoint twistEncrypt(Scalar& lambda, const Scalar& cleartext) const;
 
 		CurveBipoint homomorphic_addition(const CurveBipoint& a, const CurveBipoint& b) const;
 		TwistBipoint homomorphic_addition(const TwistBipoint& a, const TwistBipoint& b) const;

+ 12 - 1
bgn2/src/PublicKey.cpp

@@ -18,7 +18,7 @@ void BGNPublicKey::encrypt(CurveBipoint& G_element, const Scalar& cleartext) con
     G_element = cleartext_as_element + random_mask;
 }
 
-CurveBipoint BGNPublicKey::encrypt(Scalar& lambda, const Scalar& cleartext) const
+CurveBipoint BGNPublicKey::curveEncrypt(Scalar& lambda, const Scalar& cleartext) const
 {
     lambda.set_random();
 
@@ -29,6 +29,17 @@ CurveBipoint BGNPublicKey::encrypt(Scalar& lambda, const Scalar& cleartext) cons
     return cleartext_as_element + random_mask;
 }
 
+TwistBipoint BGNPublicKey::twistEncrypt(Scalar& lambda, const Scalar& cleartext) const
+{
+    lambda.set_random();
+
+    TwistBipoint cleartext_as_element, random_mask;
+    cleartext_as_element = get_bipoint_twistgen() * cleartext;
+    random_mask = get_bipoint_twist_subgroup_gen() * lambda;
+
+    return cleartext_as_element + random_mask;
+}
+
 void BGNPublicKey::encrypt(TwistBipoint& H_element, const Scalar& cleartext) const
 {
     Scalar lambda;