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 f6e91e315ac..94e1cb9ad5a 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 @@ -140,8 +140,8 @@ fun InternalNoiseMechanism.toNoiseMechanism(): NoiseMechanism { return when (this) { InternalNoiseMechanism.GEOMETRIC -> NoiseMechanism.GEOMETRIC InternalNoiseMechanism.DISCRETE_GAUSSIAN -> NoiseMechanism.DISCRETE_GAUSSIAN - InternalNoiseMechanism.UNRECOGNIZED, - InternalNoiseMechanism.NOISE_MECHANISM_UNSPECIFIED -> error("Noise mechanism not specified") + InternalNoiseMechanism.NOISE_MECHANISM_UNSPECIFIED, + InternalNoiseMechanism.UNRECOGNIZED -> error("invalid internal noise mechanism.") } } @@ -194,7 +194,16 @@ fun InternalProtocolConfig.toProtocolConfig( } ellipticCurveId = source.liquidLegionsV2.ellipticCurveId maximumFrequency = source.liquidLegionsV2.maximumFrequency - noiseMechanism = source.liquidLegionsV2.noiseMechanism.toNoiseMechanism() + // Use `GEOMETRIC` for unspecified InternalNoiseMechanism for old Measurements. + noiseMechanism = + if ( + source.liquidLegionsV2.noiseMechanism == + InternalNoiseMechanism.NOISE_MECHANISM_UNSPECIFIED + ) { + NoiseMechanism.GEOMETRIC + } else { + source.liquidLegionsV2.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 a18994b9b0a..40b647c3c6b 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 @@ -230,7 +230,16 @@ fun buildMpcProtocolConfig( } ellipticCurveId = protocolConfig.liquidLegionsV2.ellipticCurveId maximumFrequency = protocolConfig.liquidLegionsV2.maximumFrequency - noiseMechanism = protocolConfig.liquidLegionsV2.noiseMechanism.toSystemNoiseMechanism() + // Use `GEOMETRIC` for unspecified InternalNoiseMechanism for old Measurements. + noiseMechanism = + if ( + protocolConfig.liquidLegionsV2.noiseMechanism == + InternalProtocolConfig.NoiseMechanism.NOISE_MECHANISM_UNSPECIFIED + ) { + NoiseMechanism.GEOMETRIC + } else { + protocolConfig.liquidLegionsV2.noiseMechanism.toSystemNoiseMechanism() + } } } } @@ -336,12 +345,12 @@ fun DuchyMeasurementLogEntry.toSystemComputationLogEntry( .build() } -/** Converts an internal NoiseMechanism to a system NoiseMechanism */ +/** Converts an internal NoiseMechanism to a system NoiseMechanism. */ fun InternalNoiseMechanism.toSystemNoiseMechanism(): NoiseMechanism { return when (this) { InternalNoiseMechanism.GEOMETRIC -> NoiseMechanism.GEOMETRIC InternalNoiseMechanism.DISCRETE_GAUSSIAN -> NoiseMechanism.DISCRETE_GAUSSIAN - InternalNoiseMechanism.UNRECOGNIZED, - InternalNoiseMechanism.NOISE_MECHANISM_UNSPECIFIED -> error("Invalid internal NoiseMechanism.") + InternalNoiseMechanism.NOISE_MECHANISM_UNSPECIFIED, + InternalNoiseMechanism.UNRECOGNIZED -> error("invalid internal noise mechanism.") } } 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 cf34e9501f0..b5c954e90c8 100644 --- a/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto +++ b/src/main/proto/wfa/measurement/internal/kingdom/protocol_config.proto @@ -55,6 +55,8 @@ message ProtocolConfig { int32 maximum_frequency = 4; // The mechanism to generate noise during computation. + // + // If not specified the value is assumed to be `GEOMETRIC`. NoiseMechanism noise_mechanism = 5; }