Skip to content

Commit 53260e6

Browse files
tholopcopybara-github
authored andcommitted
Fix accumulator to use same context string as client; add test on verification.
PiperOrigin-RevId: 856362599
1 parent 5335d5d commit 53260e6

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

willow/src/api/server_accumulator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ pub struct ServerAccumulator {
112112

113113
impl ServerAccumulator {
114114
fn new(aggregation_config: AggregationConfig) -> Result<Self, StatusError> {
115-
let context_string = aggregation_config.session_id.as_bytes();
115+
let context_string = aggregation_config.compute_context_bytes()?;
116116
let vahe_config = create_shell_ahe_config(aggregation_config.max_number_of_decryptors)?;
117117
let kahe_config = create_shell_kahe_config(&aggregation_config)?;
118-
let server_kahe = ShellKahe::new(kahe_config, context_string)?;
119-
let server_vahe = ShellVahe::new(vahe_config.clone(), context_string)?;
120-
let verifier_vahe = ShellVahe::new(vahe_config, context_string)?;
118+
let server_kahe = ShellKahe::new(kahe_config, &context_string)?;
119+
let server_vahe = ShellVahe::new(vahe_config.clone(), &context_string)?;
120+
let verifier_vahe = ShellVahe::new(vahe_config, &context_string)?;
121121
let server = WillowV1Server { kahe: server_kahe, vahe: server_vahe };
122122
let verifier = WillowV1Verifier { vahe: verifier_vahe };
123123
Ok(Self {

willow/src/api/server_accumulator_test.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,5 +458,31 @@ TEST_F(ServerAccumulatorTest, ProcessClientMessagesMergesThreeRanges) {
458458
}
459459
}
460460

461+
TEST_F(ServerAccumulatorTest, VerifiesCorrectly) {
462+
willow::EncodedData encoded_data = {
463+
{"test_vector", {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}}};
464+
std::string nonce = "nonce1";
465+
SECAGG_ASSERT_OK_AND_ASSIGN(
466+
auto client_message,
467+
GenerateClientContribution(config_, encoded_data, public_key_, nonce));
468+
ClientMessageRange messages;
469+
*messages.add_client_messages() = client_message;
470+
messages.mutable_nonce_range()->set_start("nonce1");
471+
messages.mutable_nonce_range()->set_end("nonce2");
472+
473+
SECAGG_ASSERT_OK(accumulator_->ProcessClientMessages(messages));
474+
475+
SECAGG_ASSERT_OK_AND_ASSIGN(auto serialized_state,
476+
accumulator_->ToSerializedState());
477+
ServerAccumulatorState state;
478+
ASSERT_TRUE(state.ParseFromString(serialized_state));
479+
480+
ASSERT_EQ(state.verifier_states_size(), 1);
481+
willow::VerifierStateProto verifier_state = state.verifier_states(0);
482+
483+
// Proto should be non-empty, i.e. the underlying Rust Option should be Some.
484+
ASSERT_GE(verifier_state.ByteSizeLong(), 1);
485+
}
486+
461487
} // namespace
462488
} // namespace secure_aggregation

0 commit comments

Comments
 (0)