Skip to content

Commit

Permalink
Remove debug mode requirement and opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmturner committed Apr 29, 2024
1 parent d1dcf5f commit 90658fd
Showing 1 changed file with 26 additions and 58 deletions.
84 changes: 26 additions & 58 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ interface PrivateAggregation {
dictionary PAHistogramContribution {
required bigint bucket;
required long value;
bigint filteringId;
bigint filteringId = 0;
};

dictionary PADebugModeOptions {
Expand Down Expand Up @@ -176,8 +176,7 @@ are:
1. If |preSpecifiedParamsMap|[|batchingScope|] [=map/exists=]:
1. Set |filteringIdByteSize| to |preSpecifiedParamsMap|[|batchingScope|]'s
[=pre-specified report parameters/filtering ID byte size=].
1. If |contribution|["{{PAHistogramContribution/filteringId}}"] [=map/exists=]
and |contribution|["{{PAHistogramContribution/filteringId}}"] is not in the
1. If |contribution|["{{PAHistogramContribution/filteringId}}"] is not in the
range [0, 256<sup>|filteringIdByteSize|</sup>−1], [=exception/throw=] a
{{RangeError}}.
1. Let |entry| be a new [=contribution cache entry=] with the items:
Expand Down Expand Up @@ -863,26 +862,8 @@ Note: This section is largely copied from the
To <dfn>serialize an aggregatable report</dfn> given an [=aggregatable report=]
|report|, perform the following steps. They return a [=byte sequence=] or an
error.

1. Let |shouldUseNewReportVersion| be false.
1. If |report|'s [=aggregatable report/debug details=]'s [=debug details/
enabled=] is true:
1. [=list/For each=] |contribution| of |report|'s [=aggregatable report/
contributions=]:
1. If |contribution|["{{PAHistogramContribution/filteringId}}"] [=map/
exists=]:
1. Set |shouldUseNewReportVersion| to true.
1. [=iteration/Break=].

Note: For now, we only upgrade a report to version `"1.0"` if debug mode is
enabled and a filteringId was specified. This avoids affecting existing
flows while there are current Aggregation Service releases that do not
support reports with version `"1.0"`. We additionally require debug mode
so that the report version cannot be used to leak any new information.
Once all current Aggregation Service releases support version `"1.0"`,
we can change this behavior to always use the new report version.
1. Let |aggregationServicePayloads| be the result of [=obtaining the aggregation
service payloads=] given |report| and |shouldUseNewReportVersion|.
service payloads=] given |report|.
1. If |aggregationServicePayloads| is an error, return
|aggregationServicePayloads|.
1. Let |data| be an [=ordered map=] of the following key/value pairs:
Expand All @@ -892,8 +873,7 @@ error.
: "`aggregation_service_payloads`"
:: |aggregationServicePayloads|
: "`shared_info`"
:: The result of [=obtaining a report's shared info=] given |report| and
|shouldUseNewReportVersion|.
:: The result of [=obtaining a report's shared info=] given |report|.
1. Let |debugKey| be |report|'s [=aggregatable report/debug details=]'s [=debug
details/key=].
1. If |debugKey| is not null, [=map/set=] |data|["`debug_key`"] to |debugKey|.
Expand All @@ -904,17 +884,17 @@ error.
value to JSON bytes=] on |data|.

To <dfn>obtain the aggregation service payloads</dfn> given an [=aggregatable
report=] |report| and a [=boolean=] |shouldUseNewReportVersion|, perform the
following steps. They return a [=list=] of [=maps=] or an error.
report=] |report|, perform the following steps. They return a [=list=] of
[=maps=] or an error.
1. Let |publicKeyTuple| be the result of [=obtaining the public key for
encryption=] given |report|'s [=aggregatable report/aggregation
coordinator=].
1. If |publicKeyTuple| is an error, return |publicKeyTuple|.
1. Let (|pkR|, |keyId|) be |publicKeyTuple|.
1. Let |plaintextPayload| be the result of [=obtaining the plaintext payload=]
given |report| and |shouldUseNewReportVersion|.
given |report|.
1. Let |sharedInfo| be the result of [=obtaining a report's shared info=] given
|report| and |shouldUseNewReportVersion|.
|report|.
1. Let |encryptedPayload| be the result of [=encrypting the payload=] given
|plaintextPayload|, |pkR| and |sharedInfo|.
1. If |encryptedPayload| is an error, return |encryptedPayload|.
Expand Down Expand Up @@ -955,8 +935,7 @@ Note: The user agent is encouraged to enforce regular key rotation. If there are
random for every encryption operation.

To <dfn>obtain the plaintext payload</dfn> given an [=aggregatable report=]
|report| and a [=boolean=] |shouldUseNewReportVersion|, perform the
following steps. They return a [=byte sequence=].
|report|, perform the following steps. They return a [=byte sequence=].
1. Let |payloadData| be a new [=list=].
1. Let |contributions| be |report|'s [=aggregatable report/contributions=].
1. [=Assert=]: |contributions|' [=list/size=] is not greater than [=maximum
Expand All @@ -978,6 +957,10 @@ To <dfn>obtain the plaintext payload</dfn> given an [=aggregatable report=]
[below](#protecting-against-leaks-via-payload-size).
1. [=list/iterate|For each=] |contribution| of |report|'s [=aggregatable report/
contributions=]:
1. Let |filteringIdBitSize| be the product of 8 and |report|'s
[=aggregatable report/filtering id byte size=].
1. [=Assert=]: |contribution|["{{PAHistogramContribution/filteringId}}"]
is in the range [0, 2<sup>|filteringIdBitSize|</sup>−1].
1. Let |contributionData| be an [=ordered map=] of the following key/value
pairs:
: "`bucket`"
Expand All @@ -986,18 +969,9 @@ To <dfn>obtain the plaintext payload</dfn> given an [=aggregatable report=]
: "`value`"
:: The result of [=encoding an integer for the payload=] given
|contribution|["{{PAHistogramContribution/value}}"] and 32.
1. Let |filteringIdBitSize| be the product of 8 and |report|'s
[=aggregatable report/filtering id byte size=].
1. Let |filteringId| be 0.
1. If |contribution|["{{PAHistogramContribution/filteringId}}"]
[=map/exists=]:
1. [=Assert=]: |contribution|["{{PAHistogramContribution/filteringId}}"]
is in the range [0, 2<sup>|filteringIdBitSize|</sup>−1].
1. Set |filteringId| to
|contribution|["{{PAHistogramContribution/filteringId}}"].
1. If |shouldUseNewReportVersion|:
1. [=map/Set=] |contributionData|["`id`"] to the result of [=encoding an
integer for the payload=] given |filteringId| and
: "`id`"
:: The result of [=encoding an integer for the payload=] given
|contribution|["{{PAHistogramContribution/filteringId}}"] and
|filteringIdBitSize|.

Issue: Be consistent about bytes or bits as units here.
Expand Down Expand Up @@ -1037,8 +1011,7 @@ big-endian [=byte sequence=] of length |bitLength| / 8, left padding with zeroes
as necessary.

To <dfn>obtain a report's shared info</dfn> given an [=aggregatable report=]
|report| and a [=boolean=] |shouldUseNewReportVersion|, perform the following
steps. They return a [=string=].
|report|, perform the following steps. They return a [=string=].
1. Let |scheduledReportTime| be the [=duration from=] the [=UNIX epoch=] to
|report|'s [=aggregatable report/original report time=].
1. Let |sharedInfo| be an [=ordered map=] of the following key/value pairs:
Expand All @@ -1053,7 +1026,7 @@ steps. They return a [=string=].
:: The number of seconds in |scheduledReportTime|, rounded down to the
nearest number of whole seconds and [=serialize an integer|serialized=]
: "`version`"
:: "`1.0`" if |shouldUseNewReportVersion| and "`0.1`" otherwise
:: "`1.0`"
1. Return the result of [=serializing an infra value to a json string=] given
|sharedInfo|.

Expand Down Expand Up @@ -1369,7 +1342,7 @@ dictionary PASignalValue {
dictionary PAExtendedHistogramContribution {
required (PASignalValue or bigint) bucket;
required (PASignalValue or long) value;
bigint filteringId;
bigint filteringId = 0;
};

[Exposed=InterestGroupScriptRunnerGlobalScope, SecureContext]
Expand Down Expand Up @@ -1437,13 +1410,11 @@ event, PAExtendedHistogramContribution contribution)</dfn> method steps are:
throw=] a {{TypeError}}.
1. Otherwise, if |contribution|["{{PAHistogramContribution/value}}"] is
negative, [=exception/throw=] a {{TypeError}}.
1. If |contribution|["{{PAExtendedHistogramContribution/filteringId}}"]
[=map/exists=]:
1. Let |defaultFilteringIdByteSize| be the [=default filtering ID byte
size=].
1. If |contribution|["{{PAExtendedHistogramContribution/filteringId}}"] is
not in the range [0, 256<sup>|defaultFilteringIdByteSize|</sup>−1],
[=exception/throw=] a {{TypeError}}.
1. Let |defaultFilteringIdByteSize| be the [=default filtering ID byte
size=].
1. If |contribution|["{{PAExtendedHistogramContribution/filteringId}}"] is
not in the range [0, 256<sup>|defaultFilteringIdByteSize|</sup>−1],
[=exception/throw=] a {{TypeError}}.

Issue: Make the error types on validation issues here and above consistent
with {{PrivateAggregation/contributeToHistogram(contribution)}}.
Expand Down Expand Up @@ -2136,11 +2107,8 @@ following steps. They return a {{PAHistogramContribution}}.
:: |bucket|
: {{PAHistogramContribution/value}}
:: |value|
1. If |contribution|["{{PAExtendedHistogramContribution/filteringId}}"]
[=map/exists=]:
1. [=map/Set=]
|filledInContribution|["{{PAHistogramContribution/filteringId}}"] to
|contribution|["{{PAExtendedHistogramContribution/filteringId}}"].
: {{PAHistogramContribution/filteringId}}
:: |contribution|["{{PAExtendedHistogramContribution/filteringId}}"]
1. Return |filledInContribution|.

To <dfn>fill in the signal value</dfn> given a {{PASignalValue}} |value|, an
Expand Down

0 comments on commit 90658fd

Please sign in to comment.