diff --git a/willow/proto/willow/aggregation_config.proto b/willow/proto/willow/aggregation_config.proto index 9fd9f2c..c6d9f03 100644 --- a/willow/proto/willow/aggregation_config.proto +++ b/willow/proto/willow/aggregation_config.proto @@ -36,60 +36,3 @@ message VectorConfig { int64 length = 1; int64 bound = 2; } - -message KeyGenRequest {} - -message KeyGenResponse { - AggregationKey aggregation_key = 1; -} - -/// The key for the aggregation. -/// -/// This should be sent to the clients so they can encrypt their contributions. -message AggregationKey { - ShellAhePublicKey ahe_public_key = 1; -} - -/// The total contribution from the client. -message Contribution { - ContributionToServer contribution_to_server = 1; - ContributionToVerifier contribution_to_verifier = 2; -} - -/// The contribution from the client to the server. -message ContributionToServer { - ShellAheRecoverCiphertext ahe_recovery_ciphertext = 1; - ShellKaheCiphertext kahe_ciphertext = 2; -} - -/// The contribution from the client to the verifier. -message ContributionToVerifier { - ShellAhePartialDecCiphertext ahe_partial_dec_ciphertext = 1; - RlweRelationProofProto rlwe_relation_proof = 2; -} - -message VerificationRequest { - repeated ContributionToVerifier contributions = 1; -} - -message VerificationResponse { - repeated bool is_valid = 1; -} - -message VerificationSummaryRequest {} - -message VerificationSummaryResponse { - DecryptionRequest decryption_request = 1; -} - -/// The request from the verifier to the decryptor to decrypt the aggregate. -message DecryptionRequest { - ShellAhePartialDecCiphertext ahe_partial_dec_ciphertext = 1; -} - -message DecryptionResponse { - ShellAhePartialDecryption ahe_partial_decryption = 1; -} - -/// This is unimplemented for the single decryptor version -message DropoutRecoveryRequest {} diff --git a/willow/src/api/BUILD b/willow/src/api/BUILD index b46a6fe..bc42a7c 100644 --- a/willow/src/api/BUILD +++ b/willow/src/api/BUILD @@ -42,51 +42,3 @@ rust_test( "//willow/src/testing_utils", ], ) - -rust_library( - name = "client", - srcs = [ - "client.rs", - ], - deps = [ - ":aggregation_config", - "//shell_wrapper:status", - "//willow/proto/willow:aggregation_config_rust_proto", - ], -) - -rust_library( - name = "decryptor", - srcs = [ - "decryptor.rs", - ], - deps = [ - ":aggregation_config", - "//shell_wrapper:status", - "//willow/proto/willow:aggregation_config_rust_proto", - ], -) - -rust_library( - name = "server", - srcs = [ - "server.rs", - ], - deps = [ - ":aggregation_config", - "//shell_wrapper:status", - "//willow/proto/willow:aggregation_config_rust_proto", - ], -) - -rust_library( - name = "verifier", - srcs = [ - "verifier.rs", - ], - deps = [ - ":aggregation_config", - "//shell_wrapper:status", - "//willow/proto/willow:aggregation_config_rust_proto", - ], -) diff --git a/willow/src/api/client.rs b/willow/src/api/client.rs deleted file mode 100644 index 8e0f163..0000000 --- a/willow/src/api/client.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2025 Google LLC -// -// 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. - -// This is the API for Willow clients. -// -// Each function should be called once (by each client) in the order they appear in the trait. -use aggregation_config::AggregationConfig; -use aggregation_config_rust_proto::{AggregationKey, Contribution}; -use std::collections::HashMap; - -pub struct Client {} - -pub struct ClientState { -} - -pub trait ClientAPI { - /// Initializes a client at the beginning of an aggregation. - /// Returns the client state to be used for subsequent calls to the client. - /// config: The configuration of the aggregation. - fn initialize_client(config: AggregationConfig) -> Result; - - /// Run by the client to generate the contribution to be sent to the server. - /// Returns the contribution to be sent to the server. - /// aggregation_key: The aggregation key to use for the contribution. - /// client_input: The input to be aggregated. - fn generate_contribution( - aggregation_key: AggregationKey, - client_input: HashMap>, - ) -> Result; -} diff --git a/willow/src/api/decryptor.rs b/willow/src/api/decryptor.rs deleted file mode 100644 index 55d3cb7..0000000 --- a/willow/src/api/decryptor.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2025 Google LLC -// -// 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. - -// This is the API for Willow decryptors. -// -// Each function should be called once by the decryptor in the order they appear in the trait. -// -// If a function returns an error, that error can be logged and the decryptor -// should be considered to have dropped out. - -use aggregation_config::AggregationConfig; -use aggregation_config_rust_proto::{ - DecryptionRequest, DecryptionResponse, KeyGenRequest, KeyGenResponse, -}; - -pub struct Decryptor {} - -pub struct DecryptorState {} - -pub struct SigningKey { - // This is a placeholder until the signing key type is defined. -} - -impl DecryptorState { - fn serialize() -> Vec { - unimplemented!() - } - - fn deserialize(serialized: &[u8]) -> Result { - unimplemented!() - } -} - -pub trait DecryptorAPI { - /// Initializes a decryptor at the beginning of an aggregation. - /// Returns the decryptor state to be used for subsequent calls to the decryptor. - /// signing_key: The private signing key of the decryptor, this must correspond to the - /// verification key provided in the config. - /// config: The configuration of the aggregation. - fn initialize_decryptor( - signing_key: SigningKey, - config: AggregationConfig, - ) -> Result; - - /// Single-decryptor case only. - /// Run by the decryptor to generate the aggregation key. - /// Returns a request to be sent to the clients. - /// decryptor_state: The state of the decryptor which will be updated. - /// request: The KeyGenRequest from the server. - fn handle_key_gen_request( - decryptor_state: &mut DecryptorState, - request: KeyGenRequest, - ) -> Result; - - /// Run by the decryptor to decrypt the output. - /// decryptor_state: The state of the decryptor which will be updated. - /// decryption_request: The decryption request from the server. - fn decrypt( - decryptor_state: &mut DecryptorState, - decryption_request: DecryptionRequest, - ) -> Result; -} diff --git a/willow/src/api/server.rs b/willow/src/api/server.rs deleted file mode 100644 index 9c67e98..0000000 --- a/willow/src/api/server.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2025 Google LLC -// -// 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. - -// This is the API for Willow servers. -// -// Each function except for ProcessContribution should be called once by the server. The -// ProcessContribution function should be called by the server once for each client contribution. -// -// If a server function returns an error, that error can be logged and the aggregation should be -// considered to have failed. - -use aggregation_config::AggregationConfig; -use aggregation_config_rust_proto::{ - Contribution, ContributionToServer, ContributionToVerifier, DecryptionRequest, - DecryptionResponse, DropoutRecoveryRequest, KeyGenRequest, -}; - -pub struct Server {} - -pub struct ServerState {} - -impl ServerState { - fn serialize() -> Vec { - unimplemented!() - } - - fn deserialize(serialized: &[u8]) -> Result { - unimplemented!() - } -} - -pub trait ServerAPI { - /// Initializes the server at the beginning of an aggregation. - /// Returns the server state to be used for subsequent calls to the server and a KeyGenRequest. - /// config: The configuration of the aggregation. - fn initialize_server( - config: AggregationConfig, - ) -> Result<(ServerState, KeyGenRequest), status::StatusError>; - - /// Run by the server to process the parts of the client input that aren't used for - /// verification. - /// If any contribution given here is invalid, the aggregation will have to - /// be aborted. - /// server_state: The state of the server which will be updated. - /// client_contributions: The contributions to be processed. - fn handle_contributions( - server_state: &mut ServerState, - client_contributions: &[ContributionToServer], - ) -> Result<(), status::StatusError>; - - /// Run by the server to process the partial decryptions from the decryptors. - /// If no dropouts have occurred returns None. Otherwise returns a request for the - /// decryptors to recover the dropouts. - /// Always returns None or an error in the single decryptor case. - /// server_state: The state of the server which will be updated. - /// decryption_responses: The partial decryption information from the decryptors. - fn handle_decryption_responses( - server_state: &mut ServerState, - decryption_responses: &[DecryptionResponse], - ) -> Result, status::StatusError>; - - /// Run by the server to generate the output of the aggregation. - /// server_state: The state of the server which will be updated. - fn generate_output(server_state: &mut ServerState) -> Result, status::StatusError>; -} diff --git a/willow/src/api/verifier.rs b/willow/src/api/verifier.rs deleted file mode 100644 index 53fc9aa..0000000 --- a/willow/src/api/verifier.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2025 Google LLC -// -// 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. - -// This is the API for Willow verifiers. -// -// Each function except for VerifyContribution should be called once by the verifier. The -// VerifyContribution function should be called by the verifier once for each client contribution. -// -// If a verifier function returns an error, that error can be logged and the aggregation should be -// considered to have failed. - -use aggregation_config::AggregationConfig; -use aggregation_config_rust_proto::{ - VerificationRequest, VerificationResponse, VerificationSummaryRequest, - VerificationSummaryResponse, -}; - -pub struct Verifier {} - -pub struct VerifierState {} - -impl VerifierState { - fn serialize() -> Vec { - unimplemented!() - } - - fn deserialize(serialized: &[u8]) -> Result { - unimplemented!() - } -} - -pub trait VerifierAPI { - /// Initializes the verifier at the beginning of an aggregation. - /// Returns the verifier state to be used for subsequent calls to the verifier. - /// config: The configuration of the aggregation. - fn initialize_verifier(config: AggregationConfig) - -> Result; - - /// Run by the verifier to process the verification of client contributions. - /// The proofs are checked for correctness. The output is a vector of bools indicating whether - /// each contribution was valid. Note this function can be called multiple times with different - /// contributions if processing all contributions isn't possible in one call. - /// verifier_state: The state of the verifier which will be updated. - /// client_contributions: The contributions to be processed. - fn verify_contributions( - verifier_state: &mut VerifierState, - client_contribution: VerificationRequest, - ) -> Result; - - /// Run by the verifier once all client contributions have been processed. - /// Returns the decryption request to be sent to the decryptors. - /// verifier_state: The state of the verifier which will be updated. - /// request: This carries no information except that a verification summary is wanted. - fn handle_verification_summary_request( - verifier_state: &mut VerifierState, - request: VerificationSummaryRequest, - ) -> Result; -}