Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Unified Diff: components/rappor/rappor_metric.cc

Issue 1090683003: Alternative Multi-dimensional Rappor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 64-bit shift Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/rappor/bloom_filter_unittest.cc ('k') | components/rappor/rappor_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/rappor_metric.cc
diff --git a/components/rappor/rappor_metric.cc b/components/rappor/rappor_metric.cc
index 862ead8933a0612026378722dca0abeab8398242..3c368a3c98ae9820963a223632af74b904af2df7 100644
--- a/components/rappor/rappor_metric.cc
+++ b/components/rappor/rappor_metric.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/rand_util.h"
+#include "components/rappor/reports.h"
namespace rappor {
@@ -38,35 +39,7 @@ void RapporMetric::AddSample(const std::string& str) {
}
ByteVector RapporMetric::GetReport(const std::string& secret) const {
- // Generate a deterministically random mask of fake data using the
- // client's secret key + real data as a seed. The inclusion of the secret
- // in the seed avoids correlations between real and fake data.
- // The seed isn't a human-readable string.
- const std::string personalization_string = metric_name_ +
- std::string(bytes().begin(), bytes().end());
- HmacByteVectorGenerator hmac_generator(bytes().size(), secret,
- personalization_string);
- const ByteVector fake_mask =
- hmac_generator.GetWeightedRandomByteVector(parameters().fake_prob);
- ByteVector fake_bits =
- hmac_generator.GetWeightedRandomByteVector(parameters().fake_one_prob);
-
- // Redact most of the real data by replacing it with the fake data, hiding
- // and limiting the amount of information an individual client reports on.
- const ByteVector* fake_and_redacted_bits =
- ByteVectorMerge(fake_mask, bytes(), &fake_bits);
-
- // Generate biased coin flips for each bit.
- ByteVectorGenerator coin_generator(bytes().size());
- const ByteVector zero_coins =
- coin_generator.GetWeightedRandomByteVector(parameters().zero_coin_prob);
- ByteVector one_coins =
- coin_generator.GetWeightedRandomByteVector(parameters().one_coin_prob);
-
- // Create a randomized response report on the fake and redacted data, sending
- // the outcome of flipping a zero coin for the zero bits in that data, and of
- // flipping a one coin for the one bits in that data, as the final report.
- return *ByteVectorMerge(*fake_and_redacted_bits, zero_coins, &one_coins);
+ return internal::GenerateReport(secret, parameters(), bytes());
}
void RapporMetric::SetBytesForTesting(const ByteVector& bytes) {
« no previous file with comments | « components/rappor/bloom_filter_unittest.cc ('k') | components/rappor/rappor_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698