|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +edition = "2023"; |
| 16 | + |
| 17 | +package secure_aggregation.willow; |
| 18 | + |
| 19 | +// This message describes the specification of the input data for the secure |
| 20 | +// aggregation protocol. It contains two lists of `InputVectorSpec` messages: |
| 21 | +// `metric_vector_specs` for metrics to be aggregated and |
| 22 | +// `group_by_vector_specs` for columns used for grouping. |
| 23 | +// |
| 24 | +// Each `InputVectorSpec` includes: |
| 25 | +// - `vector_name`: The name of the input vector. |
| 26 | +// - `data_type`: The data type of the values in the vector. |
| 27 | +// - `domain_spec`: An optional specification of the domain of the values in |
| 28 | +// the vector, used for validation and encoding. |
| 29 | +// |
| 30 | +// Examples: |
| 31 | +// |
| 32 | +// 1. Specifying a GROUP_BY column for "country": |
| 33 | +// group_by_vector_specs { |
| 34 | +// vector_name: "country" |
| 35 | +// data_type: STRING |
| 36 | +// domain_spec { |
| 37 | +// string_values { |
| 38 | +// values: ["US", "CA", "MX"] |
| 39 | +// } |
| 40 | +// } |
| 41 | +// } |
| 42 | +// This defines a group-by vector named "country" of type STRING, where |
| 43 | +// the allowed values are "US", "CA", and "MX". |
| 44 | +// |
| 45 | +// 2. Specifying a METRIC column for "revenue": |
| 46 | +// metric_vector_specs { |
| 47 | +// vector_name: "revenue" |
| 48 | +// data_type: INT64 |
| 49 | +// domain_spec { |
| 50 | +// interval { |
| 51 | +// min: 0 |
| 52 | +// max: 1000000 |
| 53 | +// } |
| 54 | +// } |
| 55 | +// } |
| 56 | +// This defines a metric vector named "revenue" of type INT64, where |
| 57 | +// values are expected to be between 0 and 1,000,000. |
| 58 | +// |
| 59 | +// 3. Specifying a GROUP_BY column for "is_active": |
| 60 | +// group_by_vector_specs { |
| 61 | +// vector_name: "is_active" |
| 62 | +// data_type: BOOL |
| 63 | +// } |
| 64 | +// This defines a group-by vector named "is_active" of type BOOL. |
| 65 | +message InputSpec { |
| 66 | + // Supported data types for output vectors |
| 67 | + enum DataType { |
| 68 | + DATA_TYPE_UNSPECIFIED = 0; |
| 69 | + INT32 = 1; |
| 70 | + INT64 = 2; |
| 71 | + BOOL = 3; |
| 72 | + FLOAT = 4; |
| 73 | + DOUBLE = 5; |
| 74 | + BYTES = 6; |
| 75 | + STRING = 7; |
| 76 | + } |
| 77 | + // Defines a domain as an interval. |
| 78 | + message Interval { |
| 79 | + // The lower bound of the interval. The interval is inclusive. |
| 80 | + double min = 1; |
| 81 | + // The upper bound of the interval. The interval is inclusive. |
| 82 | + double max = 2; |
| 83 | + } |
| 84 | + |
| 85 | + message StringValues { |
| 86 | + repeated string values = 1; |
| 87 | + } |
| 88 | + |
| 89 | + // A new message type to represent the domain specification. |
| 90 | + message DomainSpec { |
| 91 | + oneof domain_type { |
| 92 | + // Defines a domain as an ordered list of string values. |
| 93 | + StringValues string_values = 1; |
| 94 | + |
| 95 | + // Defines a domain as an interval of values. |
| 96 | + Interval interval = 2; |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + message InputVectorSpec { |
| 101 | + // The output vector name. |
| 102 | + string vector_name = 1; |
| 103 | + |
| 104 | + // The data type for each entry in the vector. |
| 105 | + DataType data_type = 2; |
| 106 | + |
| 107 | + // An field to define the domain of the output vector. |
| 108 | + // This could be used for validation or other logic. |
| 109 | + DomainSpec domain_spec = 3; |
| 110 | + } |
| 111 | + repeated InputVectorSpec metric_vector_specs = 1; |
| 112 | + repeated InputVectorSpec group_by_vector_specs = 2; |
| 113 | +} |
0 commit comments