"Fossies" - the Fresh Open Source Software Archive

Member "qt-everywhere-src-6.3.1/qtwebengine/src/3rdparty/chromium/third_party/private_membership/patches/0001-private-membership-chromium-required-changes.patch" (8 Jun 2022, 11313 Bytes) of package /linux/misc/qt-everywhere-src-6.3.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 From e1c9aea9410c3ecc240d5c73049e957b9901fedd Mon Sep 17 00:00:00 2001
    2 From: amraboelkher <amraboelkher@chromium.org>
    3 Date: Thu, 18 Mar 2021 23:44:08 +0100
    4 Subject: [PATCH] 0001-private-membership-chromium-required-changes.patch
    5 
    6 ---
    7  src/internal/crypto_utils.h                   |  1 +
    8  src/internal/encrypted_bucket_id.cc           |  6 +++-
    9  src/internal/encrypted_bucket_id_test.cc      |  2 +-
   10  src/internal/hashed_bucket_id_test.cc         |  4 +--
   11  src/internal/oprf_utils.cc                    | 15 ++++++---
   12  src/internal/rlwe_id_utils.cc                 |  6 +++-
   13  .../regression_test_data.proto                |  2 ++
   14  src/internal/utils.cc                         |  3 +-
   15  src/membership_response_map_test.cc           |  4 +--
   16  src/private_membership.proto                  |  2 ++
   17  src/private_membership_rlwe.proto             |  2 ++
   18  src/private_membership_rlwe_client.cc         | 32 +++++++++++--------
   19  12 files changed, 52 insertions(+), 27 deletions(-)
   20 
   21 diff --git a/src/internal/crypto_utils.h b/src/internal/crypto_utils.h
   22 index fe7fda6..c755bd7 100644
   23 --- a/src/internal/crypto_utils.h
   24 +++ b/src/internal/crypto_utils.h
   25 @@ -15,6 +15,7 @@
   26  #ifndef THIRD_PARTY_PRIVATE_MEMBERSHIP_SRC_INTERNAL_CRYPTO_UTILS_H_
   27  #define THIRD_PARTY_PRIVATE_MEMBERSHIP_SRC_INTERNAL_CRYPTO_UTILS_H_
   28  
   29 +#include "absl/strings/str_cat.h"
   30  #include "third_party/private-join-and-compute/src/crypto/context.h"
   31  #include "third_party/private-join-and-compute/src/crypto/ec_commutative_cipher.h"
   32  #include "third_party/private_membership/src/private_membership.pb.h"
   33 diff --git a/src/internal/encrypted_bucket_id.cc b/src/internal/encrypted_bucket_id.cc
   34 index f5f0ed9..3b46e50 100644
   35 --- a/src/internal/encrypted_bucket_id.cc
   36 +++ b/src/internal/encrypted_bucket_id.cc
   37 @@ -38,7 +38,11 @@ namespace rlwe {
   38          "ECCipher and Context must both be non-null.");
   39    }
   40    std::string full_id = HashRlwePlaintextId(id);
   41 -  RLWE_ASSIGN_OR_RETURN(std::string encrypted_id, ec_cipher->Encrypt(full_id));
   42 +  auto status_or_encrypted_id = ec_cipher->Encrypt(full_id);
   43 +  if(!status_or_encrypted_id.ok()){
   44 +      return absl::InvalidArgumentError(status_or_encrypted_id.status().message());
   45 +  }
   46 +  std::string encrypted_id = std::move(status_or_encrypted_id).ValueOrDie();
   47    return EncryptedBucketId::Create(encrypted_id, params, ctx);
   48  }
   49  
   50 diff --git a/src/internal/encrypted_bucket_id_test.cc b/src/internal/encrypted_bucket_id_test.cc
   51 index 651ef6e..1fbd3a0 100644
   52 --- a/src/internal/encrypted_bucket_id_test.cc
   53 +++ b/src/internal/encrypted_bucket_id_test.cc
   54 @@ -113,7 +113,7 @@ TEST(EncryptedBucketIdTest, ToUint32Success) {
   55    ASSERT_OK_AND_ASSIGN(auto encrypted_bucket_id,
   56                         EncryptedBucketId::Create("\xFF\xFF\xFF\xFF", 32));
   57    ASSERT_OK_AND_ASSIGN(auto x, encrypted_bucket_id.ToUint32());
   58 -  EXPECT_EQ(x, (int64{1} << 32) - 1);
   59 +  EXPECT_EQ(x, (int64_t{1} << 32) - 1);
   60  }
   61  
   62  TEST(EncryptedBucketIdTest, EqualsFalse) {
   63 diff --git a/src/internal/hashed_bucket_id_test.cc b/src/internal/hashed_bucket_id_test.cc
   64 index cb7ef82..05aa824 100644
   65 --- a/src/internal/hashed_bucket_id_test.cc
   66 +++ b/src/internal/hashed_bucket_id_test.cc
   67 @@ -36,7 +36,7 @@ private_membership::rlwe::PrivateMembershipRlweQuery::HashedBucketId
   68  ApiHashedBucketId(absl::string_view hashed_bucket_id, int bit_length) {
   69    private_membership::rlwe::PrivateMembershipRlweQuery::HashedBucketId
   70        api_hashed_bucket_id;
   71 -  api_hashed_bucket_id.set_hashed_bucket_id(hashed_bucket_id);
   72 +  api_hashed_bucket_id.set_hashed_bucket_id(std::string(hashed_bucket_id));
   73    api_hashed_bucket_id.set_bit_length(bit_length);
   74    return api_hashed_bucket_id;
   75  }
   76 @@ -128,7 +128,7 @@ TEST(HashedBucketId, ToApiProto) {
   77        api_proto = ApiHashedBucketId("abcd", 32);
   78    ASSERT_OK_AND_ASSIGN(HashedBucketId id,
   79                         HashedBucketId::CreateFromApiProto(api_proto));
   80 -  EXPECT_THAT(id.ToApiProto(), EqualsProto(api_proto));
   81 +  EXPECT_EQ(id.ToApiProto().SerializeAsString(), api_proto.SerializeAsString());
   82  }
   83  
   84  TEST(HashedBucketIdTest, EqualsFalse) {
   85 diff --git a/src/internal/oprf_utils.cc b/src/internal/oprf_utils.cc
   86 index e6dd9fd..b6b6a5d 100644
   87 --- a/src/internal/oprf_utils.cc
   88 +++ b/src/internal/oprf_utils.cc
   89 @@ -23,11 +23,16 @@ namespace private_membership {
   90      private_join_and_compute::ECCommutativeCipher* ec_cipher) {
   91    DoublyEncryptedId doubly_encrypted_id;
   92  
   93 -  doubly_encrypted_id.set_queried_encrypted_id(encrypted_id);
   94 -
   95 -  RLWE_ASSIGN_OR_RETURN(auto reencrypted_id,
   96 -                        ec_cipher->ReEncrypt(std::string(encrypted_id)));
   97 -  doubly_encrypted_id.set_doubly_encrypted_id(reencrypted_id);
   98 +  doubly_encrypted_id.set_queried_encrypted_id(std::string(encrypted_id));
   99 +
  100 +  auto status_or_reencrypted_id =
  101 +      ec_cipher->ReEncrypt(std::string(encrypted_id));
  102 +  if (!status_or_reencrypted_id.ok()) {
  103 +    return absl::InvalidArgumentError(
  104 +        status_or_reencrypted_id.status().message());
  105 +  }
  106 +  auto reencrypted_id = std::move(status_or_reencrypted_id).ValueOrDie();
  107 +  doubly_encrypted_id.set_doubly_encrypted_id(std::string(reencrypted_id));
  108  
  109    return doubly_encrypted_id;
  110  }
  111 diff --git a/src/internal/rlwe_id_utils.cc b/src/internal/rlwe_id_utils.cc
  112 index 327c68e..67cc4f9 100644
  113 --- a/src/internal/rlwe_id_utils.cc
  114 +++ b/src/internal/rlwe_id_utils.cc
  115 @@ -32,7 +32,11 @@ namespace rlwe {
  116          "ECCipher and Context should both be non-null.");
  117    }
  118    std::string full_id = rlwe::HashRlwePlaintextId(id);
  119 -  RLWE_ASSIGN_OR_RETURN(std::string encrypted_id, ec_cipher->Encrypt(full_id));
  120 +  auto status_or_encrypted_id = ec_cipher->Encrypt(full_id);
  121 +  if(!status_or_encrypted_id.ok()){
  122 +      return absl::InvalidArgumentError(status_or_encrypted_id.status().message());
  123 +  }
  124 +  std::string encrypted_id = std::move(status_or_encrypted_id).ValueOrDie();
  125    return ComputeBucketStoredEncryptedId(encrypted_id, params, ctx);
  126  }
  127  
  128 diff --git a/src/internal/testing/regression_test_data/regression_test_data.proto b/src/internal/testing/regression_test_data/regression_test_data.proto
  129 index 30b0247..023e6e7 100644
  130 --- a/src/internal/testing/regression_test_data/regression_test_data.proto
  131 +++ b/src/internal/testing/regression_test_data/regression_test_data.proto
  132 @@ -1,5 +1,7 @@
  133  syntax = "proto3";
  134  
  135 +option optimize_for = LITE_RUNTIME;
  136 +
  137  package private_membership.rlwe;
  138  
  139  import "private_membership_rlwe.proto";
  140 diff --git a/src/internal/utils.cc b/src/internal/utils.cc
  141 index c0ad4e1..f56996f 100644
  142 --- a/src/internal/utils.cc
  143 +++ b/src/internal/utils.cc
  144 @@ -28,7 +28,8 @@ namespace rlwe {
  145    }
  146    int ceiled_byte_length = (bit_length - 1) / 8 + 1;
  147    std::string res(in.begin(), in.begin() + ceiled_byte_length);
  148 -  if (int remainder_bit_count = bit_length % 8; remainder_bit_count > 0) {
  149 +  int remainder_bit_count = bit_length % 8;
  150 +  if (remainder_bit_count > 0) {
  151      int mask = (1 << remainder_bit_count) - 1;
  152      res[res.size() - 1] &= (mask << (8 - remainder_bit_count));
  153    }
  154 diff --git a/src/membership_response_map_test.cc b/src/membership_response_map_test.cc
  155 index b58eaeb..210915f 100644
  156 --- a/src/membership_response_map_test.cc
  157 +++ b/src/membership_response_map_test.cc
  158 @@ -28,8 +28,8 @@ using ::rlwe::testing::EqualsProto;
  159  RlwePlaintextId CreateRlwePlaintextId(absl::string_view non_sensitive_id,
  160                                        absl::string_view sensitive_id) {
  161    RlwePlaintextId id;
  162 -  id.set_non_sensitive_id(non_sensitive_id);
  163 -  id.set_sensitive_id(sensitive_id);
  164 +  id.set_non_sensitive_id(std::string(non_sensitive_id));
  165 +  id.set_sensitive_id(std::string(sensitive_id));
  166    return id;
  167  }
  168  
  169 diff --git a/src/private_membership.proto b/src/private_membership.proto
  170 index c6c3bf1..088b4c2 100644
  171 --- a/src/private_membership.proto
  172 +++ b/src/private_membership.proto
  173 @@ -14,6 +14,8 @@
  174  
  175  syntax = "proto3";
  176  
  177 +option optimize_for = LITE_RUNTIME;
  178 +
  179  package private_membership;
  180  
  181  // An enum describing different types of available hash functions.
  182 diff --git a/src/private_membership_rlwe.proto b/src/private_membership_rlwe.proto
  183 index b5415bd..69070b1 100644
  184 --- a/src/private_membership_rlwe.proto
  185 +++ b/src/private_membership_rlwe.proto
  186 @@ -14,6 +14,8 @@
  187  
  188  syntax = "proto3";
  189  
  190 +option optimize_for = LITE_RUNTIME;
  191 +
  192  package private_membership.rlwe;
  193  
  194  import "private_membership.proto";
  195 diff --git a/src/private_membership_rlwe_client.cc b/src/private_membership_rlwe_client.cc
  196 index 1d31fc2..0b21fbf 100644
  197 --- a/src/private_membership_rlwe_client.cc
  198 +++ b/src/private_membership_rlwe_client.cc
  199 @@ -80,18 +80,22 @@ PrivateMembershipRlweClient::CreateInternal(
  200  
  201    // Create the cipher with new key or from existing key depending on whether
  202    // the key was provided.
  203 -  RLWE_ASSIGN_OR_RETURN(
  204 -      auto ec_cipher,
  205 -      ec_cipher_key.has_value()
  206 -          ? private_join_and_compute::ECCommutativeCipher::CreateFromKey(
  207 -                kCurveId, ec_cipher_key.value(),
  208 -                private_join_and_compute::ECCommutativeCipher::HashType::SHA256)
  209 -          : private_join_and_compute::ECCommutativeCipher::CreateWithNewKey(
  210 -                kCurveId, private_join_and_compute::ECCommutativeCipher::HashType::SHA256));
  211 -  return absl::WrapUnique<PrivateMembershipRlweClient>(
  212 -      new PrivateMembershipRlweClient(use_case, unique_plaintext_ids,
  213 -                                      std::move(ec_cipher),
  214 -                                      std::move(prng_seed_generator)));
  215 +  auto status_or_ec_cipher = ec_cipher_key.has_value()
  216 +           ? private_join_and_compute::ECCommutativeCipher::CreateFromKey(
  217 +                 kCurveId, ec_cipher_key.value(),
  218 +                 private_join_and_compute::ECCommutativeCipher::HashType::SHA256)
  219 +           : private_join_and_compute::ECCommutativeCipher::CreateWithNewKey(
  220 +                kCurveId, private_join_and_compute::ECCommutativeCipher::HashType::SHA256);
  221 +
  222 +  if (!status_or_ec_cipher.ok()) {
  223 +    return absl::InvalidArgumentError(status_or_ec_cipher.status().message());
  224 +  }
  225 +  auto ec_cipher = std::move(status_or_ec_cipher).ValueOrDie();
  226 +
  227 +   return absl::WrapUnique<PrivateMembershipRlweClient>(
  228 +      new PrivateMembershipRlweClient(use_case, plaintext_ids,
  229 +                                       std::move(ec_cipher),
  230 +                                       std::move(prng_seed_generator)));
  231  }
  232  
  233  PrivateMembershipRlweClient::PrivateMembershipRlweClient(
  234 @@ -113,7 +117,7 @@ PrivateMembershipRlweClient::CreateOprfRequest() {
  235      std::string whole_id = HashRlwePlaintextId(plaintext_id);
  236      auto status_or_client_encrypted_id = ec_cipher_->Encrypt(whole_id);
  237      if (!status_or_client_encrypted_id.ok()) {
  238 -      return status_or_client_encrypted_id.status();
  239 +    return absl::InternalError(status_or_client_encrypted_id.status().message());
  240      }
  241      std::string client_encrypted_id =
  242          status_or_client_encrypted_id.ValueOrDie();
  243 @@ -201,7 +205,7 @@ PrivateMembershipRlweClient::CreateQueryRequest(
  244      auto status_or_server_encrypted_id =
  245          ec_cipher_->Decrypt(doubly_encrypted_id.doubly_encrypted_id());
  246      if (!status_or_server_encrypted_id.ok()) {
  247 -      return status_or_server_encrypted_id.status();
  248 +        return absl::InternalError(status_or_server_encrypted_id.status().message());
  249      }
  250      auto server_encrypted_id = status_or_server_encrypted_id.ValueOrDie();
  251  
  252 -- 
  253 2.31.0.rc2.261.g7f71774620-goog
  254