Skip to content

Conversation

@mdonaka
Copy link

@mdonaka mdonaka commented Aug 30, 2022

Summary

Update LTZ parmeter

Purpose

Allow larger values to be used to avoid ID collisions

Contents

  • Update LTZ parmeter k (32 -> 48), m (16 -> 20)
  • Fix 2^x value on LTZ
  • Fix getRoundValue

Testing Methods Performed

  • CI
  • medium test
  • 1000 rows horizontal join using mail address ID

Etc

collision probability

Assuming 1 million data, at least less than 1%. calculation

speed

Since it should be linear with respect to k, it can be estimated to be 1.5 times. But it was faster than I expected.
Larger sizes may produce different results, but this is time consuming and will be omitted here.
k is LTZ parameter. H is table row size.

H=5 H=10 H=100
k=32 9.77s 10.86s 45.41s
k=48 10.50s 11.73s 51.76s

@mdonaka mdonaka marked this pull request as ready for review August 30, 2022 12:22
@mdonaka mdonaka marked this pull request as draft August 31, 2022 04:16
@mdonaka
Copy link
Author

mdonaka commented Aug 31, 2022

I converted to draft due to unexpected behavior in testing.

Copy link
Author

@mdonaka mdonaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fixes and minor error countermeasures have been added.

@mdonaka mdonaka marked this pull request as ready for review September 1, 2022 12:25
@arukuka
Copy link
Member

arukuka commented Sep 2, 2022

A following patch may help you.
The newly added test fails because the decimal point is less than 2^{-m}.

Click to toggle contents of patch and details of failed test

b483068

diff --git a/src/ComputationContainer/FixedPoint/FixedPoint.hpp b/src/ComputationContainer/FixedPoint/FixedPoint.hpp
index e25b2f1d..0d496935 100644
--- a/src/ComputationContainer/FixedPoint/FixedPoint.hpp
+++ b/src/ComputationContainer/FixedPoint/FixedPoint.hpp
@@ -103,7 +103,18 @@ public:
             ret = std::numeric_limits<D>::max();
         }
         ret /= shift;
-        return ret.str(20, std::ios_base::fixed);
+        return ret.str(0, std::ios_base::fixed);  // optional, it prints all decimal points template because type `D` has 50 decimal places.  using other serializations may better choice.
+    }
+    T getRoundValue() const
+    {
+        D ret{this->getVal<D>()};
+        if (boost::math::isinf(ret))
+        {
+            ret = std::numeric_limits<D>::max();
+        }
+        ret /= shift;
+        ret = mp::round(ret);
+        return static_cast<T>(ret);
     }
     double getDoubleVal() const
     {
diff --git a/src/ComputationContainer/Share/Compare.cpp b/src/ComputationContainer/Share/Compare.cpp
index ca1e48d5..2c0a4132 100644
--- a/src/ComputationContainer/Share/Compare.cpp
+++ b/src/ComputationContainer/Share/Compare.cpp
@@ -57,8 +57,8 @@ bool operator==(const Share<FixedPoint> &left, const Share<FixedPoint> &right)
 {
     // |x-y|<ep <=> (x-y<ep)&(y-x<ep)
     auto epsilon = 0.0001;
-    auto x_ret = (left < right + epsilon);
-    auto y_ret = (right < left + epsilon);
+    auto x_ret = (left < right);
+    auto y_ret = (right < left);
     auto ret = (FixedPoint(1) - x_ret) * (FixedPoint(1) - y_ret);
 
     if (ret.getDoubleVal() > 0.95)
diff --git a/src/ComputationContainer/Share/Share.hpp b/src/ComputationContainer/Share/Share.hpp
index 29ba1faf..63342d77 100644
--- a/src/ComputationContainer/Share/Share.hpp
+++ b/src/ComputationContainer/Share/Share.hpp
@@ -489,7 +489,7 @@ Share<T> getLSBShare(const Share<T> &y)
     Share<T> t = y + r0 + T(2) * r_dash;
     open(t);
     T c = recons(t);
-    c = T(std::round(c.getDoubleVal())) % T(2);
+    c = T(c.getRoundValue()) % T(2);
     Share<T> b = c + r0 - T(2) * c * r0;
     return b;
 }
@@ -506,7 +506,7 @@ std::vector<Share<T>> getLSBShare(const std::vector<Share<T>> &y)
     b.reserve(y.size());
     for (int j = 0; j < static_cast<int>(c.size()); ++j)
     {
-        c[j] = T(std::round(c[j].getDoubleVal())) % T(2);
+        c[j] = T(c[j].getRoundValue()) % T(2);
         b.emplace_back(c[j] + r0[j] - T(2) * c[j] * r0[j]);
     }
 
diff --git a/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp b/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
index 77346c28..9bd47d4f 100644
--- a/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
+++ b/src/ComputationContainer/Test/IntegrationTest/ShareCompTest.hpp
@@ -544,6 +544,9 @@ TEST(ShareTest, EqualityEpsilonTest)
         auto val_d1 = static_cast<double>(val1) / (1LL << m) / n_parties;
         auto val_d2 = static_cast<double>(val2) / (1LL << m) / n_parties;
 
+        std::cerr << val_d1 << " == " << val_d2 << " : " << (val_d1 == val_d2) << std::endl;
+        std::cerr << "\t" << std::abs(val_d1 - val_d2) << std::endl;
+
         auto s1 = Share(FixedPoint(std::to_string(val_d1)));
         auto s2 = Share(FixedPoint(std::to_string(val_d2)));
computation_container1  | 4985.54 == 4985.54 : 0
computation_container1  |       7.7307e-11
computation_container1  | ./Test/IntegrationTest/ShareCompTest.hpp:553: Failure
computation_container1  | Value of: false
computation_container1  | Expected: s1 == s2
computation_container1  | Which is: true

@arukuka
Copy link
Member

arukuka commented Sep 2, 2022

@mdonaka
I forgot mention. My apologies.

@mdonaka
Copy link
Author

mdonaka commented Sep 5, 2022

The test passed, but the internal 1000 rows of data do not guarantee 100% accuracy.
I'll draft it once to do some more parameter tuning.

@mdonaka mdonaka marked this pull request as draft September 5, 2022 11:28
@mdonaka
Copy link
Author

mdonaka commented Sep 6, 2022

Parameter tuning is completed. The internal data confirmed 100% accuracy.

@mdonaka mdonaka marked this pull request as ready for review September 6, 2022 10:27
Copy link
Member

@arukuka arukuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdonaka Thank you for your contribution!
I left a comment because I had some concerns.
I would appreciate it if you could confirm it.

@arukuka arukuka force-pushed the feature/nakata/udpate_compare_param branch from 1cf8366 to fa1c97e Compare September 9, 2022 01:46
@mdonaka mdonaka force-pushed the feature/nakata/udpate_compare_param branch from fa1c97e to 71d01a0 Compare September 9, 2022 06:24
@mdonaka mdonaka force-pushed the feature/nakata/udpate_compare_param branch from 71d01a0 to 45bc76c Compare September 12, 2022 03:40
@mdonaka mdonaka merged commit 1dd0828 into main Sep 16, 2022
@mdonaka mdonaka deleted the feature/nakata/udpate_compare_param branch September 16, 2022 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants