1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_METRICS_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_METRICS_H_
7 
8 #include <stdint.h>
9 
10 #include "base/containers/span.h"
11 #include "third_party/blink/public/common/common_export.h"
12 
13 namespace blink {
14 
15 // DigestForMetrics, which is NOT a cryptographic hash function, takes a span of
16 // bytes as input and calculates a digest that can be used with identifiability
17 // metric reporting functions.
18 //
19 // The returned digest ...:
20 //
21 // * Is Stable: The returned digest will be consistent across different versions
22 //   of Chromium. Thus it can be persisted and meaningfully aggregated across
23 //   browser versions.
24 //
25 // * Is approximately uniformly distributed when the input is uniformly
26 //   distributed.
27 //
28 // * Is NOT optimized for any other distribution of input including narrow
29 //   integral ranges.
30 //
31 // * Is NOT collision resistant: Callers should assume that it is easy to come
32 //   up with collisions, and to come up with a pre-image given a digest.
33 //
34 // Note: This is NOT a cryptographic hash function.
35 BLINK_COMMON_EXPORT uint64_t DigestForMetrics(base::span<const uint8_t> in);
36 
37 }  // namespace blink
38 
39 #endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_PRIVACY_BUDGET_IDENTIFIABILITY_METRICS_H_
40