1*14675a02SAndroid Build Coastguard Worker/* 2*14675a02SAndroid Build Coastguard Worker * Copyright 2017 Google LLC 3*14675a02SAndroid Build Coastguard Worker * 4*14675a02SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*14675a02SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*14675a02SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*14675a02SAndroid Build Coastguard Worker * 8*14675a02SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*14675a02SAndroid Build Coastguard Worker * 10*14675a02SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*14675a02SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*14675a02SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*14675a02SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*14675a02SAndroid Build Coastguard Worker * limitations under the License. 15*14675a02SAndroid Build Coastguard Worker */ 16*14675a02SAndroid Build Coastguard Worker 17*14675a02SAndroid Build Coastguard Worker// Definition of the protocol buffers for the SecAgg protocol 18*14675a02SAndroid Build Coastguard Worker 19*14675a02SAndroid Build Coastguard Workersyntax = "proto3"; 20*14675a02SAndroid Build Coastguard Worker 21*14675a02SAndroid Build Coastguard Workerpackage fcp.secagg; 22*14675a02SAndroid Build Coastguard Worker 23*14675a02SAndroid Build Coastguard Workerimport "google/protobuf/any.proto"; 24*14675a02SAndroid Build Coastguard Worker 25*14675a02SAndroid Build Coastguard Workeroption java_package = "fcp.secagg.shared"; 26*14675a02SAndroid Build Coastguard Workeroption java_outer_classname = "SecAggMessages"; 27*14675a02SAndroid Build Coastguard Worker 28*14675a02SAndroid Build Coastguard Worker// TODO(team): remove container class, using 29*14675a02SAndroid Build Coastguard Worker// option java_multiple_files = true; 30*14675a02SAndroid Build Coastguard Worker 31*14675a02SAndroid Build Coastguard Worker// # MESSAGE WRAPPERS EXPOSED TO THE OUTSIDE 32*14675a02SAndroid Build Coastguard Worker 33*14675a02SAndroid Build Coastguard Worker// This message is a wrapper (simulating polymorphism) for all messages sent 34*14675a02SAndroid Build Coastguard Worker// from a client to the server during the protocol. 35*14675a02SAndroid Build Coastguard Workermessage ClientToServerWrapperMessage { 36*14675a02SAndroid Build Coastguard Worker // Each message from client to server contains exactly one of these 37*14675a02SAndroid Build Coastguard Worker // semantic types, depending on the phase of the protocol. 38*14675a02SAndroid Build Coastguard Worker oneof message_content { 39*14675a02SAndroid Build Coastguard Worker // Abort the protocol. 40*14675a02SAndroid Build Coastguard Worker AbortMessage abort = 1; 41*14675a02SAndroid Build Coastguard Worker 42*14675a02SAndroid Build Coastguard Worker // Round 0 message; see details at message definition. 43*14675a02SAndroid Build Coastguard Worker AdvertiseKeys advertise_keys = 2; 44*14675a02SAndroid Build Coastguard Worker 45*14675a02SAndroid Build Coastguard Worker // Round 1 message; see details at message definition. 46*14675a02SAndroid Build Coastguard Worker ShareKeysResponse share_keys_response = 3; 47*14675a02SAndroid Build Coastguard Worker 48*14675a02SAndroid Build Coastguard Worker // Round 2 message; see details at message definition. 49*14675a02SAndroid Build Coastguard Worker MaskedInputCollectionResponse masked_input_response = 4; 50*14675a02SAndroid Build Coastguard Worker 51*14675a02SAndroid Build Coastguard Worker // Round 3 message; see details at message definition. 52*14675a02SAndroid Build Coastguard Worker UnmaskingResponse unmasking_response = 5; 53*14675a02SAndroid Build Coastguard Worker } 54*14675a02SAndroid Build Coastguard Worker} 55*14675a02SAndroid Build Coastguard Worker 56*14675a02SAndroid Build Coastguard Worker// This message is a wrapper (simulating polymorphism) for all messages sent 57*14675a02SAndroid Build Coastguard Worker// from the server to a client during the protocol. 58*14675a02SAndroid Build Coastguard Workermessage ServerToClientWrapperMessage { 59*14675a02SAndroid Build Coastguard Worker // Each message from server to client contains exactly one of these 60*14675a02SAndroid Build Coastguard Worker // semantic types, depending on the phase of the protocol. 61*14675a02SAndroid Build Coastguard Worker oneof message_content { 62*14675a02SAndroid Build Coastguard Worker // Abort the protocol. 63*14675a02SAndroid Build Coastguard Worker AbortMessage abort = 1; 64*14675a02SAndroid Build Coastguard Worker 65*14675a02SAndroid Build Coastguard Worker // Round 1 message; see details at message definition. 66*14675a02SAndroid Build Coastguard Worker ShareKeysRequest share_keys_request = 2; 67*14675a02SAndroid Build Coastguard Worker 68*14675a02SAndroid Build Coastguard Worker // Round 2 message; see details at message definition. 69*14675a02SAndroid Build Coastguard Worker MaskedInputCollectionRequest masked_input_request = 3; 70*14675a02SAndroid Build Coastguard Worker 71*14675a02SAndroid Build Coastguard Worker // Round 3 message; see details at message definition. 72*14675a02SAndroid Build Coastguard Worker UnmaskingRequest unmasking_request = 4; 73*14675a02SAndroid Build Coastguard Worker } 74*14675a02SAndroid Build Coastguard Worker} 75*14675a02SAndroid Build Coastguard Worker 76*14675a02SAndroid Build Coastguard Worker// # MESSAGES INTERNAL TO THE LIBRARY 77*14675a02SAndroid Build Coastguard Worker 78*14675a02SAndroid Build Coastguard Worker// ## ABORT MESSAGE 79*14675a02SAndroid Build Coastguard Worker// Sent by the server to the client to cause the client to abort and erase all 80*14675a02SAndroid Build Coastguard Worker// the state relate to the current session. Can signify either an abort due to 81*14675a02SAndroid Build Coastguard Worker// some error or an abort because the server needs no more messages. 82*14675a02SAndroid Build Coastguard Worker// Sent by the client to the server to notify it that the sending client 83*14675a02SAndroid Build Coastguard Worker// aborted. 84*14675a02SAndroid Build Coastguard Workermessage AbortMessage { 85*14675a02SAndroid Build Coastguard Worker // Can contain optional logging/diagnostic info. 86*14675a02SAndroid Build Coastguard Worker string diagnostic_info = 1; 87*14675a02SAndroid Build Coastguard Worker // If true, the client will halt early but mark the protocol as a success, 88*14675a02SAndroid Build Coastguard Worker // rather than as aborted. 89*14675a02SAndroid Build Coastguard Worker bool early_success = 2; 90*14675a02SAndroid Build Coastguard Worker} 91*14675a02SAndroid Build Coastguard Worker 92*14675a02SAndroid Build Coastguard Worker// ## ROUND 0 MESSAGES: ADVERTISE KEYS 93*14675a02SAndroid Build Coastguard Worker// AdvertiseKeys is sent by clients who wish to participate in the protocol. 94*14675a02SAndroid Build Coastguard Worker 95*14675a02SAndroid Build Coastguard Worker// Part of a ClientToServerWrapperMessage. Contains a pair of public keys. 96*14675a02SAndroid Build Coastguard Workermessage AdvertiseKeys { 97*14675a02SAndroid Build Coastguard Worker // Pair of public keys for this client. 98*14675a02SAndroid Build Coastguard Worker PairOfPublicKeys pair_of_public_keys = 1; 99*14675a02SAndroid Build Coastguard Worker} 100*14675a02SAndroid Build Coastguard Worker 101*14675a02SAndroid Build Coastguard Worker// A pair of public keys. Used as part of AdvertiseKeys and ShareKeysRequest. 102*14675a02SAndroid Build Coastguard Worker// TODO(team): move away from comprossed encoding of ECPoint into 103*14675a02SAndroid Build Coastguard Worker// encoding the complete PublicKey, including the other parameters. 104*14675a02SAndroid Build Coastguard Workermessage PairOfPublicKeys { 105*14675a02SAndroid Build Coastguard Worker // An encoding of the Diffie Hellman public key used to generate correlated 106*14675a02SAndroid Build Coastguard Worker // noise to be added to ciphertexts. 107*14675a02SAndroid Build Coastguard Worker // The encoding used is the one returned by the getEncoded(compressed=true) 108*14675a02SAndroid Build Coastguard Worker // method of the class org.bouncycastle.math.ec.ECPoint 109*14675a02SAndroid Build Coastguard Worker // TODO(team): figure out the actual encoding used. 110*14675a02SAndroid Build Coastguard Worker bytes noise_pk = 1; 111*14675a02SAndroid Build Coastguard Worker 112*14675a02SAndroid Build Coastguard Worker // An encoding of the Diffie Hellman public key used to establish private 113*14675a02SAndroid Build Coastguard Worker // channels between the protocol parties. 114*14675a02SAndroid Build Coastguard Worker // The encoding used is the one returned by the getEncoded(compressed=true) 115*14675a02SAndroid Build Coastguard Worker // method of the class org.bouncycastle.math.ec.ECPoint 116*14675a02SAndroid Build Coastguard Worker // TODO(team): figure out the actual encoding used. 117*14675a02SAndroid Build Coastguard Worker bytes enc_pk = 2; 118*14675a02SAndroid Build Coastguard Worker} 119*14675a02SAndroid Build Coastguard Worker 120*14675a02SAndroid Build Coastguard Worker// ## ROUND 1 MESSAGES: SHARE KEYS 121*14675a02SAndroid Build Coastguard Worker// Clients who are selected to participate in the protocol receive a list of the 122*14675a02SAndroid Build Coastguard Worker// (pairs of) public keys of all other clients. Each client secret-shares its 123*14675a02SAndroid Build Coastguard Worker// own noise_sk and prf_sk with all the other clients (encrypting shares for 124*14675a02SAndroid Build Coastguard Worker// client j with their own enc_pk) and sends all these encrypted shares to the 125*14675a02SAndroid Build Coastguard Worker// server for distribution. 126*14675a02SAndroid Build Coastguard Worker 127*14675a02SAndroid Build Coastguard Worker// Part of a ServerToClientWrapperMessage. Contains a list of pairs of public 128*14675a02SAndroid Build Coastguard Worker// keys, as well as the logging ID for the SecAgg execution. 129*14675a02SAndroid Build Coastguard Workermessage ShareKeysRequest { 130*14675a02SAndroid Build Coastguard Worker // List of public keys for all clients, ordered by the clients' 131*14675a02SAndroid Build Coastguard Worker // logical ids. Each client infers its logical id "i" from the 132*14675a02SAndroid Build Coastguard Worker // position "i" of its pair of keys in the list. 133*14675a02SAndroid Build Coastguard Worker // Note that the logical ids are assumed to be 1-indexed (i.e. the first 134*14675a02SAndroid Build Coastguard Worker // public key in the repeated field corresponds to client with logical id 1) 135*14675a02SAndroid Build Coastguard Worker repeated PairOfPublicKeys pairs_of_public_keys = 1; 136*14675a02SAndroid Build Coastguard Worker // The logging ID for the SecAgg execution. All participants in the protocol 137*14675a02SAndroid Build Coastguard Worker // will use this ID while logging, to allow metrics for the entire execution 138*14675a02SAndroid Build Coastguard Worker // to be collected. 139*14675a02SAndroid Build Coastguard Worker int64 sec_agg_execution_logging_id = 2; 140*14675a02SAndroid Build Coastguard Worker 141*14675a02SAndroid Build Coastguard Worker // May be populated with implementation-specific data. 142*14675a02SAndroid Build Coastguard Worker repeated google.protobuf.Any extra_data = 3; 143*14675a02SAndroid Build Coastguard Worker 144*14675a02SAndroid Build Coastguard Worker // The session ID for the Secagg execution. All clients will use this session 145*14675a02SAndroid Build Coastguard Worker // ID as part of the seed of PRNGs used during the execution of the protocol, 146*14675a02SAndroid Build Coastguard Worker bytes session_id = 4 ; 147*14675a02SAndroid Build Coastguard Worker} 148*14675a02SAndroid Build Coastguard Worker 149*14675a02SAndroid Build Coastguard Worker// Part of a ClientToServerWrapperMessage. Contains a list of encrypted pairs of 150*14675a02SAndroid Build Coastguard Worker// key shares (one for each other client). 151*14675a02SAndroid Build Coastguard Workermessage ShareKeysResponse { 152*14675a02SAndroid Build Coastguard Worker // The (1-indexed) j'th element of the repeated field (of a ShareKeysResponse 153*14675a02SAndroid Build Coastguard Worker // message sent from client i) contains the j'th shares of each of client i's 154*14675a02SAndroid Build Coastguard Worker // noise_sk and prf_sk, encrypted under client j's enc_pk and intended to be 155*14675a02SAndroid Build Coastguard Worker // sent to him. The i'th share (i.e. the share the a client would send to 156*14675a02SAndroid Build Coastguard Worker // himself) will be empty. 157*14675a02SAndroid Build Coastguard Worker // The client indexes above refer to their logical ids. 158*14675a02SAndroid Build Coastguard Worker // This field is opaque, as it will be the output of an AES/GCM encryption. 159*14675a02SAndroid Build Coastguard Worker // However, once decrypted, each entry should be interpreted as the 160*14675a02SAndroid Build Coastguard Worker // serialization of a PairOfKeyShares message. 161*14675a02SAndroid Build Coastguard Worker repeated bytes encrypted_key_shares = 1; 162*14675a02SAndroid Build Coastguard Worker} 163*14675a02SAndroid Build Coastguard Worker 164*14675a02SAndroid Build Coastguard Worker// Each of the encrypted_key_shares bytes in ShareKeysResponse and 165*14675a02SAndroid Build Coastguard Worker// MaskedInputCollectionRequest is an encryption of the serialization of this 166*14675a02SAndroid Build Coastguard Worker// message. 167*14675a02SAndroid Build Coastguard Workermessage PairOfKeyShares { 168*14675a02SAndroid Build Coastguard Worker // The two shares are encodings of BigIntegers which represents elements of 169*14675a02SAndroid Build Coastguard Worker // the group Z_p, where p is the prime denoting the field over which the 170*14675a02SAndroid Build Coastguard Worker // elliptic curve prime256v1 is defined. See the ShamirSecretSharing 171*14675a02SAndroid Build Coastguard Worker // class for more details on the sharing. 172*14675a02SAndroid Build Coastguard Worker // 173*14675a02SAndroid Build Coastguard Worker // The following comes from the BigInteger documentation (the encoding is 174*14675a02SAndroid Build Coastguard Worker // computed using the toByteArray() method): 175*14675a02SAndroid Build Coastguard Worker // [The encoding consists of] a byte array containing the two's-complement 176*14675a02SAndroid Build Coastguard Worker // representation of the BigInteger and is in big-endian byte-order: the most 177*14675a02SAndroid Build Coastguard Worker // significant byte is in the zeroth element. 178*14675a02SAndroid Build Coastguard Worker // The array will contain the minimum number of bytes required to represent 179*14675a02SAndroid Build Coastguard Worker // this BigInteger, including at least one sign bit, which is 180*14675a02SAndroid Build Coastguard Worker // (ceil((this.bitLength() + 1)/8)). 181*14675a02SAndroid Build Coastguard Worker bytes noise_sk_share = 1; 182*14675a02SAndroid Build Coastguard Worker bytes prf_sk_share = 2; 183*14675a02SAndroid Build Coastguard Worker} 184*14675a02SAndroid Build Coastguard Worker 185*14675a02SAndroid Build Coastguard Worker// ## ROUND 2 MESSAGES: MASKED INPUT COLLECTION 186*14675a02SAndroid Build Coastguard Worker// The server gives each client his shares of the keys of each other client who 187*14675a02SAndroid Build Coastguard Worker// responded in the previous round. Each client computes a masked version of its 188*14675a02SAndroid Build Coastguard Worker// own input and sends it to the server. 189*14675a02SAndroid Build Coastguard Worker 190*14675a02SAndroid Build Coastguard Worker// Part of a ServerToClientWrapperMessage. Contains a list of shares of other 191*14675a02SAndroid Build Coastguard Worker// clients' keys encrypted and intended for the client who receives this 192*14675a02SAndroid Build Coastguard Worker// message. 193*14675a02SAndroid Build Coastguard Workermessage MaskedInputCollectionRequest { 194*14675a02SAndroid Build Coastguard Worker // Each bytes field of this message (intended for party with logical id i) 195*14675a02SAndroid Build Coastguard Worker // contains an encryption of a PairOfKeyShares message. 196*14675a02SAndroid Build Coastguard Worker // The bytes are ordered according to the clients' logical ids. If a client 197*14675a02SAndroid Build Coastguard Worker // j did not send the ShareKeysResponse in the previous round, the 198*14675a02SAndroid Build Coastguard Worker // corresponding encrypted_key_shares bytes field will be empty (the receiving 199*14675a02SAndroid Build Coastguard Worker // client i will therefore consider such a client j dead from now on). 200*14675a02SAndroid Build Coastguard Worker repeated bytes encrypted_key_shares = 1; 201*14675a02SAndroid Build Coastguard Worker} 202*14675a02SAndroid Build Coastguard Worker 203*14675a02SAndroid Build Coastguard Worker// Part of a ClientToServerWrapperMessage. Contains a map of masked input 204*14675a02SAndroid Build Coastguard Worker// vectors (each identified by a name string). 205*14675a02SAndroid Build Coastguard Workermessage MaskedInputCollectionResponse { 206*14675a02SAndroid Build Coastguard Worker // The string key of the map represents the name of the input vector. 207*14675a02SAndroid Build Coastguard Worker map<string, MaskedInputVector> vectors = 1; 208*14675a02SAndroid Build Coastguard Worker} 209*14675a02SAndroid Build Coastguard Worker 210*14675a02SAndroid Build Coastguard Worker// Part of a MaskedInputCollectionResponse message. Contains an encoding of an 211*14675a02SAndroid Build Coastguard Worker// input vector masked by the addition of pseudo-random values (which will be 212*14675a02SAndroid Build Coastguard Worker// removed later). 213*14675a02SAndroid Build Coastguard Workermessage MaskedInputVector { 214*14675a02SAndroid Build Coastguard Worker // The vector contains a packed representation of a masked SecAggVector, 215*14675a02SAndroid Build Coastguard Worker // where each element is packed in little-endian order. 216*14675a02SAndroid Build Coastguard Worker bytes encoded_vector = 1; 217*14675a02SAndroid Build Coastguard Worker 218*14675a02SAndroid Build Coastguard Worker // May be populated with implementation-specific data. 219*14675a02SAndroid Build Coastguard Worker repeated google.protobuf.Any extra_data = 2; 220*14675a02SAndroid Build Coastguard Worker} 221*14675a02SAndroid Build Coastguard Worker 222*14675a02SAndroid Build Coastguard Worker// ## ROUND 3 MESSAGES: UNMASKING 223*14675a02SAndroid Build Coastguard Worker// The server communicates to the clients the list of clients which did not 224*14675a02SAndroid Build Coastguard Worker// complete the previous round (and therefore are considered dead). Each client 225*14675a02SAndroid Build Coastguard Worker// i, for each other client j, responds with either the share of noise_sk (if 226*14675a02SAndroid Build Coastguard Worker// client j is dead) OR share of prf_sk (if client j is still alive). 227*14675a02SAndroid Build Coastguard Worker 228*14675a02SAndroid Build Coastguard Worker// Part of a ServerToClientWrapperMessage. 229*14675a02SAndroid Build Coastguard Workermessage UnmaskingRequest { 230*14675a02SAndroid Build Coastguard Worker // Clients which were alive at round 2, but did not send a ROUND 2 response, 231*14675a02SAndroid Build Coastguard Worker // so they are considered dead from round 3 onwards. 232*14675a02SAndroid Build Coastguard Worker // NOTE: to minimize bandwidth, this DOES NOT include clients which dropped 233*14675a02SAndroid Build Coastguard Worker // before round 2 (i.e. those who did not send a round 1 response). 234*14675a02SAndroid Build Coastguard Worker repeated uint32 dead_3_client_ids = 1; 235*14675a02SAndroid Build Coastguard Worker} 236*14675a02SAndroid Build Coastguard Worker 237*14675a02SAndroid Build Coastguard Worker// Part of a ClientToServerWrapperMessage. 238*14675a02SAndroid Build Coastguard Workermessage UnmaskingResponse { 239*14675a02SAndroid Build Coastguard Worker // These shares are NOT encrypted. For each other client j, client i sends to 240*14675a02SAndroid Build Coastguard Worker // the server his share of noise_sk (if client j is dead) OR share of prf_sk 241*14675a02SAndroid Build Coastguard Worker // (if client j is still alive). 242*14675a02SAndroid Build Coastguard Worker // The entries corresponding to clients who died before round 2 (i.e. the 243*14675a02SAndroid Build Coastguard Worker // ones for which the client sending the message never got any key shares) are 244*14675a02SAndroid Build Coastguard Worker // empty. The entry corresponding to the client sending the message must be 245*14675a02SAndroid Build Coastguard Worker // a prf_sk_share (otherwise the client would be dead and would not be sending 246*14675a02SAndroid Build Coastguard Worker // this response. 247*14675a02SAndroid Build Coastguard Worker repeated NoiseOrPrfKeyShare noise_or_prf_key_shares = 1; 248*14675a02SAndroid Build Coastguard Worker} 249*14675a02SAndroid Build Coastguard Worker 250*14675a02SAndroid Build Coastguard Worker// Part of an UnmaskingResponse. Contains either a share of a noise secret key 251*14675a02SAndroid Build Coastguard Worker// or a share of a prf secret key. 252*14675a02SAndroid Build Coastguard Workermessage NoiseOrPrfKeyShare { 253*14675a02SAndroid Build Coastguard Worker // Either a share of a noise secrete key or a share of a prf secret key. 254*14675a02SAndroid Build Coastguard Worker // An honest client never reveals both, therefore oneof is appropriate. 255*14675a02SAndroid Build Coastguard Worker oneof oneof_shares { 256*14675a02SAndroid Build Coastguard Worker // A share of a noise secret key. 257*14675a02SAndroid Build Coastguard Worker bytes noise_sk_share = 1; 258*14675a02SAndroid Build Coastguard Worker 259*14675a02SAndroid Build Coastguard Worker // A share of a prf secret key. 260*14675a02SAndroid Build Coastguard Worker bytes prf_sk_share = 2; 261*14675a02SAndroid Build Coastguard Worker } 262*14675a02SAndroid Build Coastguard Worker} 263*14675a02SAndroid Build Coastguard Worker 264*14675a02SAndroid Build Coastguard Worker// Version(s) supported on each client. 265*14675a02SAndroid Build Coastguard Workerenum ClientVariant { 266*14675a02SAndroid Build Coastguard Worker // No SecAgg versions are supported on this client. 267*14675a02SAndroid Build Coastguard Worker SECAGG_CLIENT_VARIANT_NONE = 0; 268*14675a02SAndroid Build Coastguard Worker // The Java implementation of the SegAgg client. 269*14675a02SAndroid Build Coastguard Worker SECAGG_CLIENT_VARIANT_JAVA = 1 [deprecated = true]; 270*14675a02SAndroid Build Coastguard Worker // The native (C++) implementation of the SegAgg client. 271*14675a02SAndroid Build Coastguard Worker SECAGG_CLIENT_VARIANT_NATIVE_V1 = 2; 272*14675a02SAndroid Build Coastguard Worker} 273