Browse Source

Make CDPF::is_zero work for both RegAS and RegXS (as intended)

Ian Goldberg 1 year ago
parent
commit
57a1dfd6cb
2 changed files with 7 additions and 1 deletions
  1. 4 0
      cdpf.hpp
  2. 3 1
      cdpf.tcc

+ 4 - 0
cdpf.hpp

@@ -114,6 +114,10 @@ struct CDPF : public DPF {
     // this in the protocol, but it's useful for testing.
     DPFnode leaf(value_t input, size_t &aes_ops) const;
 
+    // Get the appropriate (RegXS or RegAS) target
+    inline void get_target(RegAS &target) const { target = as_target; }
+    inline void get_target(RegXS &target) const { target = xs_target; }
+
     // Compare the given additively shared element to 0.  The output is
     // a triple of bit shares; the first is a share of 1 iff the
     // reconstruction of the element is negative; the second iff it is

+ 3 - 1
cdpf.tcc

@@ -59,7 +59,9 @@ RegBS CDPF::is_zero(MPCTIO &tio, yield_t &yield,
     // Reconstruct S = target-x
     // The server does nothing in this protocol
     if (tio.player() < 2) {
-        T S_share = as_target - x;
+        T S_share;
+        get_target(S_share);
+        S_share -= x;
         tio.iostream_peer() << S_share;
         yield();
         T peer_S_share;