From 88645c9710508106e2b21c434839e06624eba788 Mon Sep 17 00:00:00 2001 From: renjiez Date: Mon, 15 Jul 2024 16:34:24 +0000 Subject: [PATCH 1/7] Refactor HMSS to remove sketch params --- MODULE.bazel | 10 ++ MODULE.bazel.lock | 97 ++++-------- .../honest_majority_share_shuffle_utility.cc | 4 - .../hmss_protocol_config_config.textproto | 6 +- .../HonestMajorityShareShuffleStarter.kt | 11 +- .../daemon/mill/shareshuffle/BUILD.bazel | 1 - .../HonestMajorityShareShuffleMill.kt | 23 ++- .../v2alpha/RequisitionFulfillmentService.kt | 17 --- .../FulfillRequisitionRequestBuilder.kt | 6 +- .../service/api/v2alpha/ProtoConversions.kt | 21 +-- .../system/v1alpha/ProtoConversions.kt | 11 +- .../loadtest/dataprovider/EdpSimulator.kt | 2 +- .../measurement/testing/Requisitions.kt | 7 +- .../internal/duchy/protocol/BUILD.bazel | 11 -- .../honest_majority_share_shuffle.proto | 24 +-- .../duchy/protocol/share_shuffle_sketch.proto | 26 ---- .../share_shuffle_sketch_params.proto | 10 +- .../internal/kingdom/protocol_config.proto | 20 +-- .../system/v1alpha/computation.proto | 23 +-- ...ority_share_shuffle_utility_helper_test.cc | 6 - ...est_majority_share_shuffle_utility_test.cc | 144 ++++++------------ .../duchy/daemon/herald/HeraldTest.kt | 23 +-- .../HonestMajorityShareShuffleMillTest.kt | 66 +++++--- .../api/v2alpha/RequisitionsServiceTest.kt | 5 +- .../loadtest/dataprovider/EdpSimulatorTest.kt | 16 +- 25 files changed, 218 insertions(+), 372 deletions(-) delete mode 100644 src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch.proto diff --git a/MODULE.bazel b/MODULE.bazel index 09cd224b2a..74864483b3 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -141,6 +141,16 @@ bazel_dep( version = "0.62.0", repo_name = "wfa_measurement_proto", ) + +# DO_NOT_SUBMIT: Use version +archive_override( + module_name = "cross-media-measurement-api", + strip_prefix = "cross-media-measurement-api-e72bcd049d592c58e51276abeaa4565611b6597d", + urls = [ + "https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/e72bcd049d592c58e51276abeaa4565611b6597d.tar.gz", + ], +) + bazel_dep( name = "consent-signaling-client", version = "0.22.0", diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 2ad4b3b0e9..792a8ba8b3 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 6, - "moduleFileHash": "9b779444cb6de3a6b4023b58123f31d508f83338d83454d9f6c7bb8cc3e9f8fa", + "moduleFileHash": "4d591e3ad8e239b8fbaeb0576892b08413ecbe6d9fb595215fee139e5d787708", "flags": { "cmdRegistries": [ "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main", @@ -31,7 +31,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 185, + "line": 195, "column": 22 }, "imports": { @@ -53,7 +53,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 186, + "line": 196, "column": 15 } }, @@ -70,7 +70,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 192, + "line": 202, "column": 15 } }, @@ -103,7 +103,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 201, + "line": 211, "column": 14 } } @@ -117,7 +117,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 227, + "line": 237, "column": 20 }, "imports": { @@ -136,7 +136,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 228, + "line": 238, "column": 23 } } @@ -150,7 +150,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 236, + "line": 246, "column": 24 }, "imports": { @@ -172,7 +172,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 237, + "line": 247, "column": 15 } }, @@ -186,7 +186,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 242, + "line": 252, "column": 15 } }, @@ -200,7 +200,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 247, + "line": 257, "column": 15 } }, @@ -214,7 +214,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 252, + "line": 262, "column": 15 } }, @@ -228,7 +228,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 257, + "line": 267, "column": 15 } } @@ -242,7 +242,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 271, + "line": 281, "column": 23 }, "imports": {}, @@ -257,7 +257,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 272, + "line": 282, "column": 17 } } @@ -293,7 +293,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 281, + "line": 291, "column": 13 } }, @@ -308,7 +308,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 288, + "line": 298, "column": 13 } }, @@ -323,7 +323,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 295, + "line": 305, "column": 13 } }, @@ -338,7 +338,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 302, + "line": 312, "column": 13 } } @@ -374,7 +374,7 @@ "wfa_rules_cue": "rules_cue@0.4.0", "wfa_common_jvm": "common-jvm@_", "wfa_common_cpp": "common-cpp@0.13.0", - "wfa_measurement_proto": "cross-media-measurement-api@0.62.0", + "wfa_measurement_proto": "cross-media-measurement-api@_", "wfa_consent_signaling_client": "consent-signaling-client@0.22.0", "any_sketch": "any-sketch@0.9.0", "any_sketch_java": "any-sketch-java@0.7.0", @@ -2687,10 +2687,10 @@ } } }, - "cross-media-measurement-api@0.62.0": { + "cross-media-measurement-api@_": { "name": "cross-media-measurement-api", - "version": "0.62.0", - "key": "cross-media-measurement-api@0.62.0", + "version": "", + "key": "cross-media-measurement-api@_", "repoName": "wfa_measurement_proto", "executionPlatformsToRegister": [], "toolchainsToRegister": [], @@ -2698,10 +2698,10 @@ { "extensionBzlFile": "@wfa_measurement_proto//build:non_module_deps.bzl", "extensionName": "non_module_deps", - "usingModule": "cross-media-measurement-api@0.62.0", + "usingModule": "cross-media-measurement-api@_", "location": { - "file": "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.62.0/MODULE.bazel", - "line": 25, + "file": "@@cross-media-measurement-api~//:MODULE.bazel", + "line": 24, "column": 32 }, "imports": { @@ -2719,21 +2719,6 @@ "com_google_googleapis": "googleapis@0.0.0-bzlmod.1", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/refs/tags/v0.62.0.tar.gz" - ], - "integrity": "sha256-kc7MaqqrGXy16ifaaOmuEXrvYBTBSzY9XFctQdO5wb8=", - "strip_prefix": "cross-media-measurement-api-0.62.0", - "remote_patches": { - "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.62.0/patches/module_dot_bazel.patch": "sha256-bhHvEspMM1LRrvVPj9l4mphuNpeQHbN0ap3cSYU6gsk=" - }, - "remote_patch_strip": 0 - } } }, "consent-signaling-client@0.22.0": { @@ -2746,7 +2731,7 @@ "extensionUsages": [], "deps": { "wfa_rules_kotlin_jvm": "rules_kotlin_jvm@0.2.0", - "wfa_measurement_proto": "cross-media-measurement-api@0.62.0", + "wfa_measurement_proto": "cross-media-measurement-api@_", "wfa_common_jvm": "common-jvm@_", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -133949,34 +133934,6 @@ "recordedRepoMappingEntries": [] } }, - "@@cross-media-measurement-api~//build:non_module_deps.bzl%non_module_deps": { - "general": { - "bzlTransitiveDigest": "N9a0WLV2zhxfMK1hQc9MX/xt5KvdyYdfVQC3uE+PpJs=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "plantuml": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "downloaded_file_path": "plantuml.jar", - "sha256": "3a659c3d87ea5ebac7aadb645233176c51d0290777ebc28285dd2a35dc947752", - "urls": [ - "https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar" - ] - } - } - }, - "recordedRepoMappingEntries": [ - [ - "cross-media-measurement-api~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@gazelle~//:extensions.bzl%go_deps": { "general": { "bzlTransitiveDigest": "LU6SX6N3JGbML1A3SCpN/Pm4Pck4gYEMf63QPuiuSq8=", diff --git a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc index 9adc9b8d6d..d930410b46 100644 --- a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc +++ b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc @@ -66,10 +66,6 @@ absl::Status VerifySketchParameters(const ShareShuffleSketchParams& params) { "The ring modulus must be greater than maximum combined frequency plus " "one."); } - if (params.ring_modulus() > (1 << (8 * params.bytes_per_register()))) { - return absl::InvalidArgumentError( - "The bit length of the register is not enough to store the shares."); - } return absl::OkStatus(); } diff --git a/src/main/k8s/testing/secretfiles/hmss_protocol_config_config.textproto b/src/main/k8s/testing/secretfiles/hmss_protocol_config_config.textproto index 2a28edf794..8939a033ed 100644 --- a/src/main/k8s/testing/secretfiles/hmss_protocol_config_config.textproto +++ b/src/main/k8s/testing/secretfiles/hmss_protocol_config_config.textproto @@ -1,11 +1,9 @@ # proto-file: src/main/proto/wfa/measurement/internal/kingdom/protocol_config_config.proto # proto-message: HmssProtocolConfigConfig protocol_config { - sketch_params { - bytes_per_register: 2 - ring_modulus: 127 - } noise_mechanism: DISCRETE_GAUSSIAN + reach_and_frequency_ring_modulus: 127 + reach_ring_modulus: 127 } required_external_duchy_ids: "worker1" diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/herald/HonestMajorityShareShuffleStarter.kt b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/herald/HonestMajorityShareShuffleStarter.kt index d69f421879..45159398e3 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/herald/HonestMajorityShareShuffleStarter.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/herald/HonestMajorityShareShuffleStarter.kt @@ -44,7 +44,6 @@ import org.wfanet.measurement.internal.duchy.encryptionPublicKey import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle.Stage import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffleKt -import org.wfanet.measurement.internal.duchy.protocol.shareShuffleSketchParams import org.wfanet.measurement.system.v1alpha.Computation private const val RANDOM_SEED_LENGTH_IN_BYTES = 48 @@ -207,17 +206,11 @@ object HonestMajorityShareShuffleStarter { frequencyDpParams = measurementSpec.reachAndFrequency.frequencyPrivacyParams .toDuchyDifferentialPrivacyParams() + ringModulus = hmssConfig.reachAndFrequencyRingModulus } else { maximumFrequency = 1 reachDpParams = measurementSpec.reach.privacyParams.toDuchyDifferentialPrivacyParams() - } - - sketchParams = shareShuffleSketchParams { - registerCount = hmssConfig.sketchParams.registerCount - bytesPerRegister = hmssConfig.sketchParams.bytesPerRegister - maximumCombinedFrequency = - measurementSpec.reachAndFrequency.maximumFrequency * measurementSpec.nonceHashesCount - this.ringModulus = hmssConfig.sketchParams.ringModulus + ringModulus = hmssConfig.reachRingModulus } noiseMechanism = hmssConfig.noiseMechanism.toInternalNoiseMechanism() } diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel index 682f499eb0..a8ceaf0804 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel @@ -36,7 +36,6 @@ kt_jvm_library( "//src/main/proto/wfa/measurement/internal/duchy:differential_privacy_kt_jvm_proto", "//src/main/proto/wfa/measurement/internal/duchy/config:protocols_setup_config_kt_jvm_proto", "//src/main/proto/wfa/measurement/internal/duchy/protocol:honest_majority_share_shuffle_methods_kt_jvm_proto", - "//src/main/proto/wfa/measurement/internal/duchy/protocol:share_shuffle_sketch_kt_jvm_proto", "//src/main/proto/wfa/measurement/internal/duchy/protocol:share_shuffle_sketch_params_kt_jvm_proto", "//src/main/proto/wfa/measurement/system/v1alpha:computation_control_service_kt_jvm_grpc_proto", "//src/main/proto/wfa/measurement/system/v1alpha:computation_participants_service_kt_jvm_grpc_proto", diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt index 1ea661de49..7b950ee0de 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt @@ -80,7 +80,7 @@ import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffleKt.shufflePhaseInput import org.wfanet.measurement.internal.duchy.protocol.completeAggregationPhaseRequest import org.wfanet.measurement.internal.duchy.protocol.completeShufflePhaseRequest -import org.wfanet.measurement.internal.duchy.protocol.copy +import org.wfanet.measurement.internal.duchy.protocol.shareShuffleSketchParams import org.wfanet.measurement.system.v1alpha.ComputationControlGrpcKt.ComputationControlCoroutineStub import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt import org.wfanet.measurement.system.v1alpha.ComputationParticipantKt @@ -375,7 +375,6 @@ class HonestMajorityShareShuffleMill( val request = completeShufflePhaseRequest { val hmss = token.computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams commonRandomSeed = hmss.randomSeed xor shufflePhaseInput.peerRandomSeed order = if (hmss.role == FIRST_NON_AGGREGATOR) { @@ -420,7 +419,11 @@ class HonestMajorityShareShuffleMill( require(registerCounts.distinct().size == 1) { "All RegisterCount from requisitions must be the same. $registerCounts" } - sketchParams = hmss.parameters.sketchParams.copy { registerCount = registerCounts.first() } + sketchParams = shareShuffleSketchParams { + registerCount = registerCounts.first() + maximumCombinedFrequency = hmss.parameters.maximumFrequency * token.requisitionsCount + ringModulus = hmss.parameters.ringModulus + } } val result: CompleteShufflePhaseResponse = @@ -442,7 +445,8 @@ class HonestMajorityShareShuffleMill( ) val aggregationPhaseInput = aggregationPhaseInput { - combinedSketch += result.combinedSketchList + combinedFrequencyVectors += result.combinedSketchList + registerCount = request.sketchParams.registerCount } logWallClockDuration( @@ -474,7 +478,6 @@ class HonestMajorityShareShuffleMill( val request = completeAggregationPhaseRequest { val hmss = token.computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams maximumFrequency = hmss.parameters.maximumFrequency when (publicApiVersion) { @@ -492,7 +495,15 @@ class HonestMajorityShareShuffleMill( for (input in aggregationPhaseInputs) { sketchShares += - CompleteAggregationPhaseRequestKt.shareData { shareVector += input.combinedSketchList } + CompleteAggregationPhaseRequestKt.shareData { + shareVector += input.combinedFrequencyVectorsList + } + } + sketchParams = shareShuffleSketchParams { + require(aggregationPhaseInputs.map { it.registerCount }.distinct().size == 1) + registerCount = aggregationPhaseInputs.first().registerCount + maximumCombinedFrequency = hmss.parameters.maximumFrequency * token.requisitionsCount + ringModulus = hmss.parameters.ringModulus } } diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/service/api/v2alpha/RequisitionFulfillmentService.kt b/src/main/kotlin/org/wfanet/measurement/duchy/service/api/v2alpha/RequisitionFulfillmentService.kt index 96e097dea6..8341ea2faf 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/service/api/v2alpha/RequisitionFulfillmentService.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/service/api/v2alpha/RequisitionFulfillmentService.kt @@ -26,9 +26,7 @@ import org.wfanet.measurement.api.v2alpha.FulfillRequisitionResponse import org.wfanet.measurement.api.v2alpha.MeasurementSpec import org.wfanet.measurement.api.v2alpha.Requisition import org.wfanet.measurement.api.v2alpha.RequisitionFulfillmentGrpcKt.RequisitionFulfillmentCoroutineImplBase -import org.wfanet.measurement.api.v2alpha.SignedMessage import org.wfanet.measurement.api.v2alpha.principalFromCurrentContext -import org.wfanet.measurement.common.ProtoReflection import org.wfanet.measurement.common.consumeFirst import org.wfanet.measurement.common.grpc.grpcRequire import org.wfanet.measurement.common.grpc.grpcRequireNotNull @@ -126,21 +124,6 @@ class RequisitionFulfillmentService( } else { recordLlv2RequisitionLocally(computationToken, externalRequisitionKey, blob.blobKey) } - val seed = - if (computationToken.computationStage.hasHonestMajorityShareShuffle()) { - grpcRequire(header.honestMajorityShareShuffle.hasSecretSeed()) { - "Secret seed not be specified for HMSS protocol." - } - grpcRequire( - header.honestMajorityShareShuffle.secretSeed.typeUrl == - ProtoReflection.getTypeUrl(SignedMessage.getDescriptor()) - ) { - "ciphertext of secret seed must be of SignedMessage." - } - header.honestMajorityShareShuffle.secretSeed.ciphertext - } else { - null - } } fulfillRequisitionAtKingdom( diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/shareshuffle/v2alpha/FulfillRequisitionRequestBuilder.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/shareshuffle/v2alpha/FulfillRequisitionRequestBuilder.kt index 4e3544a7a0..eead47a96b 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/shareshuffle/v2alpha/FulfillRequisitionRequestBuilder.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/shareshuffle/v2alpha/FulfillRequisitionRequestBuilder.kt @@ -70,8 +70,8 @@ class FulfillRequisitionRequestBuilder( "Expected to find exactly one config for HonestMajorityShareShuffle. Found: ${hmssProtocolList.size}" ) - require(protocolConfig.sketchParams.ringModulus > 1) { - "HMSS ring modulus must be greater than one. Found: ${protocolConfig.sketchParams.ringModulus}" + require(protocolConfig.ringModulus > 1) { + "HMSS ring modulus must be greater than one. Found: ${protocolConfig.ringModulus}" } } @@ -105,7 +105,7 @@ class FulfillRequisitionRequestBuilder( val secretShareGeneratorRequest = secretShareGeneratorRequest { data += frequencyVector.dataList - ringModulus = protocolConfig.sketchParams.ringModulus + ringModulus = protocolConfig.ringModulus } val secretShare = diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt index 32d04e41f7..042872d3d1 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt @@ -93,7 +93,6 @@ import org.wfanet.measurement.api.v2alpha.population import org.wfanet.measurement.api.v2alpha.protocolConfig import org.wfanet.measurement.api.v2alpha.reachOnlyLiquidLegionsSketchParams import org.wfanet.measurement.api.v2alpha.setMessage -import org.wfanet.measurement.api.v2alpha.shareShuffleSketchParams import org.wfanet.measurement.api.v2alpha.signedMessage import org.wfanet.measurement.api.v2alpha.unpack import org.wfanet.measurement.common.ProtoReflection @@ -332,7 +331,7 @@ fun InternalProtocolConfig.toProtocolConfig( } } } else { - buildMpcProtocolConfig(source) + buildMpcProtocolConfig(measurementTypeCase, source) } } ProtocolConfig.MeasurementType.REACH_AND_FREQUENCY -> { @@ -349,7 +348,7 @@ fun InternalProtocolConfig.toProtocolConfig( } } } else { - buildMpcProtocolConfig(source) + buildMpcProtocolConfig(measurementTypeCase, source) } } ProtocolConfig.MeasurementType.IMPRESSION -> { @@ -395,7 +394,8 @@ fun InternalProtocolConfig.toProtocolConfig( * Builds a public [ProtocolConfig.Protocol] for MPC only from an internal [InternalProtocolConfig]. */ private fun buildMpcProtocolConfig( - protocolConfig: InternalProtocolConfig + measurementType: MeasurementSpec.MeasurementTypeCase, + protocolConfig: InternalProtocolConfig, ): ProtocolConfig.Protocol { @Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA") // Protobuf enum fields are never null. return when (protocolConfig.protocolCase) { @@ -461,11 +461,14 @@ private fun buildMpcProtocolConfig( InternalProtocolConfig.ProtocolCase.HONEST_MAJORITY_SHARE_SHUFFLE -> { protocol { honestMajorityShareShuffle = honestMajorityShareShuffle { - sketchParams = shareShuffleSketchParams { - bytesPerRegister = - protocolConfig.honestMajorityShareShuffle.sketchParams.bytesPerRegister - ringModulus = protocolConfig.honestMajorityShareShuffle.sketchParams.ringModulus - } + ringModulus = + when (measurementType) { + MeasurementSpec.MeasurementTypeCase.REACH_AND_FREQUENCY -> + protocolConfig.honestMajorityShareShuffle.reachAndFrequencyRingModulus + MeasurementSpec.MeasurementTypeCase.REACH -> + protocolConfig.honestMajorityShareShuffle.reachRingModulus + else -> error("Unsupported measurement type for ring modulus.") + } noiseMechanism = protocolConfig.honestMajorityShareShuffle.noiseMechanism.toNoiseMechanism() } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ProtoConversions.kt index 903c098b46..1ef16e4e84 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ProtoConversions.kt @@ -31,7 +31,6 @@ import org.wfanet.measurement.internal.kingdom.Requisition as InternalRequisitio import org.wfanet.measurement.system.v1alpha.Computation import org.wfanet.measurement.system.v1alpha.Computation.MpcProtocolConfig.NoiseMechanism import org.wfanet.measurement.system.v1alpha.ComputationKey -import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.HonestMajorityShareShuffleKt.shareShuffleSketchParams import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.LiquidLegionsV2Kt.liquidLegionsSketchParams import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.LiquidLegionsV2Kt.mpcNoise import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.honestMajorityShareShuffle @@ -243,7 +242,7 @@ fun InternalMeasurement.toSystemComputation(): Computation { * Builds a [Computation.MpcProtocolConfig] using the [InternalDuchyProtocolConfig] and * [InternalProtocolConfig]. */ -fun buildMpcProtocolConfig( +private fun buildMpcProtocolConfig( duchyProtocolConfig: InternalDuchyProtocolConfig, protocolConfig: InternalProtocolConfig, ): Computation.MpcProtocolConfig { @@ -318,11 +317,9 @@ fun buildMpcProtocolConfig( InternalProtocolConfig.ProtocolCase.HONEST_MAJORITY_SHARE_SHUFFLE -> { mpcProtocolConfig { honestMajorityShareShuffle = honestMajorityShareShuffle { - sketchParams = shareShuffleSketchParams { - bytesPerRegister = - protocolConfig.honestMajorityShareShuffle.sketchParams.bytesPerRegister - ringModulus = protocolConfig.honestMajorityShareShuffle.sketchParams.ringModulus - } + reachAndFrequencyRingModulus = + protocolConfig.honestMajorityShareShuffle.reachAndFrequencyRingModulus + reachRingModulus = protocolConfig.honestMajorityShareShuffle.reachRingModulus noiseMechanism = protocolConfig.honestMajorityShareShuffle.noiseMechanism.toSystemNoiseMechanism() } diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt index e0f74c69c7..37f66d2542 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt @@ -1261,7 +1261,7 @@ class EdpSimulator( val secretShareGeneratorRequest = secretShareGeneratorRequest { data += frequencyVector.toList() - ringModulus = protocolConfig.sketchParams.ringModulus + ringModulus = protocolConfig.ringModulus } val secretShare = diff --git a/src/main/kotlin/org/wfanet/measurement/testing/Requisitions.kt b/src/main/kotlin/org/wfanet/measurement/testing/Requisitions.kt index 79b296592f..12c224a707 100644 --- a/src/main/kotlin/org/wfanet/measurement/testing/Requisitions.kt +++ b/src/main/kotlin/org/wfanet/measurement/testing/Requisitions.kt @@ -41,7 +41,6 @@ import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.protocolConfig import org.wfanet.measurement.api.v2alpha.requisition import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.shareShuffleSketchParams import org.wfanet.measurement.common.OpenEndTimeRange import org.wfanet.measurement.common.crypto.Hashing import org.wfanet.measurement.common.crypto.SigningKeyHandle @@ -216,10 +215,6 @@ object Requisitions { ) val NOISE_MECHANISM = ProtocolConfig.NoiseMechanism.DISCRETE_GAUSSIAN - val HONEST_MAJORITY_SHARE_SHUFFLE_SKETCH_PARAMS = shareShuffleSketchParams { - bytesPerRegister = 1 - ringModulus = 127 - } val HMSS_REQUISITION = requisition { name = "${EDP_NAME}/requisitions/foo" @@ -234,7 +229,7 @@ object Requisitions { honestMajorityShareShuffle = ProtocolConfigKt.honestMajorityShareShuffle { noiseMechanism = NOISE_MECHANISM - sketchParams = HONEST_MAJORITY_SHARE_SHUFFLE_SKETCH_PARAMS + ringModulus = 127 } } } diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel index 974e704126..8b157bdc08 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel @@ -172,14 +172,3 @@ kt_jvm_proto_library( name = "honest_majority_share_shuffle_methods_kt_jvm_proto", deps = [":honest_majority_share_shuffle_methods_proto"], ) - -# TODO(@renjiez): replace with target in any-sketch-java. -proto_library( - name = "share_shuffle_sketch_proto", - srcs = ["share_shuffle_sketch.proto"], -) - -kt_jvm_proto_library( - name = "share_shuffle_sketch_kt_jvm_proto", - deps = ["share_shuffle_sketch_proto"], -) diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto index 1a996a4f24..05e706d691 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto @@ -20,7 +20,6 @@ import "wfa/measurement/internal/duchy/config/protocols_setup_config.proto"; import "wfa/measurement/internal/duchy/crypto.proto"; import "wfa/measurement/internal/duchy/differential_privacy.proto"; import "wfa/measurement/internal/duchy/noise_mechanism.proto"; -import "wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto"; option java_package = "org.wfanet.measurement.internal.duchy.protocol"; option java_multiple_files = true; @@ -110,7 +109,7 @@ message HonestMajorityShareShuffle { // Non-aggregators execute following actions: // - // 1. Combine sketch shares from EDPs: Expand all requisition seeds + // 1. Combine FrequencyVector shares from EDPs: Expand all requisition seeds // into shares. Combine all requisition shares. // // 2. Add noise: Generate own noise share N_0 from common random seed. @@ -140,10 +139,9 @@ message HonestMajorityShareShuffle { // Parameters used in this computation. message Parameters { - // The maximum frequency to reveal in the histogram. int32 maximum_frequency = 1; - // Parameters for secret sharing sketches. - ShareShuffleSketchParams sketch_params = 2; + // The modulus used in the protocol. + int32 ring_modulus = 2; // Differential privacy parameters for reach noise generation. DifferentialPrivacyParams reach_dp_params = 3; // Differential privacy parameters for frequency noise generation. @@ -181,7 +179,7 @@ message HonestMajorityShareShuffle { // CMMS public API. bytes secret_seed_ciphertext = 2; - // The number of registers in the sketch. + // The number of registers in the FrequencyVector. int64 register_count = 3; // Resource name of the `Certificate` from the public api belonging to the @@ -194,8 +192,12 @@ message HonestMajorityShareShuffle { // The input message of aggregation phase. message AggregationPhaseInput { - // Combined sketches from non-aggregators. - repeated uint32 combined_sketch = 1; + // Combined FrequencyVectors from non-aggregators. + repeated uint32 combined_frequency_vectors = 1; + // The number of registers in the sketch. + // + // It is provided from RequisitionFulfillment. + int64 register_count = 2; } // Details about a particular attempt of running a stage of the @@ -215,9 +217,9 @@ message HonestMajorityShareShuffle { // A mapping of the name of a duchy to the BlobId corresponding to the // ComputationBlobDependency.OUTPUT BLOB where it will be written. // - // Upon receiving a sketch from a duchy the OUTPUT reference with the id - // found in this map is updated with the local copy of the blob. When all - // the output references have a path the worker can move onto the next + // Upon receiving a FrequencyVector from a duchy the OUTPUT reference with + // the id found in this map is updated with the local copy of the blob. When + // all the output references have a path the worker can move onto the next // stage. map external_duchy_local_blob_id = 1; } diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch.proto deleted file mode 100644 index 12656f0149..0000000000 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch.proto +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2023 The Cross-Media Measurement Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package wfa.measurement.internal.duchy.protocol; - -option java_package = "org.wfanet.measurement.internal.duchy.protocol"; -option java_multiple_files = true; - -// The data share of HonestMajorityShareShuffle protocol. -message ShareShuffleSketch { - // A vector of counts. - repeated uint32 data = 1; -} diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto index 2a4b0f5a61..9915986392 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto @@ -25,18 +25,12 @@ message ShareShuffleSketchParams { // The number of registers in the sketch. int64 register_count = 1; - // Length of each register in bytes. - // - // The product of `maximum_frequency` and the `nonce_hashes` count from the - // `MeasurementSpec` should be no more than 2 ^ (`bytes_per_register` * 8). - int32 bytes_per_register = 2; - // The maximum frequency of the combined sketch. Let N be the max frequency // of a sketch, and p the number of EDPs, the maximum frequency of the // combined sketch is (1 + pN). - int32 maximum_combined_frequency = 3; + int32 maximum_combined_frequency = 2; // The modulus used in the MPC protocol. It is required to be greater than // (1 + maximum_frequency). - int32 ring_modulus = 4; + int32 ring_modulus = 3; } diff --git a/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto b/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto index 2163a0d3dc..a03bbaad39 100644 --- a/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto +++ b/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto @@ -133,11 +133,16 @@ message ProtocolConfig { // Configuration for Honest Majority Share Shuffle protocols. message HonestMajorityShareShuffle { - // Parameters for sketches. - ShareShuffleSketchParams sketch_params = 1; + reserved 1; // The mechanism to generate noise by MPC nodes during computation. NoiseMechanism noise_mechanism = 2; + + // The modulus used in the protocol for ReachAndFrequency Measurement. + int32 reach_and_frequency_ring_modulus = 3; + + // The modulus used in the protocol for Reach Measurement. + int32 reach_ring_modulus = 4; } // Configuration for the specific protocol. @@ -171,13 +176,4 @@ message LiquidLegionsSketchParams { // The size of the distribution of the sampling indicator value. // Reach-Only Liquid Legions protocol ignores this field. int64 sampling_indicator_size = 3; -} - -// Parameters for a honest majority share shuffle sketch. -message ShareShuffleSketchParams { - // Length of each register in bytes. - int32 bytes_per_register = 1; - - // Secret share modulus. - int32 ring_modulus = 2; -} +} \ No newline at end of file diff --git a/src/main/proto/wfa/measurement/system/v1alpha/computation.proto b/src/main/proto/wfa/measurement/system/v1alpha/computation.proto index df51adeded..eb2073711e 100644 --- a/src/main/proto/wfa/measurement/system/v1alpha/computation.proto +++ b/src/main/proto/wfa/measurement/system/v1alpha/computation.proto @@ -166,23 +166,14 @@ message Computation { // Configuration for the Honest Majority Share Shuffle protocol. message HonestMajorityShareShuffle { - // Parameters for HonestMajorityShareShuffle sketch. - message ShareShuffleSketchParams { - // The number of registers in the sketch. - int64 register_count = 1 [(google.api.field_behavior) = REQUIRED]; - - // Length of each register in bytes. - int32 bytes_per_register = 2 [(google.api.field_behavior) = REQUIRED]; - - // The modulus used in the MPC protocol. - int32 ring_modulus = 3 [(google.api.field_behavior) = REQUIRED]; - } - // Parameters for HonestMajorityShareShuffle sketch. - ShareShuffleSketchParams sketch_params = 1 - [(google.api.field_behavior) = REQUIRED]; - + // The modulus used in the MPC protocol for ReachAndFrequency Measurement. + int32 reach_and_frequency_ring_modulus = 1 + [(google.api.field_behavior) = REQUIRED]; + // The modulus used in the MPC protocol for Reach Measurement. + int32 reach_ring_modulus = 2 + [(google.api.field_behavior) = REQUIRED]; // The mechanism to generate noise during computation. - NoiseMechanism noise_mechanism = 5 + NoiseMechanism noise_mechanism = 3 [(google.api.field_behavior) = REQUIRED]; } diff --git a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc index b0555330b1..4ceb2bf05f 100644 --- a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc +++ b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc @@ -53,7 +53,6 @@ using ::wfa::measurement::internal::duchy::protocol::common:: constexpr int kEdpCount = 5; constexpr int kRegisterCount = 10; -constexpr int kBytesPerRegister = 1; constexpr int kMaxFrequencyPerEdp = 10; constexpr int kMaxCombinedFrequency = 1 + kEdpCount * kMaxFrequencyPerEdp; constexpr int kRingModulus = 128; @@ -157,7 +156,6 @@ TEST(GenerateReachOnlyNoiseRegisters, ValidSketchParamsSucceeds) { TEST(GetShareVectorFromSketchShare, SketchShareTypeNotSetFails) { ShareShuffleSketchParams sketch_params; sketch_params.set_register_count(kRegisterCount); - sketch_params.set_bytes_per_register(kBytesPerRegister); sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); sketch_params.set_ring_modulus(kRingModulus); @@ -170,7 +168,6 @@ TEST(GetShareVectorFromSketchShare, SketchShareTypeNotSetFails) { TEST(GetShareVectorFromSketchShare, ShareFromShareDataSucceeds) { ShareShuffleSketchParams sketch_params; sketch_params.set_register_count(kRegisterCount); - sketch_params.set_bytes_per_register(kBytesPerRegister); sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); sketch_params.set_ring_modulus(kRingModulus); @@ -187,7 +184,6 @@ TEST(GetShareVectorFromSketchShare, ShareFromShareDataSucceeds) { TEST(GetShareVectorFromSketchShare, ShareFromShareSeedSucceeds) { ShareShuffleSketchParams sketch_params; sketch_params.set_register_count(kRegisterCount); - sketch_params.set_bytes_per_register(kBytesPerRegister); sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); sketch_params.set_ring_modulus(kRingModulus); @@ -228,7 +224,6 @@ TEST(GetPrngSeedFromCharVector, ValidVectorLengthSucceeds) { TEST(GenerateShareFromSeed, InvalidSeedFails) { ShareShuffleSketchParams sketch_params; sketch_params.set_register_count(kRegisterCount); - sketch_params.set_bytes_per_register(kBytesPerRegister); sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); sketch_params.set_ring_modulus(kRingModulus); PrngSeed seed; @@ -241,7 +236,6 @@ TEST(GenerateShareFromSeed, InvalidSeedFails) { TEST(GenerateShareFromSeed, ValidSeedSucceeds) { ShareShuffleSketchParams sketch_params; sketch_params.set_register_count(kRegisterCount); - sketch_params.set_bytes_per_register(kBytesPerRegister); sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); sketch_params.set_ring_modulus(kRingModulus); PrngSeed seed; diff --git a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc index 495049ff76..27e7705065 100644 --- a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc +++ b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc @@ -69,7 +69,6 @@ using ::wfa::measurement::internal::duchy::protocol::common:: constexpr int kEdpCount = 5; constexpr int kRegisterCount = 100; -constexpr int kBytesPerRegister = 1; constexpr int kMaxFrequencyPerEdp = 2; constexpr int kMaxCombinedFrequency = 1 + kEdpCount * kMaxFrequencyPerEdp; constexpr int kRingModulus = 127; @@ -104,8 +103,7 @@ class ShufflePhaseTestData { *request_.mutable_common_random_seed() = std::string(kBytesPerAes256Key + kBytesPerAes256Iv, 'a'); request_.set_noise_mechanism(NoiseMechanism::DISCRETE_GAUSSIAN); - SetSketchParams(kRegisterCount, kBytesPerRegister, kMaxCombinedFrequency, - kRingModulus); + SetSketchParams(kRegisterCount, kMaxCombinedFrequency, kRingModulus); SetDifferentialPrivacyParams(kEpsilon, kDelta); PrngSeed seed = GenerateRandomSeed(); @@ -121,11 +119,9 @@ class ShufflePhaseTestData { request_.set_order(order); } - void SetSketchParams(int register_count, int bytes_per_register, - int maximum_combined_frequency, int ring_modulus) { + void SetSketchParams(int register_count, int maximum_combined_frequency, + int ring_modulus) { request_.mutable_sketch_params()->set_register_count(register_count); - request_.mutable_sketch_params()->set_bytes_per_register( - bytes_per_register); request_.mutable_sketch_params()->set_maximum_combined_frequency( maximum_combined_frequency); request_.mutable_sketch_params()->set_ring_modulus(ring_modulus); @@ -194,7 +190,7 @@ class ShufflePhaseTestData { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/0, /*maximum_combined_frequency=*/10, /*ring_modulus=*/128); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -204,7 +200,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/10, /*ring_modulus=*/1); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -215,7 +211,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusAndMaxFrequencyPairFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/4, /*ring_modulus=*/5); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -223,22 +219,11 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); } -TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, - RingModulusDoesNotFitTheRegisterFails) { - ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, - /*maximum_combined_frequency=*/127, - /*ring_modulus=*/257); - test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); - EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), - StatusIs(absl::StatusCode::kInvalidArgument, "bit length")); -} - TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InputSizeDoesNotMatchTheConfigFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::vector share_data(kRegisterCount - 1, 1); test_data.AddShareToSketchShares(share_data); @@ -248,8 +233,8 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, EmptySketchSharesFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "empty")); @@ -268,8 +253,8 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, NonAggregatorOrderNotSpecifiedAndDpParamsSpecifiedFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetDifferentialPrivacyParams(kEpsilon, kDelta); std::vector share_data(kRegisterCount, 1); test_data.AddShareToSketchShares(share_data); @@ -383,8 +368,8 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetDifferentialPrivacyParams(kEpsilon, kDelta); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -604,7 +589,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/0, /*maximum_combined_frequency=*/10, /*ring_modulus=*/128); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -614,7 +599,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/10, /*ring_modulus=*/1); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -625,7 +610,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusAndMaxFrequencyPairFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/4, /*ring_modulus=*/5); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -633,20 +618,9 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); } -TEST(ReachOnlyShufflePhaseAtNonAggregator, - RingModulusDoesNotFitTheRegisterFails) { - ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, - /*maximum_combined_frequency=*/127, - /*ring_modulus=*/257); - test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); - EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), - StatusIs(absl::StatusCode::kInvalidArgument, "bit length")); -} - TEST(ReachOnlyShufflePhaseAtNonAggregator, NonPrimeRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/127, /*ring_modulus=*/130); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -657,8 +631,8 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, NonPrimeRingModulusFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InputSizeDoesNotMatchTheConfigFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::vector share_data(kRegisterCount - 1, 1); test_data.AddShareToSketchShares(share_data); @@ -668,8 +642,8 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, EmptySketchSharesFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "empty")); @@ -687,8 +661,8 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, NonAggregatorOrderNotSpecifiedAndDpParamsSpecifiedFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetReachOnlyDifferentialPrivacyParams(kEpsilon, kDelta); std::vector share_data(kRegisterCount, 1); test_data.AddShareToSketchShares(share_data); @@ -839,8 +813,8 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kBytesPerRegister, - kMaxCombinedFrequency, kRingModulus); + test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetReachOnlyDifferentialPrivacyParams(kEpsilon, kDelta); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -1071,8 +1045,7 @@ class AggregationPhaseTestData { request_.set_vid_sampling_interval_width(kVidSamplingIntervalWidth); request_.set_noise_mechanism(NoiseMechanism::DISCRETE_GAUSSIAN); SetDifferentialPrivacyParams(kEpsilon, kDelta); - SetSketchParams(kRegisterCount, kBytesPerRegister, kMaxCombinedFrequency, - kRingModulus); + SetSketchParams(kRegisterCount, kMaxCombinedFrequency, kRingModulus); SetMaximumFrequency(kMaxFrequencyPerEdp); } @@ -1080,11 +1053,9 @@ class AggregationPhaseTestData { request_.set_maximum_frequency(maximum_frequency); } - void SetSketchParams(int register_count, int bytes_per_register, - int maximum_combined_frequency, int ring_modulus) { + void SetSketchParams(int register_count, int maximum_combined_frequency, + int ring_modulus) { request_.mutable_sketch_params()->set_register_count(register_count); - request_.mutable_sketch_params()->set_bytes_per_register( - bytes_per_register); request_.mutable_sketch_params()->set_maximum_combined_frequency( maximum_combined_frequency); request_.mutable_sketch_params()->set_ring_modulus(ring_modulus); @@ -1145,7 +1116,7 @@ class AggregationPhaseTestData { TEST(ReachAndFrequencyAggregationPhase, InvalidRegisterCountFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/0, /*maximum_combined_frequency=*/10, /*ring_modulus=*/128); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), @@ -1154,7 +1125,7 @@ TEST(ReachAndFrequencyAggregationPhase, InvalidRegisterCountFails) { TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/10, /*ring_modulus=*/1); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), @@ -1164,7 +1135,7 @@ TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusFails) { TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusAndMaxFrequencyPairFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/4, /*ring_modulus=*/5); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), @@ -1214,8 +1185,7 @@ TEST(ReachAndFrequencyAggregationPhase, CombinedSketchElementExceedsMaxCombinedFrequencyFails) { AggregationPhaseTestData test_data; int register_count = 1; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); @@ -1233,8 +1203,7 @@ TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); @@ -1259,8 +1228,7 @@ TEST(ReachAndFrequencyAggregationPhase, TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseWithDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); // Frequency offset = 2 and reach offset = 6. @@ -1289,8 +1257,7 @@ TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseNoDataNorEffectiveNoiseFails) { AggregationPhaseTestData test_data; int register_count = 4; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); // Frequency offset = 2 and reach offset = 6. @@ -1312,7 +1279,7 @@ TEST(ReachAndFrequencyAggregationPhase, TEST(ReachOnlyAggregationPhase, InvalidRegisterCountFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/0, /*maximum_combined_frequency=*/10, /*ring_modulus=*/128); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), @@ -1321,7 +1288,7 @@ TEST(ReachOnlyAggregationPhase, InvalidRegisterCountFails) { TEST(ReachOnlyAggregationPhase, InvalidRingModulusFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/10, /*ring_modulus=*/1); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), @@ -1330,7 +1297,7 @@ TEST(ReachOnlyAggregationPhase, InvalidRingModulusFails) { TEST(ReachOnlyAggregationPhase, InvalidRingModulusAndMaxFrequencyPairFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, /*bytes_per_registers=*/1, + test_data.SetSketchParams(/*register_count=*/100, /*maximum_combined_frequency=*/4, /*ring_modulus=*/5); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), @@ -1362,8 +1329,7 @@ TEST(ReachOnlyAggregationPhase, SketchShareVectorsHaveDifferentSizeFails) { TEST(ReachOnlyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/7); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); @@ -1384,8 +1350,7 @@ TEST(ReachOnlyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { TEST(ReachOnlyAggregationPhase, AggregationPhaseWithDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*bytes_per_register=*/1, - /*max_combined_frequency=*/4, + test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, /*ring_modulus=*/7); test_data.SetMaximumFrequency(2); // Computed offset = 2. @@ -1410,7 +1375,6 @@ class EndToEndHmssTest { public: EndToEndHmssTest() {} absl::Status GoThroughEntireMpcProtocol(int edp_count, int register_count, - int bytes_per_register, int maximum_combined_frequency, int ring_modulus, int maximum_frequency, double epsilon, @@ -1419,12 +1383,12 @@ class EndToEndHmssTest { ShufflePhaseTestData worker_2; AggregationPhaseTestData aggregator; - worker_1.SetSketchParams(register_count, bytes_per_register, - maximum_combined_frequency, ring_modulus); - worker_2.SetSketchParams(register_count, bytes_per_register, - maximum_combined_frequency, ring_modulus); - aggregator.SetSketchParams(register_count, bytes_per_register, - maximum_combined_frequency, ring_modulus); + worker_1.SetSketchParams(register_count, maximum_combined_frequency, + ring_modulus); + worker_2.SetSketchParams(register_count, maximum_combined_frequency, + ring_modulus); + aggregator.SetSketchParams(register_count, maximum_combined_frequency, + ring_modulus); worker_1.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); worker_2.SetNonAggregatorOrder(CompleteShufflePhaseRequest::SECOND); @@ -1567,7 +1531,6 @@ TEST(EndToEndHmss, HmssWithoutDPNoiseSucceeds) { EndToEndHmssTest mpc; auto mpc_result = mpc.GoThroughEntireMpcProtocol( /*edp_count=*/kEdpCount, /*register_count=*/kRegisterCount, - /*bytes_per_register=*/kBytesPerRegister, /*maximum_combined_frequency=*/kMaxCombinedFrequency, /*ring_modulus=*/kRingModulus, /*maximum_frequency=*/kMaxFrequencyPerEdp, /*epsilon=*/kEpsilon, @@ -1579,7 +1542,6 @@ TEST(EndToEndHmss, HmssWithDPNoiseSucceeds) { EndToEndHmssTest mpc; auto mpc_result = mpc.GoThroughEntireMpcProtocol( /*edp_count=*/kEdpCount, /*register_count=*/kRegisterCount, - /*bytes_per_register=*/kBytesPerRegister, /*maximum_combined_frequency=*/kMaxCombinedFrequency, /*ring_modulus=*/kRingModulus, /*maximum_frequency=*/kMaxFrequencyPerEdp, /*epsilon=*/kEpsilon, @@ -1591,21 +1553,17 @@ class EndToEndReachOnlyHmssTest { public: EndToEndReachOnlyHmssTest() {} absl::Status GoThroughEntireMpcProtocol(int edp_count, int register_count, - int bytes_per_register, int ring_modulus, double epsilon, double delta, bool has_dp_noise) { ShufflePhaseTestData worker_1; ShufflePhaseTestData worker_2; AggregationPhaseTestData aggregator; - worker_1.SetSketchParams(register_count, bytes_per_register, edp_count, - ring_modulus); + worker_1.SetSketchParams(register_count, edp_count, ring_modulus); worker_1.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); - worker_2.SetSketchParams(register_count, bytes_per_register, edp_count, - ring_modulus); + worker_2.SetSketchParams(register_count, edp_count, ring_modulus); worker_2.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); - aggregator.SetSketchParams(register_count, bytes_per_register, edp_count, - ring_modulus); + aggregator.SetSketchParams(register_count, edp_count, ring_modulus); aggregator.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); worker_1.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); worker_2.SetNonAggregatorOrder(CompleteShufflePhaseRequest::SECOND); @@ -1717,7 +1675,6 @@ TEST(EndToEndReachOnlyHmss, HmssWithoutDPNoiseSucceeds) { EndToEndReachOnlyHmssTest mpc; auto mpc_result = mpc.GoThroughEntireMpcProtocol( /*edp_count=*/kEdpCount, /*register_count=*/kRegisterCount, - /*bytes_per_register=*/kBytesPerRegister, /*ring_modulus=*/kRingModulus, /*epsilon=*/kEpsilon, /*delta=*/kDelta, /*has_dp_noise=*/false); EXPECT_THAT(mpc_result, IsOk()); @@ -1727,7 +1684,6 @@ TEST(EndToEndReachOnlyHmss, HmssWithDPNoiseSucceeds) { EndToEndReachOnlyHmssTest mpc; auto mpc_result = mpc.GoThroughEntireMpcProtocol( /*edp_count=*/kEdpCount, /*register_count=*/kRegisterCount, - /*bytes_per_register=*/kBytesPerRegister, /*ring_modulus=*/kRingModulus, /*epsilon=*/kEpsilon, /*delta=*/kDelta, /*has_dp_noise=*/true); EXPECT_THAT(mpc_result, IsOk()); diff --git a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/herald/HeraldTest.kt b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/herald/HeraldTest.kt index e017b8561d..b1b9732829 100644 --- a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/herald/HeraldTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/herald/HeraldTest.kt @@ -111,7 +111,6 @@ import org.wfanet.measurement.internal.duchy.protocol.ReachOnlyLiquidLegionsSket import org.wfanet.measurement.internal.duchy.protocol.ReachOnlyLiquidLegionsSketchAggregationV2Kt import org.wfanet.measurement.internal.duchy.protocol.liquidLegionsSketchParameters import org.wfanet.measurement.internal.duchy.protocol.liquidLegionsV2NoiseConfig -import org.wfanet.measurement.internal.duchy.protocol.shareShuffleSketchParams as protocolShareShuffleSketchParams import org.wfanet.measurement.internal.duchy.setContinuationTokenRequest import org.wfanet.measurement.storage.StorageClient import org.wfanet.measurement.storage.testing.InMemoryStorageClient @@ -119,7 +118,6 @@ import org.wfanet.measurement.system.v1alpha.Computation import org.wfanet.measurement.system.v1alpha.Computation.MpcProtocolConfig import org.wfanet.measurement.system.v1alpha.Computation.MpcProtocolConfig.NoiseMechanism as SystemNoiseMechanism import org.wfanet.measurement.system.v1alpha.ComputationKey -import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.HonestMajorityShareShuffleKt.shareShuffleSketchParams import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.LiquidLegionsV2Kt.liquidLegionsSketchParams import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.LiquidLegionsV2Kt.mpcNoise import org.wfanet.measurement.system.v1alpha.ComputationKt.MpcProtocolConfigKt.honestMajorityShareShuffle @@ -243,11 +241,8 @@ private val RO_LLV2_MPC_PROTOCOL_CONFIG = mpcProtocolConfig { private val HMSS_MPC_PROTOCOL_CONFIG = mpcProtocolConfig { honestMajorityShareShuffle = honestMajorityShareShuffle { - sketchParams = shareShuffleSketchParams { - registerCount = 1000000 - bytesPerRegister = 2 - ringModulus = 65535 - } + reachAndFrequencyRingModulus = 127 + reachRingModulus = 127 noiseMechanism = SystemNoiseMechanism.DISCRETE_GAUSSIAN } } @@ -843,12 +838,7 @@ class HeraldTest { parameters = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { maximumFrequency = 10 - sketchParams = protocolShareShuffleSketchParams { - registerCount = 1000000 - bytesPerRegister = 2 - maximumCombinedFrequency = 20 - ringModulus = 65535 - } + ringModulus = 127 reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 1.2 @@ -950,12 +940,7 @@ class HeraldTest { parameters = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { maximumFrequency = 10 - sketchParams = protocolShareShuffleSketchParams { - registerCount = 1000000 - bytesPerRegister = 2 - maximumCombinedFrequency = 20 - ringModulus = 65535 - } + ringModulus = 127 reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 1.2 diff --git a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt index 77d79344ed..bb6df4a109 100644 --- a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt @@ -331,11 +331,8 @@ private val REACH_ONLY_REQUISITIONS = private val HMSS_PARAMETERS = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { - sketchParams = shareShuffleSketchParams { - bytesPerRegister = 4 - maximumCombinedFrequency = 11 - ringModulus = 13 - } + maximumFrequency = 10 + ringModulus = 127 reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 0.1 @@ -349,11 +346,8 @@ private val HMSS_PARAMETERS = private val REACH_ONLY_HMSS_PARAMETERS = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { - sketchParams = shareShuffleSketchParams { - bytesPerRegister = 4 - maximumCombinedFrequency = 11 - ringModulus = 13 - } + maximumFrequency = 1 + ringModulus = 127 reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 0.1 @@ -960,7 +954,11 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeShufflePhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams.copy { registerCount = 100 } + sketchParams = shareShuffleSketchParams { + registerCount = 100 + maximumCombinedFrequency = 30 + ringModulus = 127 + } reachDpParams = hmss.parameters.reachDpParams frequencyDpParams = hmss.parameters.frequencyDpParams noiseMechanism = hmss.parameters.noiseMechanism @@ -1066,10 +1064,20 @@ class HonestMajorityShareShuffleMillTest { getReachAndFrequencyHmssComputationDetails(RoleInComputation.AGGREGATOR) val inputBlobPath1 = ComputationBlobContext(GLOBAL_ID, Stage.AGGREGATION_PHASE.toProtocolStage(), 0L) - val inputBlobData1 = aggregationPhaseInput { combinedSketch += listOf(1, 2, 3) }.toByteString() + val inputBlobData1 = + aggregationPhaseInput { + combinedFrequencyVectors += listOf(1, 2, 3) + registerCount = 3 + } + .toByteString() val inputBlobPath2 = ComputationBlobContext(GLOBAL_ID, Stage.AGGREGATION_PHASE.toProtocolStage(), 1L) - val inputBlobData2 = aggregationPhaseInput { combinedSketch += listOf(4, 5, 6) }.toByteString() + val inputBlobData2 = + aggregationPhaseInput { + combinedFrequencyVectors += listOf(4, 5, 6) + registerCount = 3 + } + .toByteString() val inputBlobs = listOf( computationStageBlobMetadata { @@ -1141,7 +1149,11 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeAggregationPhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams + sketchParams = shareShuffleSketchParams { + registerCount = 3 + maximumCombinedFrequency = 30 + ringModulus = 127 + } maximumFrequency = hmss.parameters.maximumFrequency vidSamplingIntervalWidth = REACH_AND_FREQUENCY_MEASUREMENT_SPEC.vidSamplingInterval.width reachDpParams = hmss.parameters.reachDpParams @@ -1247,7 +1259,11 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeShufflePhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams.copy { registerCount = 100 } + sketchParams = shareShuffleSketchParams { + registerCount = 100 + maximumCombinedFrequency = 3 + ringModulus = 127 + } reachDpParams = hmss.parameters.reachDpParams noiseMechanism = hmss.parameters.noiseMechanism order = CompleteShufflePhaseRequest.NonAggregatorOrder.FIRST @@ -1270,10 +1286,20 @@ class HonestMajorityShareShuffleMillTest { val computationDetails = getReachOnlyHmssComputationDetails(RoleInComputation.AGGREGATOR) val inputBlobPath1 = ComputationBlobContext(GLOBAL_ID, Stage.AGGREGATION_PHASE.toProtocolStage(), 0L) - val inputBlobData1 = aggregationPhaseInput { combinedSketch += listOf(1, 2, 3) }.toByteString() + val inputBlobData1 = + aggregationPhaseInput { + combinedFrequencyVectors += listOf(1, 2, 3) + registerCount = 3 + } + .toByteString() val inputBlobPath2 = ComputationBlobContext(GLOBAL_ID, Stage.AGGREGATION_PHASE.toProtocolStage(), 1L) - val inputBlobData2 = aggregationPhaseInput { combinedSketch += listOf(4, 5, 6) }.toByteString() + val inputBlobData2 = + aggregationPhaseInput { + combinedFrequencyVectors += listOf(4, 5, 6) + registerCount = 3 + } + .toByteString() val inputBlobs = listOf( computationStageBlobMetadata { @@ -1345,7 +1371,11 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeAggregationPhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = hmss.parameters.sketchParams + sketchParams = shareShuffleSketchParams { + registerCount = 3 + maximumCombinedFrequency = 3 + ringModulus = 127 + } maximumFrequency = hmss.parameters.maximumFrequency vidSamplingIntervalWidth = REACH_ONLY_MEASUREMENT_SPEC.vidSamplingInterval.width reachDpParams = hmss.parameters.reachDpParams diff --git a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsServiceTest.kt index e2067354e4..0b365f88a5 100644 --- a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsServiceTest.kt @@ -62,7 +62,6 @@ import org.wfanet.measurement.api.v2alpha.RequisitionKt.DuchyEntryKt.liquidLegio import org.wfanet.measurement.api.v2alpha.RequisitionKt.DuchyEntryKt.value import org.wfanet.measurement.api.v2alpha.RequisitionKt.duchyEntry import org.wfanet.measurement.api.v2alpha.RequisitionKt.refusal -import org.wfanet.measurement.api.v2alpha.ShareShuffleSketchParams import org.wfanet.measurement.api.v2alpha.SignedMessage import org.wfanet.measurement.api.v2alpha.copy import org.wfanet.measurement.api.v2alpha.differentialPrivacyParams @@ -1361,6 +1360,8 @@ class RequisitionsServiceTest { externalProtocolConfigId = "hmss" honestMajorityShareShuffle = InternalProtocolConfigKt.honestMajorityShareShuffle { + reachRingModulus = 127 + reachAndFrequencyRingModulus = 127 noiseMechanism = InternalProtocolConfig.NoiseMechanism.DISCRETE_GAUSSIAN } } @@ -1439,7 +1440,7 @@ class RequisitionsServiceTest { ProtocolConfigKt.protocol { honestMajorityShareShuffle = ProtocolConfigKt.honestMajorityShareShuffle { - sketchParams = ShareShuffleSketchParams.getDefaultInstance() + ringModulus = 127 noiseMechanism = ProtocolConfig.NoiseMechanism.DISCRETE_GAUSSIAN } } diff --git a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt index 51daad4e2f..1f71936182 100644 --- a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt @@ -125,7 +125,6 @@ import org.wfanet.measurement.api.v2alpha.protocolConfig import org.wfanet.measurement.api.v2alpha.refuseRequisitionRequest import org.wfanet.measurement.api.v2alpha.requisition import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.shareShuffleSketchParams import org.wfanet.measurement.api.v2alpha.testing.MeasurementResultSubject.Companion.assertThat import org.wfanet.measurement.api.v2alpha.unpack import org.wfanet.measurement.common.HexString @@ -217,6 +216,8 @@ private const val DUCHY_ONE_ID = "worker1" private const val DUCHY_TWO_ID = "worker2" private const val RANDOM_SEED: Long = 0 +private const val RING_MODULUS = 127 + // Resource ID for EventGroup that fails Requisitions with CONSENT_SIGNAL_INVALID if used. private const val CONSENT_SIGNAL_INVALID_EVENT_GROUP_ID = "consent-signal-invalid" // Resource ID for EventGroup that fails Requisitions with SPEC_INVALID if used. @@ -826,11 +827,7 @@ class EdpSimulatorTest { val header: FulfillRequisitionRequest.Header = requests.first().header val shareVector = FrequencyVector.parseFrom(requests.drop(1).map { it.bodyChunk.data }.flatten()) - assert( - shareVector.dataList.all { - it in 0 until HONEST_MAJORITY_SHARE_SHUFFLE_SKETCH_PARAMS.ringModulus - } - ) + assert(shareVector.dataList.all { it in 0 until RING_MODULUS }) assertThat(header) .comparingExpectedFieldsOnly() .isEqualTo( @@ -3057,11 +3054,6 @@ class EdpSimulatorTest { samplingIndicatorSize = 10_000_000 } - private val HONEST_MAJORITY_SHARE_SHUFFLE_SKETCH_PARAMS = shareShuffleSketchParams { - bytesPerRegister = 1 - ringModulus = 127 - } - private val REQUISITION = requisition { name = "${EDP_NAME}/requisitions/foo" measurement = MEASUREMENT_NAME @@ -3122,8 +3114,8 @@ class EdpSimulatorTest { ProtocolConfigKt.protocol { honestMajorityShareShuffle = ProtocolConfigKt.honestMajorityShareShuffle { + ringModulus = RING_MODULUS noiseMechanism = NOISE_MECHANISM - sketchParams = HONEST_MAJORITY_SHARE_SHUFFLE_SKETCH_PARAMS } } } From 0f2f12436548f653fd705de141f9fca1f07ab11d Mon Sep 17 00:00:00 2001 From: renjiez Date: Mon, 15 Jul 2024 19:51:52 +0000 Subject: [PATCH 2/7] Lint --- .../proto/wfa/measurement/system/v1alpha/computation.proto | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/proto/wfa/measurement/system/v1alpha/computation.proto b/src/main/proto/wfa/measurement/system/v1alpha/computation.proto index eb2073711e..e2a3037f9b 100644 --- a/src/main/proto/wfa/measurement/system/v1alpha/computation.proto +++ b/src/main/proto/wfa/measurement/system/v1alpha/computation.proto @@ -168,10 +168,9 @@ message Computation { message HonestMajorityShareShuffle { // The modulus used in the MPC protocol for ReachAndFrequency Measurement. int32 reach_and_frequency_ring_modulus = 1 - [(google.api.field_behavior) = REQUIRED]; + [(google.api.field_behavior) = REQUIRED]; // The modulus used in the MPC protocol for Reach Measurement. - int32 reach_ring_modulus = 2 - [(google.api.field_behavior) = REQUIRED]; + int32 reach_ring_modulus = 2 [(google.api.field_behavior) = REQUIRED]; // The mechanism to generate noise during computation. NoiseMechanism noise_mechanism = 3 [(google.api.field_behavior) = REQUIRED]; From 9bf8673104a0e756ddf4cb9b2fa991f923b1c533 Mon Sep 17 00:00:00 2001 From: renjiez Date: Mon, 15 Jul 2024 20:38:14 +0000 Subject: [PATCH 3/7] Update based on PR comments. --- .../HonestMajorityShareShuffleMillTest.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt index bb6df4a109..109c689835 100644 --- a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt @@ -329,10 +329,12 @@ private val REACH_ONLY_REQUISITION_3 = private val REACH_ONLY_REQUISITIONS = listOf(REACH_ONLY_REQUISITION_1, REACH_ONLY_REQUISITION_2, REACH_ONLY_REQUISITION_3) +private const val RING_MODULUS = 127 + private val HMSS_PARAMETERS = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { maximumFrequency = 10 - ringModulus = 127 + ringModulus = RING_MODULUS reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 0.1 @@ -347,7 +349,7 @@ private val HMSS_PARAMETERS = private val REACH_ONLY_HMSS_PARAMETERS = HonestMajorityShareShuffleKt.ComputationDetailsKt.parameters { maximumFrequency = 1 - ringModulus = 127 + ringModulus = RING_MODULUS reachDpParams = differentialPrivacyParams { epsilon = 1.1 delta = 0.1 @@ -957,7 +959,7 @@ class HonestMajorityShareShuffleMillTest { sketchParams = shareShuffleSketchParams { registerCount = 100 maximumCombinedFrequency = 30 - ringModulus = 127 + ringModulus = RING_MODULUS } reachDpParams = hmss.parameters.reachDpParams frequencyDpParams = hmss.parameters.frequencyDpParams @@ -1152,7 +1154,7 @@ class HonestMajorityShareShuffleMillTest { sketchParams = shareShuffleSketchParams { registerCount = 3 maximumCombinedFrequency = 30 - ringModulus = 127 + ringModulus = RING_MODULUS } maximumFrequency = hmss.parameters.maximumFrequency vidSamplingIntervalWidth = REACH_AND_FREQUENCY_MEASUREMENT_SPEC.vidSamplingInterval.width @@ -1262,7 +1264,7 @@ class HonestMajorityShareShuffleMillTest { sketchParams = shareShuffleSketchParams { registerCount = 100 maximumCombinedFrequency = 3 - ringModulus = 127 + ringModulus = RING_MODULUS } reachDpParams = hmss.parameters.reachDpParams noiseMechanism = hmss.parameters.noiseMechanism @@ -1374,7 +1376,7 @@ class HonestMajorityShareShuffleMillTest { sketchParams = shareShuffleSketchParams { registerCount = 3 maximumCombinedFrequency = 3 - ringModulus = 127 + ringModulus = RING_MODULUS } maximumFrequency = hmss.parameters.maximumFrequency vidSamplingIntervalWidth = REACH_ONLY_MEASUREMENT_SPEC.vidSamplingInterval.width From e07c2c9b88e50a45139d5fe5bc08552c31078839 Mon Sep 17 00:00:00 2001 From: renjiez Date: Tue, 16 Jul 2024 17:42:06 +0000 Subject: [PATCH 4/7] Update based on PR comments. --- .../wfa/measurement/internal/kingdom/protocol_config.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto b/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto index a03bbaad39..8ded91a17d 100644 --- a/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto +++ b/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto @@ -142,6 +142,8 @@ message ProtocolConfig { int32 reach_and_frequency_ring_modulus = 3; // The modulus used in the protocol for Reach Measurement. + // + // This must be a prime number. int32 reach_ring_modulus = 4; } From 9e4f3238531033c7f14eaf8c8101079a99f3105f Mon Sep 17 00:00:00 2001 From: renjiez Date: Tue, 16 Jul 2024 19:19:57 +0000 Subject: [PATCH 5/7] Replace sketch by frequencyVector --- MODULE.bazel.lock | 97 +-- .../honest_majority_share_shuffle_utility.cc | 270 ++++--- ...t_majority_share_shuffle_utility_helper.cc | 78 +- ...st_majority_share_shuffle_utility_helper.h | 19 +- .../HonestMajorityShareShuffleMill.kt | 20 +- .../internal/duchy/protocol/BUILD.bazel | 2 +- .../honest_majority_share_shuffle.proto | 2 +- ...onest_majority_share_shuffle_methods.proto | 26 +- ...are_shuffle_frequency_vector_params.proto} | 14 +- ...ority_share_shuffle_utility_helper_test.cc | 247 +++--- ...est_majority_share_shuffle_utility_test.cc | 704 ++++++++++-------- .../HonestMajorityShareShuffleMillTest.kt | 52 +- 12 files changed, 797 insertions(+), 734 deletions(-) rename src/main/proto/wfa/measurement/internal/duchy/protocol/{share_shuffle_sketch_params.proto => share_shuffle_frequency_vector_params.proto} (71%) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index eda3723d37..739e9fb2e9 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 6, - "moduleFileHash": "04990e8b8fbf1738be22cc027db6abf0a0573e70571d789ce0e5c8149de46290", + "moduleFileHash": "920d6bae36789ac07de8bbeefaf0cf87727cf5986cd7db5b58437061dc9001b6", "flags": { "cmdRegistries": [ "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main", @@ -31,7 +31,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 186, + "line": 196, "column": 22 }, "imports": { @@ -53,7 +53,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 187, + "line": 197, "column": 15 } }, @@ -70,7 +70,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 193, + "line": 203, "column": 15 } }, @@ -103,7 +103,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 202, + "line": 212, "column": 14 } } @@ -117,7 +117,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 228, + "line": 238, "column": 20 }, "imports": { @@ -136,7 +136,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 229, + "line": 239, "column": 23 } } @@ -150,7 +150,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 237, + "line": 247, "column": 24 }, "imports": { @@ -172,7 +172,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 238, + "line": 248, "column": 15 } }, @@ -186,7 +186,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 243, + "line": 253, "column": 15 } }, @@ -200,7 +200,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 248, + "line": 258, "column": 15 } }, @@ -214,7 +214,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 253, + "line": 263, "column": 15 } }, @@ -228,7 +228,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 258, + "line": 268, "column": 15 } } @@ -242,7 +242,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 272, + "line": 282, "column": 23 }, "imports": {}, @@ -257,7 +257,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 273, + "line": 283, "column": 17 } } @@ -293,7 +293,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 282, + "line": 292, "column": 13 } }, @@ -308,7 +308,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 289, + "line": 299, "column": 13 } }, @@ -323,7 +323,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 296, + "line": 306, "column": 13 } }, @@ -338,7 +338,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 303, + "line": 313, "column": 13 } } @@ -374,7 +374,7 @@ "wfa_rules_cue": "rules_cue@0.4.0", "wfa_common_jvm": "common-jvm@0.86.0", "wfa_common_cpp": "common-cpp@0.13.0", - "wfa_measurement_proto": "cross-media-measurement-api@0.62.0", + "wfa_measurement_proto": "cross-media-measurement-api@_", "wfa_consent_signaling_client": "consent-signaling-client@0.22.0", "any_sketch": "any-sketch@0.9.1", "any_sketch_java": "any-sketch-java@0.7.0", @@ -2702,10 +2702,10 @@ } } }, - "cross-media-measurement-api@0.62.0": { + "cross-media-measurement-api@_": { "name": "cross-media-measurement-api", - "version": "0.62.0", - "key": "cross-media-measurement-api@0.62.0", + "version": "", + "key": "cross-media-measurement-api@_", "repoName": "wfa_measurement_proto", "executionPlatformsToRegister": [], "toolchainsToRegister": [], @@ -2713,10 +2713,10 @@ { "extensionBzlFile": "@wfa_measurement_proto//build:non_module_deps.bzl", "extensionName": "non_module_deps", - "usingModule": "cross-media-measurement-api@0.62.0", + "usingModule": "cross-media-measurement-api@_", "location": { - "file": "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.62.0/MODULE.bazel", - "line": 25, + "file": "@@cross-media-measurement-api~//:MODULE.bazel", + "line": 24, "column": 32 }, "imports": { @@ -2734,21 +2734,6 @@ "com_google_googleapis": "googleapis@0.0.0-bzlmod.1", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/refs/tags/v0.62.0.tar.gz" - ], - "integrity": "sha256-kc7MaqqrGXy16ifaaOmuEXrvYBTBSzY9XFctQdO5wb8=", - "strip_prefix": "cross-media-measurement-api-0.62.0", - "remote_patches": { - "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.62.0/patches/module_dot_bazel.patch": "sha256-bhHvEspMM1LRrvVPj9l4mphuNpeQHbN0ap3cSYU6gsk=" - }, - "remote_patch_strip": 0 - } } }, "consent-signaling-client@0.22.0": { @@ -2761,7 +2746,7 @@ "extensionUsages": [], "deps": { "wfa_rules_kotlin_jvm": "rules_kotlin_jvm@0.2.0", - "wfa_measurement_proto": "cross-media-measurement-api@0.62.0", + "wfa_measurement_proto": "cross-media-measurement-api@_", "wfa_common_jvm": "common-jvm@0.86.0", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -133964,34 +133949,6 @@ "recordedRepoMappingEntries": [] } }, - "@@cross-media-measurement-api~//build:non_module_deps.bzl%non_module_deps": { - "general": { - "bzlTransitiveDigest": "N9a0WLV2zhxfMK1hQc9MX/xt5KvdyYdfVQC3uE+PpJs=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "plantuml": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "downloaded_file_path": "plantuml.jar", - "sha256": "3a659c3d87ea5ebac7aadb645233176c51d0290777ebc28285dd2a35dc947752", - "urls": [ - "https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar" - ] - } - } - }, - "recordedRepoMappingEntries": [ - [ - "cross-media-measurement-api~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@gazelle~//:extensions.bzl%go_deps": { "general": { "bzlTransitiveDigest": "LU6SX6N3JGbML1A3SCpN/Pm4Pck4gYEMf63QPuiuSq8=", diff --git a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc index d930410b46..c02af8680c 100644 --- a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc +++ b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility.cc @@ -54,7 +54,8 @@ using ::wfa::measurement::internal::duchy::protocol::common:: constexpr int kWorkerCount = 2; -absl::Status VerifySketchParameters(const ShareShuffleSketchParams& params) { +absl::Status VerifyFrequencyVectorParameters( + const ShareShuffleFrequencyVectorParams& params) { if (params.register_count() < 1) { return absl::InvalidArgumentError("The register count must be at least 1."); } @@ -92,30 +93,35 @@ CompleteReachAndFrequencyShufflePhase( StartedThreadCpuTimer timer; CompleteShufflePhaseResponse response; - RETURN_IF_ERROR(VerifySketchParameters(request.sketch_params())); + RETURN_IF_ERROR( + VerifyFrequencyVectorParameters(request.frequency_vector_params())); - if (request.sketch_shares().empty()) { - return absl::InvalidArgumentError("Sketch shares must not be empty."); + if (request.frequency_vector_shares().empty()) { + return absl::InvalidArgumentError( + "FrequencyVector shares must not be empty."); } - const int sketch_size = request.sketch_params().register_count(); + const int frequency_vector_size = + request.frequency_vector_params().register_count(); // Combines the input shares. - std::vector combined_sketch(sketch_size, 0); - for (int i = 0; i < request.sketch_shares().size(); i++) { - ASSIGN_OR_RETURN( - std::vector share_vector, - GetShareVectorFromSketchShare(request.sketch_params(), - request.sketch_shares().Get(i))); - if (share_vector.size() != sketch_size) { - return absl::InvalidArgumentError(absl::Substitute( - "The $0-th sketch share has invalid size. Expect $1 but the " - "actual is $2.", - i, sketch_size, share_vector.size())); + std::vector combined_frequency_vector(frequency_vector_size, 0); + for (int i = 0; i < request.frequency_vector_shares().size(); i++) { + ASSIGN_OR_RETURN(std::vector share_vector, + GetShareVectorFromFrequencyVectorShare( + request.frequency_vector_params(), + request.frequency_vector_shares().Get(i))); + if (share_vector.size() != frequency_vector_size) { + return absl::InvalidArgumentError( + absl::Substitute("The $0-th frequency_vector share has invalid size. " + "Expect $1 but the " + "actual is $2.", + i, frequency_vector_size, share_vector.size())); } - ASSIGN_OR_RETURN(combined_sketch, - VectorAddMod(combined_sketch, share_vector, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + combined_frequency_vector, + VectorAddMod(combined_frequency_vector, share_vector, + request.frequency_vector_params().ring_modulus())); } ASSIGN_OR_RETURN(PrngSeed seed, @@ -137,21 +143,21 @@ CompleteReachAndFrequencyShufflePhase( GetBlindHistogramNoiser(request.frequency_dp_params(), kWorkerCount, request.noise_mechanism()); // Generates local noise registers. - ASSIGN_OR_RETURN( - std::vector noise_registers, - GenerateReachAndFrequencyNoiseRegisters( - request.sketch_params(), *reach_noiser, *frequency_noiser)); + ASSIGN_OR_RETURN(std::vector noise_registers, + GenerateReachAndFrequencyNoiseRegisters( + request.frequency_vector_params(), *reach_noiser, + *frequency_noiser)); // Both workers generate common random vectors from the common random seed. // rand_vec_1 || rand_vec_2 <-- PRNG(seed). - ASSIGN_OR_RETURN( - std::vector rand_vec_1, - prng->GenerateUniformRandomRange( - noise_registers.size(), request.sketch_params().ring_modulus())); - ASSIGN_OR_RETURN( - std::vector rand_vec_2, - prng->GenerateUniformRandomRange( - noise_registers.size(), request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN(std::vector rand_vec_1, + prng->GenerateUniformRandomRange( + noise_registers.size(), + request.frequency_vector_params().ring_modulus())); + ASSIGN_OR_RETURN(std::vector rand_vec_2, + prng->GenerateUniformRandomRange( + noise_registers.size(), + request.frequency_vector_params().ring_modulus())); // Generates local noise register shares using the common random vectors. // Worker 1 obtains shares: @@ -163,28 +169,30 @@ CompleteReachAndFrequencyShufflePhase( std::vector first_local_noise_share; std::vector second_local_noise_share; if (request.order() == CompleteShufflePhaseRequest::FIRST) { - ASSIGN_OR_RETURN(first_local_noise_share, - VectorSubMod(noise_registers, rand_vec_1, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + first_local_noise_share, + VectorSubMod(noise_registers, rand_vec_1, + request.frequency_vector_params().ring_modulus())); second_local_noise_share = std::move(rand_vec_2); } else if (request.order() == CompleteShufflePhaseRequest::SECOND) { first_local_noise_share = std::move(rand_vec_1); - ASSIGN_OR_RETURN(second_local_noise_share, - VectorSubMod(noise_registers, rand_vec_2, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + second_local_noise_share, + VectorSubMod(noise_registers, rand_vec_2, + request.frequency_vector_params().ring_modulus())); } else { return absl::InvalidArgumentError( "Non aggregator order must be specified."); } - // Appends the first noise share to the combined sketch share. - combined_sketch.insert(combined_sketch.end(), - first_local_noise_share.begin(), - first_local_noise_share.end()); - // Appends the second noise share to the combined sketch share. - combined_sketch.insert(combined_sketch.end(), - second_local_noise_share.begin(), - second_local_noise_share.end()); + // Appends the first noise share to the combined frequency_vector share. + combined_frequency_vector.insert(combined_frequency_vector.end(), + first_local_noise_share.begin(), + first_local_noise_share.end()); + // Appends the second noise share to the combined frequency_vector share. + combined_frequency_vector.insert(combined_frequency_vector.end(), + second_local_noise_share.begin(), + second_local_noise_share.end()); } // Generates shuffle seed from common random seed. @@ -194,10 +202,11 @@ CompleteReachAndFrequencyShufflePhase( ASSIGN_OR_RETURN(PrngSeed shuffle_seed, GetPrngSeedFromCharVector(shuffle_seed_vec)); // Shuffle the shares. - RETURN_IF_ERROR(SecureShuffleWithSeed(combined_sketch, shuffle_seed)); + RETURN_IF_ERROR( + SecureShuffleWithSeed(combined_frequency_vector, shuffle_seed)); - response.mutable_combined_sketch()->Add(combined_sketch.begin(), - combined_sketch.end()); + response.mutable_combined_frequency_vector()->Add( + combined_frequency_vector.begin(), combined_frequency_vector.end()); *response.mutable_elapsed_cpu_duration() = google::protobuf::util::TimeUtil::MillisecondsToDuration( timer.ElapsedMillis()); @@ -209,35 +218,40 @@ absl::StatusOr CompleteReachOnlyShufflePhase( StartedThreadCpuTimer timer; CompleteShufflePhaseResponse response; - RETURN_IF_ERROR(VerifySketchParameters(request.sketch_params())); + RETURN_IF_ERROR( + VerifyFrequencyVectorParameters(request.frequency_vector_params())); // Verify that the ring modulus is a prime. - if (!IsPrime(request.sketch_params().ring_modulus())) { + if (!IsPrime(request.frequency_vector_params().ring_modulus())) { return absl::InvalidArgumentError("The ring modulus must be a prime."); } - if (request.sketch_shares().empty()) { - return absl::InvalidArgumentError("Sketch shares must not be empty."); + if (request.frequency_vector_shares().empty()) { + return absl::InvalidArgumentError( + "FrequencyVector shares must not be empty."); } - const int sketch_size = request.sketch_params().register_count(); + const int frequency_vector_size = + request.frequency_vector_params().register_count(); // Combines the input shares. - std::vector combined_sketch(sketch_size, 0); - for (int i = 0; i < request.sketch_shares().size(); i++) { - ASSIGN_OR_RETURN( - std::vector share_vector, - GetShareVectorFromSketchShare(request.sketch_params(), - request.sketch_shares().Get(i))); - if (share_vector.size() != sketch_size) { - return absl::InvalidArgumentError(absl::Substitute( - "The $0-th sketch share has invalid size. Expect $1 but the " - "actual is $2.", - i, sketch_size, share_vector.size())); + std::vector combined_frequency_vector(frequency_vector_size, 0); + for (int i = 0; i < request.frequency_vector_shares().size(); i++) { + ASSIGN_OR_RETURN(std::vector share_vector, + GetShareVectorFromFrequencyVectorShare( + request.frequency_vector_params(), + request.frequency_vector_shares().Get(i))); + if (share_vector.size() != frequency_vector_size) { + return absl::InvalidArgumentError( + absl::Substitute("The $0-th frequency_vector share has invalid size. " + "Expect $1 but the " + "actual is $2.", + i, frequency_vector_size, share_vector.size())); } - ASSIGN_OR_RETURN(combined_sketch, - VectorAddMod(combined_sketch, share_vector, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + combined_frequency_vector, + VectorAddMod(combined_frequency_vector, share_vector, + request.frequency_vector_params().ring_modulus())); } ASSIGN_OR_RETURN(PrngSeed seed, GetPrngSeedFromString(request.common_random_seed())); @@ -250,12 +264,14 @@ absl::StatusOr CompleteReachOnlyShufflePhase( // Sample a vector r of random values in [1, modulus). ASSIGN_OR_RETURN(std::vector r, prng->GenerateNonZeroUniformRandomRange( - sketch_size, request.sketch_params().ring_modulus())); + frequency_vector_size, + request.frequency_vector_params().ring_modulus())); // Transform share of non-zero registers to share of a non-zero random value. - for (int j = 0; j < sketch_size; j++) { - combined_sketch[j] = uint64_t{combined_sketch[j]} * uint64_t{r[j]} % - request.sketch_params().ring_modulus(); + for (int j = 0; j < frequency_vector_size; j++) { + combined_frequency_vector[j] = + uint64_t{combined_frequency_vector[j]} * uint64_t{r[j]} % + request.frequency_vector_params().ring_modulus(); } // Adds noise registers to the combined input share. @@ -266,19 +282,19 @@ absl::StatusOr CompleteReachOnlyShufflePhase( // Generates local noise registers. ASSIGN_OR_RETURN(std::vector noise_registers, - GenerateReachOnlyNoiseRegisters(request.sketch_params(), - *reach_noiser)); + GenerateReachOnlyNoiseRegisters( + request.frequency_vector_params(), *reach_noiser)); // Both workers generate common random vectors from the common random seed. // rand_vec_1 || rand_vec_2 <-- PRNG(seed). - ASSIGN_OR_RETURN( - std::vector rand_vec_1, - prng->GenerateUniformRandomRange( - noise_registers.size(), request.sketch_params().ring_modulus())); - ASSIGN_OR_RETURN( - std::vector rand_vec_2, - prng->GenerateUniformRandomRange( - noise_registers.size(), request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN(std::vector rand_vec_1, + prng->GenerateUniformRandomRange( + noise_registers.size(), + request.frequency_vector_params().ring_modulus())); + ASSIGN_OR_RETURN(std::vector rand_vec_2, + prng->GenerateUniformRandomRange( + noise_registers.size(), + request.frequency_vector_params().ring_modulus())); // Generates local noise register shares using the common random vectors. // Worker 1 obtains shares: @@ -290,28 +306,30 @@ absl::StatusOr CompleteReachOnlyShufflePhase( std::vector first_local_noise_share; std::vector second_local_noise_share; if (request.order() == CompleteShufflePhaseRequest::FIRST) { - ASSIGN_OR_RETURN(first_local_noise_share, - VectorSubMod(noise_registers, rand_vec_1, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + first_local_noise_share, + VectorSubMod(noise_registers, rand_vec_1, + request.frequency_vector_params().ring_modulus())); second_local_noise_share = std::move(rand_vec_2); } else if (request.order() == CompleteShufflePhaseRequest::SECOND) { first_local_noise_share = std::move(rand_vec_1); - ASSIGN_OR_RETURN(second_local_noise_share, - VectorSubMod(noise_registers, rand_vec_2, - request.sketch_params().ring_modulus())); + ASSIGN_OR_RETURN( + second_local_noise_share, + VectorSubMod(noise_registers, rand_vec_2, + request.frequency_vector_params().ring_modulus())); } else { return absl::InvalidArgumentError( "Non aggregator order must be specified."); } - // Appends the first noise share to the combined sketch share. - combined_sketch.insert(combined_sketch.end(), - first_local_noise_share.begin(), - first_local_noise_share.end()); - // Appends the second noise share to the combined sketch share. - combined_sketch.insert(combined_sketch.end(), - second_local_noise_share.begin(), - second_local_noise_share.end()); + // Appends the first noise share to the combined frequency_vector share. + combined_frequency_vector.insert(combined_frequency_vector.end(), + first_local_noise_share.begin(), + first_local_noise_share.end()); + // Appends the second noise share to the combined frequency_vector share. + combined_frequency_vector.insert(combined_frequency_vector.end(), + second_local_noise_share.begin(), + second_local_noise_share.end()); } // Generates shuffle seed from common random seed. @@ -321,10 +339,11 @@ absl::StatusOr CompleteReachOnlyShufflePhase( ASSIGN_OR_RETURN(PrngSeed shuffle_seed, GetPrngSeedFromCharVector(shuffle_seed_vec)); // Shuffle the shares. - RETURN_IF_ERROR(SecureShuffleWithSeed(combined_sketch, shuffle_seed)); + RETURN_IF_ERROR( + SecureShuffleWithSeed(combined_frequency_vector, shuffle_seed)); - response.mutable_combined_sketch()->Add(combined_sketch.begin(), - combined_sketch.end()); + response.mutable_combined_frequency_vector()->Add( + combined_frequency_vector.begin(), combined_frequency_vector.end()); *response.mutable_elapsed_cpu_duration() = google::protobuf::util::TimeUtil::MillisecondsToDuration( timer.ElapsedMillis()); @@ -337,16 +356,18 @@ CompleteReachAndFrequencyAggregationPhase( StartedThreadCpuTimer timer; CompleteAggregationPhaseResponse response; - RETURN_IF_ERROR(VerifySketchParameters(request.sketch_params())); + RETURN_IF_ERROR( + VerifyFrequencyVectorParameters(request.frequency_vector_params())); - if (request.sketch_shares().size() != kWorkerCount) { + if (request.frequency_vector_shares().size() != kWorkerCount) { return absl::InvalidArgumentError( "The number of share vectors must be equal to the number of " "non-aggregators."); } ASSIGN_OR_RETURN( - std::vector combined_sketch, - CombineSketchShares(request.sketch_params(), request.sketch_shares())); + std::vector combined_frequency_vector, + CombineFrequencyVectorShares(request.frequency_vector_params(), + request.frequency_vector_shares())); int maximum_frequency = request.maximum_frequency(); if (maximum_frequency < 1) { @@ -354,29 +375,29 @@ CompleteReachAndFrequencyAggregationPhase( "The maximum frequency should be greater than 0."); } - // Validates the combined sketch and generates the frequency histogram. - // frequency_histogram[i] = the number of times value i occurs where - // i in {0, ..., maximum_frequency-1}. + // Validates the combined frequency_vector and generates the frequency + // histogram. frequency_histogram[i] = the number of times value i occurs + // where i in {0, ..., maximum_frequency-1}. absl::flat_hash_map frequency_histogram; - for (const auto reg : combined_sketch) { - if (reg > request.sketch_params().maximum_combined_frequency() && - reg != (request.sketch_params().ring_modulus() - 1)) { + for (const auto reg : combined_frequency_vector) { + if (reg > request.frequency_vector_params().maximum_combined_frequency() && + reg != (request.frequency_vector_params().ring_modulus() - 1)) { return absl::InternalError(absl::Substitute( "The combined register value, which is $0, is not valid. It must be " "either the sentinel value, which is $1, or less that or equal to " "the combined maximum frequency, which is $2.", - reg, request.sketch_params().ring_modulus() - 1, - request.sketch_params().maximum_combined_frequency())); + reg, request.frequency_vector_params().ring_modulus() - 1, + request.frequency_vector_params().maximum_combined_frequency())); } if (reg < maximum_frequency) { frequency_histogram[reg]++; } } - int64_t register_count = request.sketch_params().register_count(); + int64_t register_count = request.frequency_vector_params().register_count(); // Computes the non empty register count by subtracting frequency zero from - // the input sketch size. Another way to compute it is to add up all + // the input frequency_vector size. Another way to compute it is to add up all // frequencies from 1 to the maximum combined frequency. However, the latter // approach will have a lot more noise. int64_t non_empty_register_count = @@ -411,7 +432,8 @@ CompleteReachAndFrequencyAggregationPhase( // Ensures that non_empty_register_count is at least 0. non_empty_register_count = std::max(0L, non_empty_register_count); - // Ensures that non_empty_register_count is at most the input sketch size. + // Ensures that non_empty_register_count is at most the input + // frequency_vector size. non_empty_register_count = std::min(register_count, non_empty_register_count); } @@ -451,7 +473,7 @@ CompleteReachAndFrequencyAggregationPhase( // Returns error message when the adjusted_total equals to zero. This happens // when frequency_histogram[0] = max(register_count, accumulated_count) which - // suggests that the sketchs are empty. + // suggests that the frequency_vectors are empty. if (adjusted_total == 0) { return absl::InvalidArgumentError( "There is neither actual data nor effective noise in the request."); @@ -483,19 +505,21 @@ CompleteReachOnlyAggregationPhase( const CompleteAggregationPhaseRequest& request) { StartedThreadCpuTimer timer; CompleteAggregationPhaseResponse response; - RETURN_IF_ERROR(VerifySketchParameters(request.sketch_params())); - if (request.sketch_shares().size() != kWorkerCount) { + RETURN_IF_ERROR( + VerifyFrequencyVectorParameters(request.frequency_vector_params())); + if (request.frequency_vector_shares().size() != kWorkerCount) { return absl::InvalidArgumentError( "The number of share vectors must be equal to the number of " "non-aggregators."); } ASSIGN_OR_RETURN( - std::vector combined_sketch, - CombineSketchShares(request.sketch_params(), request.sketch_shares())); + std::vector combined_frequency_vector, + CombineFrequencyVectorShares(request.frequency_vector_params(), + request.frequency_vector_shares())); // Count the non-zero registers. int64_t non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if (reg != 0) { non_empty_register_count++; } @@ -514,9 +538,11 @@ CompleteReachOnlyAggregationPhase( // Ensures that non_empty_register_count is at least 0. non_empty_register_count = std::max(0L, non_empty_register_count); - // Ensures that non_empty_register_count is at most the input sketch size. - non_empty_register_count = std::min( - request.sketch_params().register_count(), non_empty_register_count); + // Ensures that non_empty_register_count is at most the input + // frequency_vector size. + non_empty_register_count = + std::min(request.frequency_vector_params().register_count(), + non_empty_register_count); } // Estimates reach using the number of non-empty buckets and the VID sampling diff --git a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.cc b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.cc index 74263e4e18..138f429e97 100644 --- a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.cc +++ b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.cc @@ -45,11 +45,11 @@ using ::wfa::math::kBytesPerAes256Key; using ::wfa::math::UniformPseudorandomGenerator; absl::StatusOr> GenerateReachAndFrequencyNoiseRegisters( - const ShareShuffleSketchParams& sketch_param, + const ShareShuffleFrequencyVectorParams& frequency_vector_param, const math::DistributedNoiser& distributed_reach_noiser, const math::DistributedNoiser& distributed_frequency_noiser) { - if (sketch_param.ring_modulus() <= - sketch_param.maximum_combined_frequency() + 1) { + if (frequency_vector_param.ring_modulus() <= + frequency_vector_param.maximum_combined_frequency() + 1) { return absl::InvalidArgumentError( "Ring modulus must be greater than maximum combined frequency plus 1."); } @@ -57,10 +57,10 @@ absl::StatusOr> GenerateReachAndFrequencyNoiseRegisters( int64_t total_noise_registers_count = distributed_reach_noiser.options().shift_offset * 2 + distributed_frequency_noiser.options().shift_offset * 2 * - sketch_param.maximum_combined_frequency(); + frequency_vector_param.maximum_combined_frequency(); // Sets all noise registers to the sentinel value (q-1). - std::vector noise_registers(total_noise_registers_count, - sketch_param.ring_modulus() - 1); + std::vector noise_registers( + total_noise_registers_count, frequency_vector_param.ring_modulus() - 1); int current_index = 0; // Sample noise registers for reach. @@ -72,7 +72,8 @@ absl::StatusOr> GenerateReachAndFrequencyNoiseRegisters( } // Sample noise registers for 1+ frequency. - for (int k = 1; k <= sketch_param.maximum_combined_frequency(); k++) { + for (int k = 1; k <= frequency_vector_param.maximum_combined_frequency(); + k++) { ASSIGN_OR_RETURN(int64_t noise_register_count_for_bucket_k, distributed_frequency_noiser.GenerateNoiseComponent()); for (int i = 0; i < noise_register_count_for_bucket_k; i++) { @@ -85,10 +86,10 @@ absl::StatusOr> GenerateReachAndFrequencyNoiseRegisters( } absl::StatusOr> GenerateReachOnlyNoiseRegisters( - const ShareShuffleSketchParams& sketch_param, + const ShareShuffleFrequencyVectorParams& frequency_vector_param, const math::DistributedNoiser& distributed_noiser) { - if (sketch_param.ring_modulus() <= - sketch_param.maximum_combined_frequency() + 1) { + if (frequency_vector_param.ring_modulus() <= + frequency_vector_param.maximum_combined_frequency() + 1) { return absl::InvalidArgumentError( "Ring modulus must be greater than maximum combined frequency plus 1."); } @@ -107,10 +108,10 @@ absl::StatusOr> GenerateReachOnlyNoiseRegisters( ASSIGN_OR_RETURN(std::unique_ptr prng, math::OpenSslUniformPseudorandomGenerator::Create(key, iv)); - ASSIGN_OR_RETURN( - std::vector noise_registers, - prng->GenerateNonZeroUniformRandomRange(non_zero_register_noise_count, - sketch_param.ring_modulus())); + ASSIGN_OR_RETURN(std::vector noise_registers, + prng->GenerateNonZeroUniformRandomRange( + non_zero_register_noise_count, + frequency_vector_param.ring_modulus())); noise_registers.resize(total_noise_registers_count, 0); @@ -146,7 +147,7 @@ absl::StatusOr GetPrngSeedFromCharVector( } absl::StatusOr> GenerateShareFromSeed( - const ShareShuffleSketchParams& param, + const ShareShuffleFrequencyVectorParams& param, const frequency_count::PrngSeed& seed) { ASSIGN_OR_RETURN(std::unique_ptr prng, math::CreatePrngFromSeed(seed)); @@ -156,52 +157,53 @@ absl::StatusOr> GenerateShareFromSeed( return share_from_seed; } -absl::StatusOr> GetShareVectorFromSketchShare( - const ShareShuffleSketchParams& sketch_params, - const CompleteShufflePhaseRequest::SketchShare& sketch_share) { +absl::StatusOr> GetShareVectorFromFrequencyVectorShare( + const ShareShuffleFrequencyVectorParams& frequency_vector_params, + const CompleteShufflePhaseRequest::FrequencyVectorShare& + frequency_vector_share) { std::vector share_vector; - switch (sketch_share.share_type_case()) { - case CompleteShufflePhaseRequest::SketchShare::kData: - share_vector = std::vector(sketch_share.data().values().begin(), - sketch_share.data().values().end()); + switch (frequency_vector_share.share_type_case()) { + case CompleteShufflePhaseRequest::FrequencyVectorShare::kData: + share_vector = std::vector(frequency_vector_share.data().values().begin(), + frequency_vector_share.data().values().end()); break; - case CompleteShufflePhaseRequest::SketchShare::kSeed: { + case CompleteShufflePhaseRequest::FrequencyVectorShare::kSeed: { ASSIGN_OR_RETURN(frequency_count::PrngSeed seed, - GetPrngSeedFromString(sketch_share.seed())); + GetPrngSeedFromString(frequency_vector_share.seed())); ASSIGN_OR_RETURN(share_vector, - GenerateShareFromSeed(sketch_params, seed)); + GenerateShareFromSeed(frequency_vector_params, seed)); break; } - case CompleteShufflePhaseRequest::SketchShare::SHARE_TYPE_NOT_SET: + case CompleteShufflePhaseRequest::FrequencyVectorShare::SHARE_TYPE_NOT_SET: return absl::InvalidArgumentError("Share type is not defined."); break; } return share_vector; } -absl::StatusOr> CombineSketchShares( - const ShareShuffleSketchParams& sketch_params, +absl::StatusOr> CombineFrequencyVectorShares( + const ShareShuffleFrequencyVectorParams& frequency_vector_params, const google::protobuf::RepeatedPtrField< - CompleteAggregationPhaseRequest::ShareData>& sketch_shares) { - if (sketch_shares.empty()) { + CompleteAggregationPhaseRequest::ShareData>& frequency_vector_shares) { + if (frequency_vector_shares.empty()) { return absl::InvalidArgumentError( "There must be at least one share vector."); } - if (sketch_params.ring_modulus() < 2) { + if (frequency_vector_params.ring_modulus() < 2) { return absl::InvalidArgumentError("Ring modulus must be at least 2."); } std::vector combined_share( - sketch_shares.Get(0).share_vector().size(), 0); - for (int i = 0; i < sketch_shares.size(); i++) { + frequency_vector_shares.Get(0).share_vector().size(), 0); + for (int i = 0; i < frequency_vector_shares.size(); i++) { std::vector temp = - std::vector(sketch_shares.Get(i).share_vector().begin(), - sketch_shares.Get(i).share_vector().end()); + std::vector(frequency_vector_shares.Get(i).share_vector().begin(), + frequency_vector_shares.Get(i).share_vector().end()); - ASSIGN_OR_RETURN( - combined_share, - VectorAddMod(combined_share, temp, sketch_params.ring_modulus())); + ASSIGN_OR_RETURN(combined_share, + VectorAddMod(combined_share, temp, + frequency_vector_params.ring_modulus())); } return combined_share; diff --git a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.h b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.h index eca5b5a3ba..93c3199595 100644 --- a/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.h +++ b/src/main/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper.h @@ -27,12 +27,12 @@ namespace wfa::measurement::internal::duchy::protocol::share_shuffle { absl::StatusOr> GenerateReachAndFrequencyNoiseRegisters( - const ShareShuffleSketchParams& sketch_param, + const ShareShuffleFrequencyVectorParams& frequency_vector_param, const math::DistributedNoiser& distributed_reach_noiser, const math::DistributedNoiser& distributed_frequency_noiser); absl::StatusOr> GenerateReachOnlyNoiseRegisters( - const ShareShuffleSketchParams& sketch_param, + const ShareShuffleFrequencyVectorParams& frequency_vector_param, const math::DistributedNoiser& distributed_reach_noiser); absl::StatusOr GetPrngSeedFromString( @@ -42,17 +42,18 @@ absl::StatusOr GetPrngSeedFromCharVector( const std::vector& seed_vec); absl::StatusOr> GenerateShareFromSeed( - const ShareShuffleSketchParams& param, + const ShareShuffleFrequencyVectorParams& param, const frequency_count::PrngSeed& seed); -absl::StatusOr> GetShareVectorFromSketchShare( - const ShareShuffleSketchParams& sketch_params, - const CompleteShufflePhaseRequest::SketchShare& sketch_share); +absl::StatusOr> GetShareVectorFromFrequencyVectorShare( + const ShareShuffleFrequencyVectorParams& frequency_vector_params, + const CompleteShufflePhaseRequest::FrequencyVectorShare& + frequency_vector_share); -absl::StatusOr> CombineSketchShares( - const ShareShuffleSketchParams& sketch_params, +absl::StatusOr> CombineFrequencyVectorShares( + const ShareShuffleFrequencyVectorParams& frequency_vector_params, const google::protobuf::RepeatedPtrField< - CompleteAggregationPhaseRequest::ShareData>& sketch_shares); + CompleteAggregationPhaseRequest::ShareData>& frequency_vector_shares); // Returns a vector result where result[i] = X[i] - Y[i] mod modulus. absl::StatusOr> VectorSubMod( diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt index 2463cac7ed..d3b29c60d6 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMill.kt @@ -70,7 +70,7 @@ import org.wfanet.measurement.internal.duchy.protocol.CompleteAggregationPhaseRe import org.wfanet.measurement.internal.duchy.protocol.CompleteAggregationPhaseResponse import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequest import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt -import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt.sketchShare +import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt.frequencyVectorShare import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseResponse import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle.AggregationPhaseInput import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle.ShufflePhaseInput @@ -80,7 +80,7 @@ import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffleKt.shufflePhaseInput import org.wfanet.measurement.internal.duchy.protocol.completeAggregationPhaseRequest import org.wfanet.measurement.internal.duchy.protocol.completeShufflePhaseRequest -import org.wfanet.measurement.internal.duchy.protocol.shareShuffleSketchParams +import org.wfanet.measurement.internal.duchy.protocol.shareShuffleFrequencyVectorParams import org.wfanet.measurement.system.v1alpha.ComputationControlGrpcKt.ComputationControlCoroutineStub import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt import org.wfanet.measurement.system.v1alpha.ComputationParticipantKt @@ -400,9 +400,9 @@ class HonestMajorityShareShuffleMill( if (blob != null) { // Requisition in format of blob. registerCounts += requisition.details.protocol.honestMajorityShareShuffle.registerCount - sketchShares += sketchShare { + frequencyVectorShares += frequencyVectorShare { data = - CompleteShufflePhaseRequestKt.SketchShareKt.shareData { + CompleteShufflePhaseRequestKt.FrequencyVectorShareKt.shareData { values += FrequencyVector.parseFrom(blob).dataList } } @@ -416,13 +416,13 @@ class HonestMajorityShareShuffleMill( val seed = verifySecretSeed(secretSeed, hmss.encryptionKeyPair.privateKeyId, publicApiVersion) - sketchShares += sketchShare { this.seed = seed.data } + frequencyVectorShares += frequencyVectorShare { this.seed = seed.data } } } require(registerCounts.distinct().size == 1) { "All RegisterCount from requisitions must be the same. $registerCounts" } - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { registerCount = registerCounts.first() maximumCombinedFrequency = hmss.parameters.maximumFrequency * token.requisitionsCount ringModulus = hmss.parameters.ringModulus @@ -448,8 +448,8 @@ class HonestMajorityShareShuffleMill( ) val aggregationPhaseInput = aggregationPhaseInput { - combinedFrequencyVectors += result.combinedSketchList - registerCount = request.sketchParams.registerCount + combinedFrequencyVectors += result.combinedFrequencyVectorList + registerCount = request.frequencyVectorParams.registerCount } logWallClockDuration( @@ -497,12 +497,12 @@ class HonestMajorityShareShuffleMill( noiseMechanism = hmss.parameters.noiseMechanism for (input in aggregationPhaseInputs) { - sketchShares += + frequencyVectorShares += CompleteAggregationPhaseRequestKt.shareData { shareVector += input.combinedFrequencyVectorsList } } - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { require(aggregationPhaseInputs.map { it.registerCount }.distinct().size == 1) registerCount = aggregationPhaseInputs.first().registerCount maximumCombinedFrequency = hmss.parameters.maximumFrequency * token.requisitionsCount diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel index 8b157bdc08..634f55b9d1 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel @@ -124,7 +124,7 @@ kt_jvm_proto_library( proto_library( name = "share_shuffle_sketch_params_proto", - srcs = ["share_shuffle_sketch_params.proto"], + srcs = ["share_shuffle_frequency_vector_params.proto"], strip_import_prefix = IMPORT_PREFIX, ) diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto index 05e706d691..a613c07c95 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle.proto @@ -194,7 +194,7 @@ message HonestMajorityShareShuffle { message AggregationPhaseInput { // Combined FrequencyVectors from non-aggregators. repeated uint32 combined_frequency_vectors = 1; - // The number of registers in the sketch. + // The number of registers in FrequencyVectors. // // It is provided from RequisitionFulfillment. int64 register_count = 2; diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle_methods.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle_methods.proto index ff37a46faa..b5aa81e263 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle_methods.proto +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/honest_majority_share_shuffle_methods.proto @@ -20,7 +20,7 @@ import "google/protobuf/duration.proto"; import "wfa/measurement/internal/duchy/differential_privacy.proto"; import "wfa/measurement/internal/duchy/noise_mechanism.proto"; -import "wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto"; +import "wfa/measurement/internal/duchy/protocol/share_shuffle_frequency_vector_params.proto"; option java_package = "org.wfanet.measurement.internal.duchy.protocol"; option java_multiple_files = true; @@ -31,8 +31,8 @@ option java_multiple_files = true; // Request to complete shuffle phase by a non-aggregator. message CompleteShufflePhaseRequest { - // The sketch params for the Computation. - ShareShuffleSketchParams sketch_params = 1; + // The frequency_vector params for the Computation. + ShareShuffleFrequencyVectorParams frequency_vector_params = 1; // Common random seed between the workers. bytes common_random_seed = 2; @@ -60,11 +60,11 @@ message CompleteShufflePhaseRequest { // Noise mechanism used for generating noise. NoiseMechanism noise_mechanism = 6; - // Sketch shares from EDPs in format of either data or seed. + // FrequencyVector shares from EDPs in format of either data or seed. // // Sorted by ExternalRequisitionId so that non-aggregators follow the same // order. - message SketchShare { + message FrequencyVectorShare { message ShareData { repeated uint32 values = 1; } @@ -73,32 +73,32 @@ message CompleteShufflePhaseRequest { bytes seed = 2; } } - // Sketch shares ordered by the external key. - repeated SketchShare sketch_shares = 9; + // FrequencyVector shares ordered by the external key. + repeated FrequencyVectorShare frequency_vector_shares = 9; } // For non-aggregator. // The content will be sent to the aggregator. message CompleteShufflePhaseResponse { - // Combination of sketches. It is combined, noisy, and shuffled. - repeated uint32 combined_sketch = 1; + // Combination of frequency_vectors. It is combined, noisy, and shuffled. + repeated uint32 combined_frequency_vector = 1; // The CPU time of processing the request. google.protobuf.Duration elapsed_cpu_duration = 2; } // For aggregators. message CompleteAggregationPhaseRequest { - // The sketch params for the Computation. - ShareShuffleSketchParams sketch_params = 1; + // The frequency_vector params for the Computation. + ShareShuffleFrequencyVectorParams frequency_vector_params = 1; // The maximum frequency to reveal in the histogram. int32 maximum_frequency = 2; - // Combined sketches from non-aggregators. + // Combined frequency_vectors from non-aggregators. message ShareData { repeated uint32 share_vector = 1; } - repeated ShareData sketch_shares = 3; + repeated ShareData frequency_vector_shares = 3; // The sampling rate to be used by the HMSS protocol. // This is taken from the VidSamplingInterval.width parameter in the diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto b/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_frequency_vector_params.proto similarity index 71% rename from src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto rename to src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_frequency_vector_params.proto index 9915986392..e3ee2fc1ee 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_sketch_params.proto +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/share_shuffle_frequency_vector_params.proto @@ -19,15 +19,15 @@ package wfa.measurement.internal.duchy.protocol; option java_package = "org.wfanet.measurement.internal.duchy.protocol"; option java_multiple_files = true; -// Parameters used for the sketch of HonestMajorityShareShuffle protocol -// creation and estimation. -message ShareShuffleSketchParams { - // The number of registers in the sketch. +// Parameters used for the FrequencyVector of HonestMajorityShareShuffle +// protocol creation and estimation. +message ShareShuffleFrequencyVectorParams { + // The number of registers in the FrequencyVector. int64 register_count = 1; - // The maximum frequency of the combined sketch. Let N be the max frequency - // of a sketch, and p the number of EDPs, the maximum frequency of the - // combined sketch is (1 + pN). + // The maximum frequency of the combined FrequencyVector. Let N be the max + // frequency, and p the number of EDPs, the maximum frequency of the combined + // FrequencyVector is (1 + pN). int32 maximum_combined_frequency = 2; // The modulus used in the MPC protocol. It is required to be greater than diff --git a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc index 4ceb2bf05f..848c2c4095 100644 --- a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc +++ b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_helper_test.cc @@ -59,10 +59,11 @@ constexpr int kRingModulus = 128; constexpr double kEpsilon = 1.0; constexpr double kDelta = 0.000001; -TEST(GenerateReachAndFrequencyNoiseRegisters, InvalidSketchParamsFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kMaxCombinedFrequency + 1); +TEST(GenerateReachAndFrequencyNoiseRegisters, + InvalidFrequencyVectorParamsFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kMaxCombinedFrequency + 1); DifferentialPrivacyParams dp_params; dp_params.set_epsilon(kEpsilon); dp_params.set_delta(kDelta); @@ -73,17 +74,18 @@ TEST(GenerateReachAndFrequencyNoiseRegisters, InvalidSketchParamsFails) { dp_params, /*contributors_count=*/2, NoiseMechanism::DISCRETE_GAUSSIAN); EXPECT_THAT( - GenerateReachAndFrequencyNoiseRegisters(sketch_params, *reach_noiser, - *frequency_noiser) + GenerateReachAndFrequencyNoiseRegisters(frequency_vector_params, + *reach_noiser, *frequency_noiser) .status(), StatusIs(absl::StatusCode::kInvalidArgument, "must be greater than maximum combined frequency plus 1")); } -TEST(GenerateReachAndFrequencyNoiseRegisters, ValidSketchParamsSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); +TEST(GenerateReachAndFrequencyNoiseRegisters, + ValidFrequencyVectorParamsSucceeds) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); DifferentialPrivacyParams reach_dp_params; reach_dp_params.set_epsilon(kEpsilon / 10.0); reach_dp_params.set_delta(kDelta); @@ -98,32 +100,36 @@ TEST(GenerateReachAndFrequencyNoiseRegisters, ValidSketchParamsSucceeds) { /*contributors_count=*/2, NoiseMechanism::DISCRETE_GAUSSIAN); int total_noise_for_reach = reach_noiser->options().shift_offset * 2; int total_noise_per_frequency = frequency_noiser->options().shift_offset * 2; - int total_noise = - total_noise_for_reach + - sketch_params.maximum_combined_frequency() * total_noise_per_frequency; - ASSERT_OK_AND_ASSIGN(std::vector noise_registers, - GenerateReachAndFrequencyNoiseRegisters( - sketch_params, *reach_noiser, *frequency_noiser)); + int total_noise = total_noise_for_reach + + frequency_vector_params.maximum_combined_frequency() * + total_noise_per_frequency; + ASSERT_OK_AND_ASSIGN( + std::vector noise_registers, + GenerateReachAndFrequencyNoiseRegisters( + frequency_vector_params, *reach_noiser, *frequency_noiser)); std::unordered_map noise_frequency; for (auto x : noise_registers) { noise_frequency[x]++; } EXPECT_THAT(noise_registers, SizeIs(total_noise)); EXPECT_LE(noise_frequency[0], total_noise_for_reach); - for (int i = 1; i <= sketch_params.maximum_combined_frequency(); i++) { + for (int i = 1; i <= frequency_vector_params.maximum_combined_frequency(); + i++) { EXPECT_LE(noise_frequency[i], total_noise_per_frequency); } int sentinel_count = total_noise; - for (int i = 0; i <= sketch_params.maximum_combined_frequency(); i++) { + for (int i = 0; i <= frequency_vector_params.maximum_combined_frequency(); + i++) { sentinel_count -= noise_frequency[i]; } - EXPECT_EQ(noise_frequency[sketch_params.ring_modulus() - 1], sentinel_count); + EXPECT_EQ(noise_frequency[frequency_vector_params.ring_modulus() - 1], + sentinel_count); } -TEST(GenerateReachOnlyNoiseRegisters, InvalidSketchParamsFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kMaxCombinedFrequency + 1); +TEST(GenerateReachOnlyNoiseRegisters, InvalidFrequencyVectorParamsFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kMaxCombinedFrequency + 1); DifferentialPrivacyParams dp_params; dp_params.set_epsilon(kEpsilon); dp_params.set_delta(kDelta); @@ -131,15 +137,16 @@ TEST(GenerateReachOnlyNoiseRegisters, InvalidSketchParamsFails) { /*contributors_count=*/2, NoiseMechanism::DISCRETE_GAUSSIAN); EXPECT_THAT( - GenerateReachOnlyNoiseRegisters(sketch_params, *noiser).status(), + GenerateReachOnlyNoiseRegisters(frequency_vector_params, *noiser) + .status(), StatusIs(absl::StatusCode::kInvalidArgument, "must be greater than maximum combined frequency plus 1")); } -TEST(GenerateReachOnlyNoiseRegisters, ValidSketchParamsSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); +TEST(GenerateReachOnlyNoiseRegisters, ValidFrequencyVectorParamsSucceeds) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); DifferentialPrivacyParams dp_params; dp_params.set_epsilon(kEpsilon); dp_params.set_delta(kDelta); @@ -147,54 +154,57 @@ TEST(GenerateReachOnlyNoiseRegisters, ValidSketchParamsSucceeds) { /*contributors_count=*/2, NoiseMechanism::DISCRETE_GAUSSIAN); int total_noise = noiser->options().shift_offset * 2; - ASSERT_OK_AND_ASSIGN(std::vector noise_registers, - GenerateReachOnlyNoiseRegisters(sketch_params, *noiser)); + ASSERT_OK_AND_ASSIGN( + std::vector noise_registers, + GenerateReachOnlyNoiseRegisters(frequency_vector_params, *noiser)); EXPECT_THAT(noise_registers, SizeIs(total_noise)); } -TEST(GetShareVectorFromSketchShare, SketchShareTypeNotSetFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_register_count(kRegisterCount); - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); - - CompleteShufflePhaseRequest::SketchShare sketch_share; - EXPECT_THAT( - GetShareVectorFromSketchShare(sketch_params, sketch_share).status(), - StatusIs(absl::StatusCode::kInvalidArgument, "Share type")); -} - -TEST(GetShareVectorFromSketchShare, ShareFromShareDataSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_register_count(kRegisterCount); - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); - - CompleteShufflePhaseRequest::SketchShare sketch_share; - std::vector share_data(0, sketch_params.register_count()); - sketch_share.mutable_data()->mutable_values()->Add(share_data.begin(), - share_data.end()); - ASSERT_OK_AND_ASSIGN( - std::vector share_vector, - GetShareVectorFromSketchShare(sketch_params, sketch_share)); +TEST(GetShareVectorFromFrequencyVectorShare, + FrequencyVectorShareTypeNotSetFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_register_count(kRegisterCount); + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); + + CompleteShufflePhaseRequest::FrequencyVectorShare frequency_vector_share; + EXPECT_THAT(GetShareVectorFromFrequencyVectorShare(frequency_vector_params, + frequency_vector_share) + .status(), + StatusIs(absl::StatusCode::kInvalidArgument, "Share type")); +} + +TEST(GetShareVectorFromFrequencyVectorShare, ShareFromShareDataSucceeds) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_register_count(kRegisterCount); + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); + + CompleteShufflePhaseRequest::FrequencyVectorShare frequency_vector_share; + std::vector share_data(0, frequency_vector_params.register_count()); + frequency_vector_share.mutable_data()->mutable_values()->Add( + share_data.begin(), share_data.end()); + ASSERT_OK_AND_ASSIGN(std::vector share_vector, + GetShareVectorFromFrequencyVectorShare( + frequency_vector_params, frequency_vector_share)); EXPECT_EQ(share_vector, share_data); } -TEST(GetShareVectorFromSketchShare, ShareFromShareSeedSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_register_count(kRegisterCount); - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); +TEST(GetShareVectorFromFrequencyVectorShare, ShareFromShareSeedSucceeds) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_register_count(kRegisterCount); + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); - CompleteShufflePhaseRequest::SketchShare sketch_share; - std::vector share_data(0, sketch_params.register_count()); - *sketch_share.mutable_seed() = + CompleteShufflePhaseRequest::FrequencyVectorShare frequency_vector_share; + std::vector share_data(0, frequency_vector_params.register_count()); + *frequency_vector_share.mutable_seed() = std::string(kBytesPerAes256Key + kBytesPerAes256Iv, 'a'); - ASSERT_OK_AND_ASSIGN( - std::vector share_vector, - GetShareVectorFromSketchShare(sketch_params, sketch_share)); - EXPECT_THAT(share_vector, SizeIs(sketch_params.register_count())); + ASSERT_OK_AND_ASSIGN(std::vector share_vector, + GetShareVectorFromFrequencyVectorShare( + frequency_vector_params, frequency_vector_share)); + EXPECT_THAT(share_vector, SizeIs(frequency_vector_params.register_count())); } TEST(GetPrngSeedFromString, InvalidStringLengthFails) { @@ -222,30 +232,32 @@ TEST(GetPrngSeedFromCharVector, ValidVectorLengthSucceeds) { } TEST(GenerateShareFromSeed, InvalidSeedFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_register_count(kRegisterCount); - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_register_count(kRegisterCount); + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); PrngSeed seed; *seed.mutable_key() = std::string(kBytesPerAes256Key - 1, 'a'); *seed.mutable_iv() = std::string(kBytesPerAes256Iv, 'b'); - EXPECT_THAT(GenerateShareFromSeed(sketch_params, seed).status(), + EXPECT_THAT(GenerateShareFromSeed(frequency_vector_params, seed).status(), StatusIs(absl::StatusCode::kInvalidArgument, "")); } TEST(GenerateShareFromSeed, ValidSeedSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_register_count(kRegisterCount); - sketch_params.set_maximum_combined_frequency(kMaxCombinedFrequency); - sketch_params.set_ring_modulus(kRingModulus); + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_register_count(kRegisterCount); + frequency_vector_params.set_maximum_combined_frequency(kMaxCombinedFrequency); + frequency_vector_params.set_ring_modulus(kRingModulus); PrngSeed seed; *seed.mutable_key() = std::string(kBytesPerAes256Key, 'a'); *seed.mutable_iv() = std::string(kBytesPerAes256Iv, 'b'); ASSERT_OK_AND_ASSIGN(std::vector share_vector_from_seed, - GenerateShareFromSeed(sketch_params, seed)); - ASSERT_EQ(share_vector_from_seed.size(), sketch_params.register_count()); + GenerateShareFromSeed(frequency_vector_params, seed)); + ASSERT_EQ(share_vector_from_seed.size(), + frequency_vector_params.register_count()); for (int i = 0; i < share_vector_from_seed.size(); i++) { - EXPECT_LE(share_vector_from_seed[i], sketch_params.ring_modulus()); + EXPECT_LE(share_vector_from_seed[i], + frequency_vector_params.ring_modulus()); } } @@ -352,69 +364,74 @@ TEST(EstimateReach, ValidInputSucceeds) { EXPECT_EQ(reach_2, 10); } -TEST(CombineSketchShares, EmptySketchSharesFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_ring_modulus(kRingModulus); +TEST(CombineFrequencyVectorShares, EmptyFrequencyVectorSharesFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_ring_modulus(kRingModulus); CompleteAggregationPhaseRequest request; - EXPECT_THAT( - CombineSketchShares(sketch_params, request.sketch_shares()).status(), - StatusIs(absl::StatusCode::kInvalidArgument, "at least one")); + EXPECT_THAT(CombineFrequencyVectorShares(frequency_vector_params, + request.frequency_vector_shares()) + .status(), + StatusIs(absl::StatusCode::kInvalidArgument, "at least one")); } -TEST(CombineSketchShares, InvalidRingModulusFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_ring_modulus(1); +TEST(CombineFrequencyVectorShares, InvalidRingModulusFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_ring_modulus(1); CompleteAggregationPhaseRequest request; - request.add_sketch_shares()->mutable_share_vector()->Add(1); - EXPECT_THAT( - CombineSketchShares(sketch_params, request.sketch_shares()).status(), - StatusIs(absl::StatusCode::kInvalidArgument, "modulus")); + request.add_frequency_vector_shares()->mutable_share_vector()->Add(1); + EXPECT_THAT(CombineFrequencyVectorShares(frequency_vector_params, + request.frequency_vector_shares()) + .status(), + StatusIs(absl::StatusCode::kInvalidArgument, "modulus")); } -TEST(CombineSketchShares, InvalidInputShareFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_ring_modulus(kRingModulus); +TEST(CombineFrequencyVectorShares, InvalidInputShareFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_ring_modulus(kRingModulus); CompleteAggregationPhaseRequest request; std::vector share_vector_1 = {1, 0, 1, 0, 1}; std::vector share_vector_2 = {kRingModulus, 1, 0, 1, 0}; - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_1.begin(), share_vector_1.end()); - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_2.begin(), share_vector_2.end()); - EXPECT_THAT( - CombineSketchShares(sketch_params, request.sketch_shares()).status(), - StatusIs(absl::StatusCode::kInvalidArgument, - "must be less than the modulus")); + EXPECT_THAT(CombineFrequencyVectorShares(frequency_vector_params, + request.frequency_vector_shares()) + .status(), + StatusIs(absl::StatusCode::kInvalidArgument, + "must be less than the modulus")); } -TEST(CombineSketchShares, InputSharesHaveDifferentLengthFails) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_ring_modulus(kRingModulus); +TEST(CombineFrequencyVectorShares, InputSharesHaveDifferentLengthFails) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_ring_modulus(kRingModulus); CompleteAggregationPhaseRequest request; std::vector share_vector_1 = {0, 1, 0, 1, 3}; std::vector share_vector_2 = {2, 1, 0, 1, 0, 5}; - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_1.begin(), share_vector_1.end()); - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_2.begin(), share_vector_2.end()); - EXPECT_THAT( - CombineSketchShares(sketch_params, request.sketch_shares()).status(), - StatusIs(absl::StatusCode::kInvalidArgument, "length")); + EXPECT_THAT(CombineFrequencyVectorShares(frequency_vector_params, + request.frequency_vector_shares()) + .status(), + StatusIs(absl::StatusCode::kInvalidArgument, "length")); } -TEST(CombineSketchShares, ValidInputSharesAndParamsSucceeds) { - ShareShuffleSketchParams sketch_params; - sketch_params.set_ring_modulus(10); +TEST(CombineFrequencyVectorShares, ValidInputSharesAndParamsSucceeds) { + ShareShuffleFrequencyVectorParams frequency_vector_params; + frequency_vector_params.set_ring_modulus(10); CompleteAggregationPhaseRequest request; std::vector share_vector_1 = {1, 0, 1, 0, 1}; std::vector share_vector_2 = {5, 1, 0, 1, 0}; - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_1.begin(), share_vector_1.end()); - request.add_sketch_shares()->mutable_share_vector()->Add( + request.add_frequency_vector_shares()->mutable_share_vector()->Add( share_vector_2.begin(), share_vector_2.end()); ASSERT_OK_AND_ASSIGN( auto combined_share, - CombineSketchShares(sketch_params, request.sketch_shares())); + CombineFrequencyVectorShares(frequency_vector_params, + request.frequency_vector_shares())); } } // namespace diff --git a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc index 27e7705065..a461726778 100644 --- a/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc +++ b/src/test/cc/wfa/measurement/internal/duchy/protocol/share_shuffle/honest_majority_share_shuffle_utility_test.cc @@ -103,7 +103,8 @@ class ShufflePhaseTestData { *request_.mutable_common_random_seed() = std::string(kBytesPerAes256Key + kBytesPerAes256Iv, 'a'); request_.set_noise_mechanism(NoiseMechanism::DISCRETE_GAUSSIAN); - SetSketchParams(kRegisterCount, kMaxCombinedFrequency, kRingModulus); + SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); SetDifferentialPrivacyParams(kEpsilon, kDelta); PrngSeed seed = GenerateRandomSeed(); @@ -119,12 +120,14 @@ class ShufflePhaseTestData { request_.set_order(order); } - void SetSketchParams(int register_count, int maximum_combined_frequency, - int ring_modulus) { - request_.mutable_sketch_params()->set_register_count(register_count); - request_.mutable_sketch_params()->set_maximum_combined_frequency( + void SetFrequencyVectorParams(int register_count, + int maximum_combined_frequency, + int ring_modulus) { + request_.mutable_frequency_vector_params()->set_register_count( + register_count); + request_.mutable_frequency_vector_params()->set_maximum_combined_frequency( maximum_combined_frequency); - request_.mutable_sketch_params()->set_ring_modulus(ring_modulus); + request_.mutable_frequency_vector_params()->set_ring_modulus(ring_modulus); } void SetReachOnlyDifferentialPrivacyParams(double eps, double delta) { @@ -144,23 +147,28 @@ class ShufflePhaseTestData { request_.clear_frequency_dp_params(); } - void AddSeedToSketchShares(const std::string& seed) { - *request_.add_sketch_shares()->mutable_seed() = seed; + void AddSeedToFrequencyVectorShares(const std::string& seed) { + *request_.add_frequency_vector_shares()->mutable_seed() = seed; } - void AddShareToSketchShares(const std::vector& data) { - request_.add_sketch_shares()->mutable_data()->mutable_values()->Add( - data.begin(), data.end()); + void AddShareToFrequencyVectorShares(const std::vector& data) { + request_.add_frequency_vector_shares() + ->mutable_data() + ->mutable_values() + ->Add(data.begin(), data.end()); } - void AddSeedToSketchShares(const SecretShare& secret_share) { - *request_.add_sketch_shares()->mutable_seed() = + void AddSeedToFrequencyVectorShares(const SecretShare& secret_share) { + *request_.add_frequency_vector_shares()->mutable_seed() = (secret_share.share_seed().key() + secret_share.share_seed().iv()); } - void AddShareToSketchShares(const SecretShare& secret_share) { - request_.add_sketch_shares()->mutable_data()->mutable_values()->Add( - secret_share.share_vector().begin(), secret_share.share_vector().end()); + void AddShareToFrequencyVectorShares(const SecretShare& secret_share) { + request_.add_frequency_vector_shares() + ->mutable_data() + ->mutable_values() + ->Add(secret_share.share_vector().begin(), + secret_share.share_vector().end()); } absl::StatusOr> GenerateUniformRandomRange( @@ -190,9 +198,9 @@ class ShufflePhaseTestData { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/128); + test_data.SetFrequencyVectorParams(/*register_count=*/0, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/128); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "register count")); @@ -200,9 +208,9 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/1); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/1); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "at least 2")); @@ -211,9 +219,9 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InvalidRingModulusAndMaxFrequencyPairFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/4, - /*ring_modulus=*/5); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/4, + /*ring_modulus=*/5); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); @@ -222,19 +230,20 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, InputSizeDoesNotMatchTheConfigFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::vector share_data(kRegisterCount - 1, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "invalid size")); } -TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, EmptySketchSharesFails) { +TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, + EmptyFrequencyVectorSharesFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "empty")); @@ -245,7 +254,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); std::vector share_data(kRegisterCount, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_EQ(test_data.RunReachAndFrequencyShufflePhase().status(), absl::OkStatus()); } @@ -253,17 +262,17 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, NonAggregatorOrderNotSpecifiedAndDpParamsSpecifiedFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetDifferentialPrivacyParams(kEpsilon, kDelta); std::vector share_data(kRegisterCount, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_THAT(test_data.RunReachAndFrequencyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "order")); } TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, - SketchSharesContainOnlyShareVectorAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainOnlyShareVectorAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -271,39 +280,43 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); for (int i = 0; i < kEdpCount; i++) { - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); } ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = kEdpCount * share_vector[i] % kRingModulus; + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = + kEdpCount * share_vector[i] % kRingModulus; } - EXPECT_THAT(combined_sketch, - testing::UnorderedElementsAreArray(expected_combined_sketch)); + EXPECT_THAT( + combined_frequency_vector, + testing::UnorderedElementsAreArray(expected_combined_frequency_vector)); } TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, - SketchSharesContainOnlySeedsAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainOnlySeedsAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); for (int i = 0; i < kEdpCount; i++) { - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); } ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); PrngSeed seed; *seed.mutable_key() = share_seed.substr(0, kBytesPerAes256Key); @@ -315,18 +328,19 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector expected_single_share_vector, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = kEdpCount * expected_single_share_vector[i] % kRingModulus; } - EXPECT_THAT(combined_sketch, - testing::UnorderedElementsAreArray(expected_combined_sketch)); + EXPECT_THAT( + combined_frequency_vector, + testing::UnorderedElementsAreArray(expected_combined_frequency_vector)); } TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, - SketchSharesContainShareVectorAndSeedsAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainShareVectorAndSeedsAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -334,16 +348,17 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); PrngSeed seed; *seed.mutable_key() = share_seed.substr(0, kBytesPerAes256Key); @@ -355,36 +370,38 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector expected_share_vector_from_seed, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = (expected_share_vector_from_seed[i] + share_vector[i]) % kRingModulus; } - EXPECT_THAT(combined_sketch, - testing::UnorderedElementsAreArray(expected_combined_sketch)); + EXPECT_THAT( + combined_frequency_vector, + testing::UnorderedElementsAreArray(expected_combined_frequency_vector)); } TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetDifferentialPrivacyParams(kEpsilon, kDelta); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); ASSERT_OK_AND_ASSIGN( std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); DifferentialPrivacyParams reach_dp_params; reach_dp_params.set_epsilon(kEpsilon / 10.0); reach_dp_params.set_delta(kDelta); @@ -404,7 +421,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, kMaxCombinedFrequency * frequency_noiser->options().shift_offset * 2; ASSERT_THAT( - combined_sketch, + combined_frequency_vector, SizeIs(kRegisterCount + 2 * total_noise_registers_count_per_duchy)); PrngSeed seed; @@ -417,14 +434,17 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector expected_share_vector_from_seed, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch_without_noise(kRegisterCount); - for (int i = 0; i < expected_combined_sketch_without_noise.size(); i++) { - expected_combined_sketch_without_noise[i] = + std::vector expected_combined_frequency_vector_without_noise( + kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector_without_noise.size(); + i++) { + expected_combined_frequency_vector_without_noise[i] = (expected_share_vector_from_seed[i] + share_vector[i]) % kRingModulus; } - EXPECT_THAT(combined_sketch, - testing::IsSupersetOf(expected_combined_sketch_without_noise)); + EXPECT_THAT( + combined_frequency_vector, + testing::IsSupersetOf(expected_combined_frequency_vector_without_noise)); } TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, @@ -452,27 +472,30 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN(SecretShare secret_share_b, GenerateSecretShares(ss_params, input_b)); - test_data_1.AddShareToSketchShares(secret_share_a); - test_data_2.AddSeedToSketchShares(secret_share_a); + test_data_1.AddShareToFrequencyVectorShares(secret_share_a); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_a); - test_data_1.AddShareToSketchShares(secret_share_b); - test_data_2.AddSeedToSketchShares(secret_share_b); + test_data_1.AddShareToFrequencyVectorShares(secret_share_b); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_b); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_1, test_data_1.RunReachAndFrequencyShufflePhase()); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_2, test_data_2.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch_share_1(ret_1.combined_sketch().begin(), - ret_1.combined_sketch().end()); - std::vector combined_sketch_share_2(ret_2.combined_sketch().begin(), - ret_2.combined_sketch().end()); - - std::vector combined_sketch(combined_sketch_share_1.size()); - for (int i = 0; i < combined_sketch.size(); i++) { - combined_sketch[i] = - ((combined_sketch_share_1[i] + combined_sketch_share_2[i]) % - kRingModulus); + std::vector combined_frequency_vector_share_1( + ret_1.combined_frequency_vector().begin(), + ret_1.combined_frequency_vector().end()); + std::vector combined_frequency_vector_share_2( + ret_2.combined_frequency_vector().begin(), + ret_2.combined_frequency_vector().end()); + + std::vector combined_frequency_vector( + combined_frequency_vector_share_1.size()); + for (int i = 0; i < combined_frequency_vector.size(); i++) { + combined_frequency_vector[i] = ((combined_frequency_vector_share_1[i] + + combined_frequency_vector_share_2[i]) % + kRingModulus); } std::vector combined_input(kRegisterCount); @@ -480,7 +503,7 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, combined_input[i] = (input_a[i] + input_b[i] % kRingModulus); } - EXPECT_THAT(combined_sketch, + EXPECT_THAT(combined_frequency_vector, testing::UnorderedElementsAreArray(combined_input)); } @@ -507,27 +530,30 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN(SecretShare secret_share_b, GenerateSecretShares(ss_params, input_b)); - test_data_1.AddShareToSketchShares(secret_share_a); - test_data_2.AddSeedToSketchShares(secret_share_a); + test_data_1.AddShareToFrequencyVectorShares(secret_share_a); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_a); - test_data_1.AddShareToSketchShares(secret_share_b); - test_data_2.AddSeedToSketchShares(secret_share_b); + test_data_1.AddShareToFrequencyVectorShares(secret_share_b); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_b); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_1, test_data_1.RunReachAndFrequencyShufflePhase()); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_2, test_data_2.RunReachAndFrequencyShufflePhase()); - std::vector combined_sketch_share_1(ret_1.combined_sketch().begin(), - ret_1.combined_sketch().end()); - std::vector combined_sketch_share_2(ret_2.combined_sketch().begin(), - ret_2.combined_sketch().end()); - - std::vector combined_sketch(combined_sketch_share_1.size()); - for (int i = 0; i < combined_sketch.size(); i++) { - combined_sketch[i] = - ((combined_sketch_share_1[i] + combined_sketch_share_2[i]) % - kRingModulus); + std::vector combined_frequency_vector_share_1( + ret_1.combined_frequency_vector().begin(), + ret_1.combined_frequency_vector().end()); + std::vector combined_frequency_vector_share_2( + ret_2.combined_frequency_vector().begin(), + ret_2.combined_frequency_vector().end()); + + std::vector combined_frequency_vector( + combined_frequency_vector_share_1.size()); + for (int i = 0; i < combined_frequency_vector.size(); i++) { + combined_frequency_vector[i] = ((combined_frequency_vector_share_1[i] + + combined_frequency_vector_share_2[i]) % + kRingModulus); } std::vector combined_input(kRegisterCount); @@ -554,17 +580,17 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, kMaxCombinedFrequency * frequency_noiser->options().shift_offset * 2; ASSERT_THAT( - combined_sketch, + combined_frequency_vector, SizeIs(kRegisterCount + 2 * total_noise_registers_count_per_duchy)); - EXPECT_THAT(combined_sketch, testing::IsSupersetOf(combined_input)); + EXPECT_THAT(combined_frequency_vector, testing::IsSupersetOf(combined_input)); absl::flat_hash_map combined_input_frequency; for (const auto reg : combined_input) { combined_input_frequency[reg]++; } absl::flat_hash_map noisy_frequency; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { noisy_frequency[reg]++; } @@ -589,9 +615,9 @@ TEST(ReachAndFrequencyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/128); + test_data.SetFrequencyVectorParams(/*register_count=*/0, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/128); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "register count")); @@ -599,9 +625,9 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRegisterCountFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/1); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/1); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "at least 2")); @@ -610,9 +636,9 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InvalidRingModulusAndMaxFrequencyPairFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/4, - /*ring_modulus=*/5); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/4, + /*ring_modulus=*/5); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); @@ -620,9 +646,9 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, NonPrimeRingModulusFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/127, - /*ring_modulus=*/130); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/127, + /*ring_modulus=*/130); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "prime")); @@ -631,19 +657,19 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, NonPrimeRingModulusFails) { TEST(ReachOnlyShufflePhaseAtNonAggregator, InputSizeDoesNotMatchTheConfigFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::vector share_data(kRegisterCount - 1, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "invalid size")); } -TEST(ReachOnlyShufflePhaseAtNonAggregator, EmptySketchSharesFails) { +TEST(ReachOnlyShufflePhaseAtNonAggregator, EmptyFrequencyVectorSharesFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "empty")); @@ -654,24 +680,24 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); std::vector share_data(kRegisterCount, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_EQ(test_data.RunReachOnlyShufflePhase().status(), absl::OkStatus()); } TEST(ReachOnlyShufflePhaseAtNonAggregator, NonAggregatorOrderNotSpecifiedAndDpParamsSpecifiedFails) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetReachOnlyDifferentialPrivacyParams(kEpsilon, kDelta); std::vector share_data(kRegisterCount, 1); - test_data.AddShareToSketchShares(share_data); + test_data.AddShareToFrequencyVectorShares(share_data); EXPECT_THAT(test_data.RunReachOnlyShufflePhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "order")); } TEST(ReachOnlyShufflePhaseAtNonAggregator, - SketchSharesContainOnlyShareVectorAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainOnlyShareVectorAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -679,29 +705,31 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); for (int i = 0; i < kEdpCount; i++) { - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); } ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachOnlyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = kEdpCount * share_vector[i] % kRingModulus; + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = + kEdpCount * share_vector[i] % kRingModulus; } int expected_non_empty_register_count = 0; - for (const auto reg : expected_combined_sketch) { + for (const auto reg : expected_combined_frequency_vector) { if (reg != 0) { expected_non_empty_register_count++; } } int non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if ((reg % kRingModulus) != 0) { non_empty_register_count++; } @@ -711,19 +739,20 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, } TEST(ReachOnlyShufflePhaseAtNonAggregator, - SketchSharesContainOnlySeedsAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainOnlySeedsAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); for (int i = 0; i < kEdpCount; i++) { - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); } ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachOnlyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); PrngSeed seed; *seed.mutable_key() = share_seed.substr(0, kBytesPerAes256Key); @@ -735,21 +764,21 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector expected_single_share_vector, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = kEdpCount * expected_single_share_vector[i] % kRingModulus; } int expected_non_empty_register_count = 0; - for (const auto reg : expected_combined_sketch) { + for (const auto reg : expected_combined_frequency_vector) { if (reg != 0) { expected_non_empty_register_count++; } } int non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if ((reg % kRingModulus) != 0) { non_empty_register_count++; } @@ -759,7 +788,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, } TEST(ReachOnlyShufflePhaseAtNonAggregator, - SketchSharesContainShareVectorAndSeedsAndNoDpNoiseSucceeds) { + FrequencyVectorSharesContainShareVectorAndSeedsAndNoDpNoiseSucceeds) { ShufflePhaseTestData test_data; test_data.ClearDifferentialPrivacyParams(); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); @@ -767,16 +796,17 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachOnlyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); - ASSERT_THAT(combined_sketch, SizeIs(kRegisterCount)); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); + ASSERT_THAT(combined_frequency_vector, SizeIs(kRegisterCount)); PrngSeed seed; *seed.mutable_key() = share_seed.substr(0, kBytesPerAes256Key); @@ -788,21 +818,21 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN( std::vector expected_share_vector_from_seed, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch(kRegisterCount); - for (int i = 0; i < expected_combined_sketch.size(); i++) { - expected_combined_sketch[i] = + std::vector expected_combined_frequency_vector(kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector.size(); i++) { + expected_combined_frequency_vector[i] = (expected_share_vector_from_seed[i] + share_vector[i]) % kRingModulus; } int expected_non_empty_register_count = 0; - for (const auto reg : expected_combined_sketch) { + for (const auto reg : expected_combined_frequency_vector) { if (reg != 0) { expected_non_empty_register_count++; } } int non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if ((reg % kRingModulus) != 0) { non_empty_register_count++; } @@ -813,23 +843,24 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, TEST(ReachOnlyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { ShufflePhaseTestData test_data; - test_data.SetSketchParams(kRegisterCount, kMaxCombinedFrequency, - kRingModulus); + test_data.SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); test_data.SetReachOnlyDifferentialPrivacyParams(kEpsilon, kDelta); test_data.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); ASSERT_OK_AND_ASSIGN( std::vector share_vector, test_data.GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); std::string share_seed(kBytesPerAes256Key + kBytesPerAes256Iv, 'c'); - test_data.AddSeedToSketchShares(share_seed); + test_data.AddSeedToFrequencyVectorShares(share_seed); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret, test_data.RunReachOnlyShufflePhase()); - std::vector combined_sketch(ret.combined_sketch().begin(), - ret.combined_sketch().end()); + std::vector combined_frequency_vector( + ret.combined_frequency_vector().begin(), + ret.combined_frequency_vector().end()); DifferentialPrivacyParams dp_params; dp_params.set_epsilon(kEpsilon); dp_params.set_delta(kDelta); @@ -840,7 +871,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { noiser->options().shift_offset * 2; ASSERT_THAT( - combined_sketch, + combined_frequency_vector, SizeIs(kRegisterCount + 2 * total_noise_registers_count_per_duchy)); PrngSeed seed; @@ -853,21 +884,23 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ShufflePhaseWithDpNoiseSucceeds) { ASSERT_OK_AND_ASSIGN( std::vector expected_share_vector_from_seed, prng->GenerateUniformRandomRange(kRegisterCount, kRingModulus)); - std::vector expected_combined_sketch_without_noise(kRegisterCount); - for (int i = 0; i < expected_combined_sketch_without_noise.size(); i++) { - expected_combined_sketch_without_noise[i] = + std::vector expected_combined_frequency_vector_without_noise( + kRegisterCount); + for (int i = 0; i < expected_combined_frequency_vector_without_noise.size(); + i++) { + expected_combined_frequency_vector_without_noise[i] = (expected_share_vector_from_seed[i] + share_vector[i]) % kRingModulus; } int expected_non_empty_register_count = 0; - for (const auto reg : expected_combined_sketch_without_noise) { + for (const auto reg : expected_combined_frequency_vector_without_noise) { if (reg != 0) { expected_non_empty_register_count++; } } int non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if ((reg % kRingModulus) != 0) { non_empty_register_count++; } @@ -901,27 +934,30 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN(SecretShare secret_share_b, GenerateSecretShares(ss_params, input_b)); - test_data_1.AddShareToSketchShares(secret_share_a); - test_data_2.AddSeedToSketchShares(secret_share_a); + test_data_1.AddShareToFrequencyVectorShares(secret_share_a); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_a); - test_data_1.AddShareToSketchShares(secret_share_b); - test_data_2.AddSeedToSketchShares(secret_share_b); + test_data_1.AddShareToFrequencyVectorShares(secret_share_b); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_b); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_1, test_data_1.RunReachOnlyShufflePhase()); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_2, test_data_2.RunReachOnlyShufflePhase()); - std::vector combined_sketch_share_1(ret_1.combined_sketch().begin(), - ret_1.combined_sketch().end()); - std::vector combined_sketch_share_2(ret_2.combined_sketch().begin(), - ret_2.combined_sketch().end()); - - std::vector combined_sketch(combined_sketch_share_1.size()); - for (int i = 0; i < combined_sketch.size(); i++) { - combined_sketch[i] = - ((combined_sketch_share_1[i] + combined_sketch_share_2[i]) % - kRingModulus); + std::vector combined_frequency_vector_share_1( + ret_1.combined_frequency_vector().begin(), + ret_1.combined_frequency_vector().end()); + std::vector combined_frequency_vector_share_2( + ret_2.combined_frequency_vector().begin(), + ret_2.combined_frequency_vector().end()); + + std::vector combined_frequency_vector( + combined_frequency_vector_share_1.size()); + for (int i = 0; i < combined_frequency_vector.size(); i++) { + combined_frequency_vector[i] = ((combined_frequency_vector_share_1[i] + + combined_frequency_vector_share_2[i]) % + kRingModulus); } std::vector combined_input(kRegisterCount); @@ -937,7 +973,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, } int non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if ((reg % kRingModulus) != 0) { non_empty_register_count++; } @@ -971,27 +1007,30 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, ASSERT_OK_AND_ASSIGN(SecretShare secret_share_b, GenerateSecretShares(ss_params, input_b)); - test_data_1.AddShareToSketchShares(secret_share_a); - test_data_2.AddSeedToSketchShares(secret_share_a); + test_data_1.AddShareToFrequencyVectorShares(secret_share_a); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_a); - test_data_1.AddShareToSketchShares(secret_share_b); - test_data_2.AddSeedToSketchShares(secret_share_b); + test_data_1.AddShareToFrequencyVectorShares(secret_share_b); + test_data_2.AddSeedToFrequencyVectorShares(secret_share_b); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_1, test_data_1.RunReachOnlyShufflePhase()); ASSERT_OK_AND_ASSIGN(CompleteShufflePhaseResponse ret_2, test_data_2.RunReachOnlyShufflePhase()); - std::vector combined_sketch_share_1(ret_1.combined_sketch().begin(), - ret_1.combined_sketch().end()); - std::vector combined_sketch_share_2(ret_2.combined_sketch().begin(), - ret_2.combined_sketch().end()); - - std::vector combined_sketch(combined_sketch_share_1.size()); - for (int i = 0; i < combined_sketch.size(); i++) { - combined_sketch[i] = - ((combined_sketch_share_1[i] + combined_sketch_share_2[i]) % - kRingModulus); + std::vector combined_frequency_vector_share_1( + ret_1.combined_frequency_vector().begin(), + ret_1.combined_frequency_vector().end()); + std::vector combined_frequency_vector_share_2( + ret_2.combined_frequency_vector().begin(), + ret_2.combined_frequency_vector().end()); + + std::vector combined_frequency_vector( + combined_frequency_vector_share_1.size()); + for (int i = 0; i < combined_frequency_vector.size(); i++) { + combined_frequency_vector[i] = ((combined_frequency_vector_share_1[i] + + combined_frequency_vector_share_2[i]) % + kRingModulus); } std::vector combined_input(kRegisterCount); @@ -1009,7 +1048,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, noiser->options().shift_offset * 2; ASSERT_THAT( - combined_sketch, + combined_frequency_vector, SizeIs(kRegisterCount + 2 * total_noise_registers_count_per_duchy)); int non_empty_register_count = 0; @@ -1020,7 +1059,7 @@ TEST(ReachOnlyShufflePhaseAtNonAggregator, } int noisy_non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if (reg != 0) { noisy_non_empty_register_count++; } @@ -1045,7 +1084,8 @@ class AggregationPhaseTestData { request_.set_vid_sampling_interval_width(kVidSamplingIntervalWidth); request_.set_noise_mechanism(NoiseMechanism::DISCRETE_GAUSSIAN); SetDifferentialPrivacyParams(kEpsilon, kDelta); - SetSketchParams(kRegisterCount, kMaxCombinedFrequency, kRingModulus); + SetFrequencyVectorParams(kRegisterCount, kMaxCombinedFrequency, + kRingModulus); SetMaximumFrequency(kMaxFrequencyPerEdp); } @@ -1053,12 +1093,14 @@ class AggregationPhaseTestData { request_.set_maximum_frequency(maximum_frequency); } - void SetSketchParams(int register_count, int maximum_combined_frequency, - int ring_modulus) { - request_.mutable_sketch_params()->set_register_count(register_count); - request_.mutable_sketch_params()->set_maximum_combined_frequency( + void SetFrequencyVectorParams(int register_count, + int maximum_combined_frequency, + int ring_modulus) { + request_.mutable_frequency_vector_params()->set_register_count( + register_count); + request_.mutable_frequency_vector_params()->set_maximum_combined_frequency( maximum_combined_frequency); - request_.mutable_sketch_params()->set_ring_modulus(ring_modulus); + request_.mutable_frequency_vector_params()->set_ring_modulus(ring_modulus); } void ClearDifferentialPrivacyParams() { @@ -1078,9 +1120,9 @@ class AggregationPhaseTestData { request_.mutable_frequency_dp_params()->set_delta(delta); } - void AddShareToSketchShares(absl::Span data) { - request_.add_sketch_shares()->mutable_share_vector()->Add(data.begin(), - data.end()); + void AddShareToFrequencyVectorShares(absl::Span data) { + request_.add_frequency_vector_shares()->mutable_share_vector()->Add( + data.begin(), data.end()); } absl::StatusOr RunReachAndFrequencyAggregationPhase() { @@ -1116,18 +1158,18 @@ class AggregationPhaseTestData { TEST(ReachAndFrequencyAggregationPhase, InvalidRegisterCountFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/128); + test_data.SetFrequencyVectorParams(/*register_count=*/0, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/128); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "register count")); } TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/1); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/1); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "at least 2")); } @@ -1135,17 +1177,18 @@ TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusFails) { TEST(ReachAndFrequencyAggregationPhase, InvalidRingModulusAndMaxFrequencyPairFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/4, - /*ring_modulus=*/5); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/4, + /*ring_modulus=*/5); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); } -TEST(ReachAndFrequencyAggregationPhase, InvalidNumberOfSketchSharesFails) { +TEST(ReachAndFrequencyAggregationPhase, + InvalidNumberOfFrequencyVectorSharesFails) { AggregationPhaseTestData test_data; std::vector share_vector(10, 0); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "non-aggregators")); } @@ -1158,15 +1201,15 @@ TEST(ReachAndFrequencyAggregationPhase, InvalidMaximumFrequencyFails) { ASSERT_OK_AND_ASSIGN( std::vector share_vector_2, test_data.GenerateRandomShare(kRegisterCount, kRingModulus)); - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); test_data.SetMaximumFrequency(0); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "maximum")); } TEST(ReachAndFrequencyAggregationPhase, - SketchShareVectorsHaveDifferentSizeFails) { + FrequencyVectorShareVectorsHaveDifferentSizeFails) { AggregationPhaseTestData test_data; ASSERT_OK_AND_ASSIGN( std::vector share_vector_1, @@ -1174,27 +1217,28 @@ TEST(ReachAndFrequencyAggregationPhase, ASSERT_OK_AND_ASSIGN( std::vector share_vector_2, test_data.GenerateRandomShare(kRegisterCount + 1, kRingModulus)); - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); test_data.SetMaximumFrequency(0); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "same length")); } TEST(ReachAndFrequencyAggregationPhase, - CombinedSketchElementExceedsMaxCombinedFrequencyFails) { + CombinedFrequencyVectorElementExceedsMaxCombinedFrequencyFails) { AggregationPhaseTestData test_data; int register_count = 1; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/8); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); std::vector share_vector_1 = {0}; std::vector share_vector_2 = {5}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); EXPECT_THAT(test_data.RunReachAndFrequencyAggregationPhase().status(), StatusIs(absl::StatusCode::kInternal, "5")); } @@ -1203,18 +1247,20 @@ TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/8); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); - // The combined sketch is {0, 0, 0, 0, 1, 2, 3, 4}. The frequency histogram - // after removing offset is {f[0] = 4, f[1] = f[2] = f[3] = f[4] = 1}. + // The combined frequency_vector is {0, 0, 0, 0, 1, 2, 3, 4}. The frequency + // histogram after removing offset is {f[0] = 4, f[1] = f[2] = f[3] = f[4] = + // 1}. std::vector share_vector_1 = {3, 4, 3, 6, 1, 7, 2, 0}; std::vector share_vector_2 = {5, 4, 5, 2, 0, 3, 1, 4}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); ASSERT_OK_AND_ASSIGN(MpcResult result, test_data.RunReachAndFrequencyAggregationPhase()); @@ -1228,21 +1274,22 @@ TEST(ReachAndFrequencyAggregationPhase, TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseWithDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/8); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); // Frequency offset = 2 and reach offset = 6. test_data.SetDifferentialPrivacyParams(10.0, 1.0); - // The combined sketch is {0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, - // 4}. The frequency histogram after removing offset is {f[0] = 0, + // The combined frequency_vector is {0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 1, 2, 2, + // 3, 3, 4, 4}. The frequency histogram after removing offset is {f[0] = 0, // f[1] = f[2] = f[3] = f[4] = 1}. std::vector share_vector_1 = {3, 4, 3, 6, 1, 7, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; std::vector share_vector_2 = {5, 4, 5, 2, 0, 3, 7, 2, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); ASSERT_OK_AND_ASSIGN(MpcResult result, test_data.RunReachAndFrequencyAggregationPhase()); @@ -1257,20 +1304,21 @@ TEST(ReachAndFrequencyAggregationPhase, AggregationPhaseNoDataNorEffectiveNoiseFails) { AggregationPhaseTestData test_data; int register_count = 4; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/8); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/8); test_data.SetMaximumFrequency(2); // Frequency offset = 2 and reach offset = 6. test_data.SetDifferentialPrivacyParams(10.0, 1.0); - // The combined sketch is {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2}. The - // frequency histogram after removing offset is {f[0] = 4, f[2] = 1}. + // The combined frequency_vector is {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2}. + // The frequency histogram after removing offset is {f[0] = 4, f[2] = 1}. std::vector share_vector_1 = {1, 2, 3, 4, 0, 3, 4, 3, 6, 1, 7, 4, 3}; std::vector share_vector_2 = {7, 6, 5, 4, 0, 5, 4, 5, 2, 7, 3, 6, 7}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); EXPECT_THAT( test_data.RunReachAndFrequencyAggregationPhase().status(), @@ -1279,40 +1327,41 @@ TEST(ReachAndFrequencyAggregationPhase, TEST(ReachOnlyAggregationPhase, InvalidRegisterCountFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/0, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/128); + test_data.SetFrequencyVectorParams(/*register_count=*/0, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/128); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "register count")); } TEST(ReachOnlyAggregationPhase, InvalidRingModulusFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/10, - /*ring_modulus=*/1); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/10, + /*ring_modulus=*/1); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "at least 2")); } TEST(ReachOnlyAggregationPhase, InvalidRingModulusAndMaxFrequencyPairFails) { AggregationPhaseTestData test_data; - test_data.SetSketchParams(/*register_count=*/100, - /*maximum_combined_frequency=*/4, - /*ring_modulus=*/5); + test_data.SetFrequencyVectorParams(/*register_count=*/100, + /*maximum_combined_frequency=*/4, + /*ring_modulus=*/5); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "plus one")); } -TEST(ReachOnlyAggregationPhase, InvalidNumberOfSketchSharesFails) { +TEST(ReachOnlyAggregationPhase, InvalidNumberOfFrequencyVectorSharesFails) { AggregationPhaseTestData test_data; std::vector share_vector(10, 0); - test_data.AddShareToSketchShares(share_vector); + test_data.AddShareToFrequencyVectorShares(share_vector); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "non-aggregators")); } -TEST(ReachOnlyAggregationPhase, SketchShareVectorsHaveDifferentSizeFails) { +TEST(ReachOnlyAggregationPhase, + FrequencyVectorShareVectorsHaveDifferentSizeFails) { AggregationPhaseTestData test_data; ASSERT_OK_AND_ASSIGN( std::vector share_vector_1, @@ -1320,8 +1369,8 @@ TEST(ReachOnlyAggregationPhase, SketchShareVectorsHaveDifferentSizeFails) { ASSERT_OK_AND_ASSIGN( std::vector share_vector_2, test_data.GenerateRandomShare(kRegisterCount + 1, kRingModulus)); - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); EXPECT_THAT(test_data.RunReachOnlyAggregationPhase().status(), StatusIs(absl::StatusCode::kInvalidArgument, "same length")); } @@ -1329,17 +1378,18 @@ TEST(ReachOnlyAggregationPhase, SketchShareVectorsHaveDifferentSizeFails) { TEST(ReachOnlyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/7); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/7); test_data.SetMaximumFrequency(2); test_data.ClearDifferentialPrivacyParams(); - // The combined sketch is {0, 0, 0, 0, 1, 2, 3, 4}. + // The combined frequency_vector is {0, 0, 0, 0, 1, 2, 3, 4}. std::vector share_vector_1 = {2, 3, 2, 5, 1, 6, 2, 0}; std::vector share_vector_2 = {5, 4, 5, 2, 0, 3, 1, 4}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); ASSERT_OK_AND_ASSIGN(MpcResult result, test_data.RunReachOnlyAggregationPhase()); @@ -1350,20 +1400,21 @@ TEST(ReachOnlyAggregationPhase, AggregationPhaseWithoutDPNoiseSucceeds) { TEST(ReachOnlyAggregationPhase, AggregationPhaseWithDPNoiseSucceeds) { AggregationPhaseTestData test_data; int register_count = 8; - test_data.SetSketchParams(register_count, /*max_combined_frequency=*/4, - /*ring_modulus=*/7); + test_data.SetFrequencyVectorParams(register_count, + /*max_combined_frequency=*/4, + /*ring_modulus=*/7); test_data.SetMaximumFrequency(2); // Computed offset = 2. test_data.SetReachOnlyDifferentialPrivacyParams(10.0, 1.0); - // The combined sketch is {0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, - // 4}. + // The combined frequency_vector is {0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 1, 2, 2, + // 3, 3, 4, 4}. std::vector share_vector_1 = {2, 3, 2, 5, 1, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; std::vector share_vector_2 = {5, 4, 5, 2, 0, 3, 1, 4, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4}; - test_data.AddShareToSketchShares(share_vector_1); - test_data.AddShareToSketchShares(share_vector_2); + test_data.AddShareToFrequencyVectorShares(share_vector_1); + test_data.AddShareToFrequencyVectorShares(share_vector_2); ASSERT_OK_AND_ASSIGN(MpcResult result, test_data.RunReachOnlyAggregationPhase()); @@ -1383,12 +1434,12 @@ class EndToEndHmssTest { ShufflePhaseTestData worker_2; AggregationPhaseTestData aggregator; - worker_1.SetSketchParams(register_count, maximum_combined_frequency, - ring_modulus); - worker_2.SetSketchParams(register_count, maximum_combined_frequency, - ring_modulus); - aggregator.SetSketchParams(register_count, maximum_combined_frequency, - ring_modulus); + worker_1.SetFrequencyVectorParams(register_count, + maximum_combined_frequency, ring_modulus); + worker_2.SetFrequencyVectorParams(register_count, + maximum_combined_frequency, ring_modulus); + aggregator.SetFrequencyVectorParams( + register_count, maximum_combined_frequency, ring_modulus); worker_1.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); worker_2.SetNonAggregatorOrder(CompleteShufflePhaseRequest::SECOND); @@ -1432,31 +1483,31 @@ class EndToEndHmssTest { ASSIGN_OR_RETURN(auto prng, CreatePrngFromSeed(seed)); std::vector> data_from_edps(edp_count); - std::vector combined_sketch(register_count, 0); + std::vector combined_frequency_vector(register_count, 0); std::vector secret_shares(edp_count); // Emulates the EDPs. // Generates shares from input and distributes them to workers. for (int i = 0; i < edp_count; i++) { - // Generates random sketch for the Edp. + // Generates random frequency_vector for the Edp. ASSIGN_OR_RETURN(data_from_edps[i], prng->GenerateUniformRandomRange(register_count, 1 + maximum_frequency)); - // Adds the sketch to the combined sketch. - ASSIGN_OR_RETURN( - combined_sketch, - VectorAddMod(combined_sketch, data_from_edps[i], ring_modulus)); - // Generates secret share from the sketch. + // Adds the frequency_vector to the combined frequency_vector. + ASSIGN_OR_RETURN(combined_frequency_vector, + VectorAddMod(combined_frequency_vector, + data_from_edps[i], ring_modulus)); + // Generates secret share from the frequency_vector. ASSIGN_OR_RETURN( secret_shares[i], GenerateSecretShares(secret_share_params, data_from_edps[i])); - // Assigns the sketch shares to the workers. + // Assigns the frequency_vector shares to the workers. if (i % 2 == 0) { - worker_1.AddShareToSketchShares(secret_shares[i]); - worker_2.AddSeedToSketchShares(secret_shares[i]); + worker_1.AddShareToFrequencyVectorShares(secret_shares[i]); + worker_2.AddSeedToFrequencyVectorShares(secret_shares[i]); } else { - worker_1.AddSeedToSketchShares(secret_shares[i]); - worker_2.AddShareToSketchShares(secret_shares[i]); + worker_1.AddSeedToFrequencyVectorShares(secret_shares[i]); + worker_2.AddShareToFrequencyVectorShares(secret_shares[i]); } } @@ -1471,11 +1522,11 @@ class EndToEndHmssTest { worker_2.RunReachAndFrequencyShufflePhase()); std::vector share_from_worker_1( - complete_shuffle_phase_response_1.combined_sketch().begin(), - complete_shuffle_phase_response_1.combined_sketch().end()); + complete_shuffle_phase_response_1.combined_frequency_vector().begin(), + complete_shuffle_phase_response_1.combined_frequency_vector().end()); std::vector share_from_worker_2( - complete_shuffle_phase_response_2.combined_sketch().begin(), - complete_shuffle_phase_response_2.combined_sketch().end()); + complete_shuffle_phase_response_2.combined_frequency_vector().begin(), + complete_shuffle_phase_response_2.combined_frequency_vector().end()); EXPECT_THAT( share_from_worker_1, @@ -1485,11 +1536,11 @@ class EndToEndHmssTest { SizeIs(register_count + 2 * total_noise_registers_count_per_duchy)); // Emulates the aggregator. - aggregator.AddShareToSketchShares(share_from_worker_1); - aggregator.AddShareToSketchShares(share_from_worker_2); + aggregator.AddShareToFrequencyVectorShares(share_from_worker_1); + aggregator.AddShareToFrequencyVectorShares(share_from_worker_2); std::unordered_map frequency_histogram; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { frequency_histogram[reg]++; } @@ -1559,11 +1610,12 @@ class EndToEndReachOnlyHmssTest { ShufflePhaseTestData worker_2; AggregationPhaseTestData aggregator; - worker_1.SetSketchParams(register_count, edp_count, ring_modulus); + worker_1.SetFrequencyVectorParams(register_count, edp_count, ring_modulus); worker_1.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); - worker_2.SetSketchParams(register_count, edp_count, ring_modulus); + worker_2.SetFrequencyVectorParams(register_count, edp_count, ring_modulus); worker_2.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); - aggregator.SetSketchParams(register_count, edp_count, ring_modulus); + aggregator.SetFrequencyVectorParams(register_count, edp_count, + ring_modulus); aggregator.SetReachOnlyDifferentialPrivacyParams(epsilon, delta); worker_1.SetNonAggregatorOrder(CompleteShufflePhaseRequest::FIRST); worker_2.SetNonAggregatorOrder(CompleteShufflePhaseRequest::SECOND); @@ -1594,30 +1646,30 @@ class EndToEndReachOnlyHmssTest { ASSIGN_OR_RETURN(auto prng, CreatePrngFromSeed(seed)); std::vector> data_from_edps(edp_count); - std::vector combined_sketch(register_count, 0); + std::vector combined_frequency_vector(register_count, 0); std::vector secret_shares(edp_count); // Emulates the EDPs. // Generates shares from input and distributes them to workers. for (int i = 0; i < edp_count; i++) { - // Generates random sketch for the Edp. + // Generates random frequency_vector for the Edp. ASSIGN_OR_RETURN(data_from_edps[i], prng->GenerateUniformRandomRange(register_count, 2)); - // Adds the sketch to the combined sketch. - ASSIGN_OR_RETURN( - combined_sketch, - VectorAddMod(combined_sketch, data_from_edps[i], ring_modulus)); - // Generates secret share from the sketch. + // Adds the frequency_vector to the combined frequency_vector. + ASSIGN_OR_RETURN(combined_frequency_vector, + VectorAddMod(combined_frequency_vector, + data_from_edps[i], ring_modulus)); + // Generates secret share from the frequency_vector. ASSIGN_OR_RETURN( secret_shares[i], GenerateSecretShares(secret_share_params, data_from_edps[i])); - // Assigns the sketch shares to the workers. + // Assigns the frequency_vector shares to the workers. if (i % 2 == 0) { - worker_1.AddShareToSketchShares(secret_shares[i]); - worker_2.AddSeedToSketchShares(secret_shares[i]); + worker_1.AddShareToFrequencyVectorShares(secret_shares[i]); + worker_2.AddSeedToFrequencyVectorShares(secret_shares[i]); } else { - worker_1.AddSeedToSketchShares(secret_shares[i]); - worker_2.AddShareToSketchShares(secret_shares[i]); + worker_1.AddSeedToFrequencyVectorShares(secret_shares[i]); + worker_2.AddShareToFrequencyVectorShares(secret_shares[i]); } } @@ -1632,11 +1684,11 @@ class EndToEndReachOnlyHmssTest { worker_2.RunReachOnlyShufflePhase()); std::vector share_from_worker_1( - complete_shuffle_phase_response_1.combined_sketch().begin(), - complete_shuffle_phase_response_1.combined_sketch().end()); + complete_shuffle_phase_response_1.combined_frequency_vector().begin(), + complete_shuffle_phase_response_1.combined_frequency_vector().end()); std::vector share_from_worker_2( - complete_shuffle_phase_response_2.combined_sketch().begin(), - complete_shuffle_phase_response_2.combined_sketch().end()); + complete_shuffle_phase_response_2.combined_frequency_vector().begin(), + complete_shuffle_phase_response_2.combined_frequency_vector().end()); EXPECT_THAT( share_from_worker_1, @@ -1646,11 +1698,11 @@ class EndToEndReachOnlyHmssTest { SizeIs(register_count + 2 * total_noise_registers_count_per_duchy)); // Emulates the aggregator. - aggregator.AddShareToSketchShares(share_from_worker_1); - aggregator.AddShareToSketchShares(share_from_worker_2); + aggregator.AddShareToFrequencyVectorShares(share_from_worker_1); + aggregator.AddShareToFrequencyVectorShares(share_from_worker_2); int expected_non_empty_register_count = 0; - for (const auto reg : combined_sketch) { + for (const auto reg : combined_frequency_vector) { if (reg != 0) { expected_non_empty_register_count++; } diff --git a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt index 7c04a381e5..9862d8b8d7 100644 --- a/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/HonestMajorityShareShuffleMillTest.kt @@ -116,7 +116,7 @@ import org.wfanet.measurement.internal.duchy.protocol.CompleteAggregationPhaseRe import org.wfanet.measurement.internal.duchy.protocol.CompleteAggregationPhaseRequestKt import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequest import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt -import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt.sketchShare +import org.wfanet.measurement.internal.duchy.protocol.CompleteShufflePhaseRequestKt.frequencyVectorShare import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle.ShufflePhaseInput import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffle.Stage import org.wfanet.measurement.internal.duchy.protocol.HonestMajorityShareShuffleKt @@ -128,7 +128,7 @@ import org.wfanet.measurement.internal.duchy.protocol.completeAggregationPhaseRe import org.wfanet.measurement.internal.duchy.protocol.completeShufflePhaseRequest import org.wfanet.measurement.internal.duchy.protocol.completeShufflePhaseResponse import org.wfanet.measurement.internal.duchy.protocol.copy -import org.wfanet.measurement.internal.duchy.protocol.shareShuffleSketchParams +import org.wfanet.measurement.internal.duchy.protocol.shareShuffleFrequencyVectorParams import org.wfanet.measurement.storage.filesystem.FileSystemStorageClient import org.wfanet.measurement.system.v1alpha.AdvanceComputationRequest import org.wfanet.measurement.system.v1alpha.AdvanceComputationRequestKt @@ -948,7 +948,7 @@ class HonestMajorityShareShuffleMillTest { var cryptoRequest = CompleteShufflePhaseRequest.getDefaultInstance() whenever(mockCryptoWorker.completeReachAndFrequencyShufflePhase(any())).thenAnswer { cryptoRequest = it.getArgument(0) - completeShufflePhaseResponse { combinedSketch += listOf(1, 2, 3) } + completeShufflePhaseResponse { combinedFrequencyVector += listOf(1, 2, 3) } } whenever(mockCertificates.getCertificate(any())).thenAnswer { certificate { @@ -982,7 +982,7 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeShufflePhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { registerCount = 100 maximumCombinedFrequency = 30 ringModulus = RING_MODULUS @@ -992,14 +992,18 @@ class HonestMajorityShareShuffleMillTest { noiseMechanism = hmss.parameters.noiseMechanism order = CompleteShufflePhaseRequest.NonAggregatorOrder.FIRST - sketchShares += sketchShare { + frequencyVectorShares += frequencyVectorShare { data = - CompleteShufflePhaseRequestKt.SketchShareKt.shareData { values += listOf(1, 2, 3) } + CompleteShufflePhaseRequestKt.FrequencyVectorShareKt.shareData { + values += listOf(1, 2, 3) + } } - sketchShares += sketchShare { seed = requisitionSeed.data } - sketchShares += sketchShare { + frequencyVectorShares += frequencyVectorShare { seed = requisitionSeed.data } + frequencyVectorShares += frequencyVectorShare { data = - CompleteShufflePhaseRequestKt.SketchShareKt.shareData { values += listOf(4, 5, 6) } + CompleteShufflePhaseRequestKt.FrequencyVectorShareKt.shareData { + values += listOf(4, 5, 6) + } } } ) @@ -1177,7 +1181,7 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeAggregationPhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { registerCount = 3 maximumCombinedFrequency = 30 ringModulus = RING_MODULUS @@ -1188,9 +1192,9 @@ class HonestMajorityShareShuffleMillTest { frequencyDpParams = hmss.parameters.frequencyDpParams noiseMechanism = hmss.parameters.noiseMechanism - sketchShares += + frequencyVectorShares += CompleteAggregationPhaseRequestKt.shareData { shareVector += listOf(1, 2, 3) } - sketchShares += + frequencyVectorShares += CompleteAggregationPhaseRequestKt.shareData { shareVector += listOf(4, 5, 6) } } ) @@ -1253,7 +1257,7 @@ class HonestMajorityShareShuffleMillTest { var cryptoRequest = CompleteShufflePhaseRequest.getDefaultInstance() whenever(mockCryptoWorker.completeReachOnlyShufflePhase(any())).thenAnswer { cryptoRequest = it.getArgument(0) - completeShufflePhaseResponse { combinedSketch += listOf(1, 2, 3) } + completeShufflePhaseResponse { combinedFrequencyVector += listOf(1, 2, 3) } } whenever(mockCertificates.getCertificate(any())).thenAnswer { certificate { @@ -1287,7 +1291,7 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeShufflePhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { registerCount = 100 maximumCombinedFrequency = 3 ringModulus = RING_MODULUS @@ -1296,14 +1300,18 @@ class HonestMajorityShareShuffleMillTest { noiseMechanism = hmss.parameters.noiseMechanism order = CompleteShufflePhaseRequest.NonAggregatorOrder.FIRST - sketchShares += sketchShare { + frequencyVectorShares += frequencyVectorShare { data = - CompleteShufflePhaseRequestKt.SketchShareKt.shareData { values += listOf(1, 2, 3) } + CompleteShufflePhaseRequestKt.FrequencyVectorShareKt.shareData { + values += listOf(1, 2, 3) + } } - sketchShares += sketchShare { seed = requisitionSeed.data } - sketchShares += sketchShare { + frequencyVectorShares += frequencyVectorShare { seed = requisitionSeed.data } + frequencyVectorShares += frequencyVectorShare { data = - CompleteShufflePhaseRequestKt.SketchShareKt.shareData { values += listOf(4, 5, 6) } + CompleteShufflePhaseRequestKt.FrequencyVectorShareKt.shareData { + values += listOf(4, 5, 6) + } } } ) @@ -1399,7 +1407,7 @@ class HonestMajorityShareShuffleMillTest { .isEqualTo( completeAggregationPhaseRequest { val hmss = computationDetails.honestMajorityShareShuffle - sketchParams = shareShuffleSketchParams { + frequencyVectorParams = shareShuffleFrequencyVectorParams { registerCount = 3 maximumCombinedFrequency = 3 ringModulus = RING_MODULUS @@ -1409,9 +1417,9 @@ class HonestMajorityShareShuffleMillTest { reachDpParams = hmss.parameters.reachDpParams noiseMechanism = hmss.parameters.noiseMechanism - sketchShares += + frequencyVectorShares += CompleteAggregationPhaseRequestKt.shareData { shareVector += listOf(1, 2, 3) } - sketchShares += + frequencyVectorShares += CompleteAggregationPhaseRequestKt.shareData { shareVector += listOf(4, 5, 6) } } ) From 0ec4e7e8c7e31caae38c4dc212c0fd3c25c38dc6 Mon Sep 17 00:00:00 2001 From: renjiez Date: Thu, 18 Jul 2024 20:41:34 +0000 Subject: [PATCH 6/7] Update based on PR comments. --- .../duchy/daemon/mill/shareshuffle/BUILD.bazel | 2 +- .../measurement/internal/duchy/protocol/BUILD.bazel | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel index a8ceaf0804..58e3fe26bf 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/shareshuffle/BUILD.bazel @@ -36,7 +36,7 @@ kt_jvm_library( "//src/main/proto/wfa/measurement/internal/duchy:differential_privacy_kt_jvm_proto", "//src/main/proto/wfa/measurement/internal/duchy/config:protocols_setup_config_kt_jvm_proto", "//src/main/proto/wfa/measurement/internal/duchy/protocol:honest_majority_share_shuffle_methods_kt_jvm_proto", - "//src/main/proto/wfa/measurement/internal/duchy/protocol:share_shuffle_sketch_params_kt_jvm_proto", + "//src/main/proto/wfa/measurement/internal/duchy/protocol:share_shuffle_frequency_vector_params_kt_jvm_proto", "//src/main/proto/wfa/measurement/system/v1alpha:computation_control_service_kt_jvm_grpc_proto", "//src/main/proto/wfa/measurement/system/v1alpha:computation_participants_service_kt_jvm_grpc_proto", "//src/main/swig/protocol/shareshuffle:honest_majority_share_shuffle_utility", diff --git a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel index 634f55b9d1..d06a5ad696 100644 --- a/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel +++ b/src/main/proto/wfa/measurement/internal/duchy/protocol/BUILD.bazel @@ -123,14 +123,14 @@ kt_jvm_proto_library( ) proto_library( - name = "share_shuffle_sketch_params_proto", + name = "share_shuffle_frequency_vector_params_proto", srcs = ["share_shuffle_frequency_vector_params.proto"], strip_import_prefix = IMPORT_PREFIX, ) kt_jvm_proto_library( - name = "share_shuffle_sketch_params_kt_jvm_proto", - deps = [":share_shuffle_sketch_params_proto"], + name = "share_shuffle_frequency_vector_params_kt_jvm_proto", + deps = [":share_shuffle_frequency_vector_params_proto"], ) proto_library( @@ -138,7 +138,7 @@ proto_library( srcs = ["honest_majority_share_shuffle.proto"], strip_import_prefix = IMPORT_PREFIX, deps = [ - ":share_shuffle_sketch_params_proto", + ":share_shuffle_frequency_vector_params_proto", "//src/main/proto/wfa/measurement/internal/duchy:crypto_proto", "//src/main/proto/wfa/measurement/internal/duchy:differential_privacy_proto", "//src/main/proto/wfa/measurement/internal/duchy:noise_mechanism_proto", @@ -156,7 +156,7 @@ proto_library( srcs = ["honest_majority_share_shuffle_methods.proto"], strip_import_prefix = "/src/main/proto", deps = [ - ":share_shuffle_sketch_params_proto", + ":share_shuffle_frequency_vector_params_proto", "//src/main/proto/wfa/measurement/internal/duchy:differential_privacy_proto", "//src/main/proto/wfa/measurement/internal/duchy:noise_mechanism_proto", "@com_google_protobuf//:duration_proto", From 9171000d626b2bf6d3b37e6de114f868d70e88b7 Mon Sep 17 00:00:00 2001 From: renjiez Date: Fri, 19 Jul 2024 19:28:18 +0000 Subject: [PATCH 7/7] Update cross-media-measurement-api --- MODULE.bazel | 12 +--- MODULE.bazel.lock | 69 +++++++++++-------- .../service/api/v2alpha/ProtoConversions.kt | 7 ++ 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 1ad6138b3d..90377709dc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -139,19 +139,9 @@ bazel_dep( ) bazel_dep( name = "cross-media-measurement-api", - version = "0.62.0", + version = "0.64.0", repo_name = "wfa_measurement_proto", ) - -# DO_NOT_SUBMIT: Use version -archive_override( - module_name = "cross-media-measurement-api", - strip_prefix = "cross-media-measurement-api-e72bcd049d592c58e51276abeaa4565611b6597d", - urls = [ - "https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/e72bcd049d592c58e51276abeaa4565611b6597d.tar.gz", - ], -) - bazel_dep( name = "consent-signaling-client", version = "0.22.0", diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 739e9fb2e9..1678cc6739 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 6, - "moduleFileHash": "920d6bae36789ac07de8bbeefaf0cf87727cf5986cd7db5b58437061dc9001b6", + "moduleFileHash": "9231017994afd72cd0a14cba5915944d2b2380ecc8f959274753e47ce8b643bd", "flags": { "cmdRegistries": [ "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main", @@ -31,7 +31,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 196, + "line": 186, "column": 22 }, "imports": { @@ -53,7 +53,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 197, + "line": 187, "column": 15 } }, @@ -70,7 +70,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 203, + "line": 193, "column": 15 } }, @@ -103,7 +103,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 212, + "line": 202, "column": 14 } } @@ -117,7 +117,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 238, + "line": 228, "column": 20 }, "imports": { @@ -136,7 +136,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 239, + "line": 229, "column": 23 } } @@ -150,7 +150,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 247, + "line": 237, "column": 24 }, "imports": { @@ -172,7 +172,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 248, + "line": 238, "column": 15 } }, @@ -186,7 +186,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 253, + "line": 243, "column": 15 } }, @@ -200,7 +200,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 258, + "line": 248, "column": 15 } }, @@ -214,7 +214,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 263, + "line": 253, "column": 15 } }, @@ -228,7 +228,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 268, + "line": 258, "column": 15 } } @@ -242,7 +242,7 @@ "usingModule": "", "location": { "file": "@@//:MODULE.bazel", - "line": 282, + "line": 272, "column": 23 }, "imports": {}, @@ -257,7 +257,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 283, + "line": 273, "column": 17 } } @@ -293,7 +293,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 292, + "line": 282, "column": 13 } }, @@ -308,7 +308,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 299, + "line": 289, "column": 13 } }, @@ -323,7 +323,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 306, + "line": 296, "column": 13 } }, @@ -338,7 +338,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 313, + "line": 303, "column": 13 } } @@ -374,7 +374,7 @@ "wfa_rules_cue": "rules_cue@0.4.0", "wfa_common_jvm": "common-jvm@0.86.0", "wfa_common_cpp": "common-cpp@0.13.0", - "wfa_measurement_proto": "cross-media-measurement-api@_", + "wfa_measurement_proto": "cross-media-measurement-api@0.64.0", "wfa_consent_signaling_client": "consent-signaling-client@0.22.0", "any_sketch": "any-sketch@0.9.1", "any_sketch_java": "any-sketch-java@0.7.0", @@ -2702,10 +2702,10 @@ } } }, - "cross-media-measurement-api@_": { + "cross-media-measurement-api@0.64.0": { "name": "cross-media-measurement-api", - "version": "", - "key": "cross-media-measurement-api@_", + "version": "0.64.0", + "key": "cross-media-measurement-api@0.64.0", "repoName": "wfa_measurement_proto", "executionPlatformsToRegister": [], "toolchainsToRegister": [], @@ -2713,10 +2713,10 @@ { "extensionBzlFile": "@wfa_measurement_proto//build:non_module_deps.bzl", "extensionName": "non_module_deps", - "usingModule": "cross-media-measurement-api@_", + "usingModule": "cross-media-measurement-api@0.64.0", "location": { - "file": "@@cross-media-measurement-api~//:MODULE.bazel", - "line": 24, + "file": "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.64.0/MODULE.bazel", + "line": 25, "column": 32 }, "imports": { @@ -2734,6 +2734,21 @@ "com_google_googleapis": "googleapis@0.0.0-bzlmod.1", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "urls": [ + "https://github.com/world-federation-of-advertisers/cross-media-measurement-api/archive/refs/tags/v0.64.0.tar.gz" + ], + "integrity": "sha256-Y0fB3D4hGfxg1yX6FoHI8m0E0yzigRRc85MlSU799ZY=", + "strip_prefix": "cross-media-measurement-api-0.64.0", + "remote_patches": { + "https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main/modules/cross-media-measurement-api/0.64.0/patches/module_dot_bazel.patch": "sha256-G+mZ9eQNe5Xlb5YnPlp2tLs9o4tZsC7mKfSu7ZfYBQo=" + }, + "remote_patch_strip": 0 + } } }, "consent-signaling-client@0.22.0": { @@ -2746,7 +2761,7 @@ "extensionUsages": [], "deps": { "wfa_rules_kotlin_jvm": "rules_kotlin_jvm@0.2.0", - "wfa_measurement_proto": "cross-media-measurement-api@_", + "wfa_measurement_proto": "cross-media-measurement-api@0.64.0", "wfa_common_jvm": "common-jvm@0.86.0", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt index c5424bf2a3..56e0bf7e5f 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt @@ -689,6 +689,8 @@ private fun Measurement.Result.Frequency.toInternal( Measurement.Result.Frequency.MethodologyCase.LIQUID_LEGIONS_DISTRIBUTION -> { liquidLegionsDistribution = source.liquidLegionsDistribution.toInternal() } + Measurement.Result.Frequency.MethodologyCase.LIQUID_LEGIONS_V2, + Measurement.Result.Frequency.MethodologyCase.HONEST_MAJORITY_SHARE_SHUFFLE -> {} } } else if (protocolConfig.protocolsList.any { it.hasLiquidLegionsV2() }) { val cmmsProtocol = @@ -724,6 +726,11 @@ private fun Measurement.Result.Reach.toInternal( Measurement.Result.Reach.MethodologyCase.LIQUID_LEGIONS_COUNT_DISTINCT -> { liquidLegionsCountDistinct = source.liquidLegionsCountDistinct.toInternal() } + Measurement.Result.Reach.MethodologyCase.HONEST_MAJORITY_SHARE_SHUFFLE -> { + // TODO(@ple13): Add HMSS register count. + } + Measurement.Result.Reach.MethodologyCase.LIQUID_LEGIONS_V2, + Measurement.Result.Reach.MethodologyCase.REACH_ONLY_LIQUID_LEGIONS_V2 -> {} } } else if (protocolConfig.protocolsList.any { it.hasLiquidLegionsV2() }) { val cmmsProtocol =