Skip to content

Commit

Permalink
Extend support to interop runner
Browse files Browse the repository at this point in the history
  • Loading branch information
bifurcation committed Aug 1, 2023
1 parent 8bfc3e6 commit e191c42
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
6 changes: 2 additions & 4 deletions cmd/interop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ run: ${BUILD_DIR}/${APP_NAME}
./${BUILD_DIR}/${APP_NAME} -live 50001

self-test: ${BUILD_DIR}/${APP_NAME}
# TODO(RLB) Extend to 13 to cover passive client tests
for tv_type in 1 2 3 4 5 6 7 8 9 10 11 12; do \
for tv_type in 1 2 3 4 5 6 7 8 9 10 11 12 13; do \
echo Self-test on test vector type $$tv_type; \
./${BUILD_DIR}/${APP_NAME} -gen $$tv_type | ./${BUILD_DIR}/${APP_NAME} -ver $$tv_type; \
done
Expand All @@ -34,8 +33,7 @@ interop-test: ${BUILD_DIR}/${APP_NAME}
./${BUILD_DIR}/${APP_NAME} -ver 9 <${TEST_VECTOR_DIR}/welcome.json
./${BUILD_DIR}/${APP_NAME} -ver 10 <${TEST_VECTOR_DIR}/tree-operations.json
./${BUILD_DIR}/${APP_NAME} -ver 11 <${TEST_VECTOR_DIR}/treekem.json
# TODO(RLB) Uncomment once the messages test vectors are fixed
#./${BUILD_DIR}/${APP_NAME} -ver 12 <${TEST_VECTOR_DIR}/messages.json
./${BUILD_DIR}/${APP_NAME} -ver 12 <${TEST_VECTOR_DIR}/messages.json
./${BUILD_DIR}/${APP_NAME} -ver 13 <${TEST_VECTOR_DIR}/passive-client-welcome.json
./${BUILD_DIR}/${APP_NAME} -ver 13 <${TEST_VECTOR_DIR}/passive-client-handling-commit.json

Expand Down
6 changes: 5 additions & 1 deletion cmd/interop/src/json_details.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector::PSK, psk_id, psk)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector::Epoch,
proposals,
commit,
epoch_authenticator)
epoch_authenticator,
application_data,
application_message)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector,
cipher_suite,
key_package,
Expand All @@ -354,6 +356,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector,
welcome,
ratchet_tree,
initial_epoch_authenticator,
initial_epoch_application_data,
initial_epoch_application_message,
epochs)

} // namespace mls_vectors
12 changes: 11 additions & 1 deletion cmd/interop/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ make_test_vector(uint64_t type)
MessagesTestVector(),
};

// TODO(RLB) TestVectorClass::passive_client_scenarios
case TestVectorClass::passive_client_scenarios: {
auto cases = std::vector<PassiveClientTestVector>();

for (const auto& suite : mls::all_supported_suites) {
for (const auto& scenario : PassiveClientTestVector::all_scenarios) {
cases.emplace_back(suite, scenario);
}
}

return cases;
}

default:
return nullptr;
Expand Down
15 changes: 0 additions & 15 deletions lib/mls_vectors/src/mls_vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include <limits>

#include <iostream> // XXX

namespace mls_vectors {

using namespace mls;
Expand Down Expand Up @@ -2228,8 +2226,6 @@ PassiveClientTestVector::PassiveClientTestVector(CipherSuite suite,
const auto msg_opts = MessageOpts{ encrypt, {}, 0 };
switch (op) {
case ADD_OP: {
std::cout << "step=" << epoch << " op=add" << std::endl;

const auto [joiner_init_priv,
joiner_enc_priv,
joiner_sig_priv,
Expand Down Expand Up @@ -2261,8 +2257,6 @@ PassiveClientTestVector::PassiveClientTestVector(CipherSuite suite,
const auto new_member_index = next.tree().find(joiner_kp.leaf_node);
members.insert_or_assign(opt::get(new_member_index).val, new_member);

std::cout << " @ " << opt::get(new_member_index).val << " by " << committer_index << std::endl;

// Record the epoch
const auto application_data = epoch_prg.secret("application_data");
epochs.push_back({
Expand All @@ -2276,13 +2270,9 @@ PassiveClientTestVector::PassiveClientTestVector(CipherSuite suite,
}

case UPDATE_OP: {
std::cout << "step=" << epoch << " op=update" << std::endl;

const auto updater_index = random_member("updater");
auto& updater = members.at(updater_index);

std::cout << " @ " << updater_index << " by " << committer_index << std::endl;

auto proposals = std::vector<MLSMessage>{};
if (updater_index != committer_index) {
const auto update_enc_priv = epoch_prg.hpke_key("update_enc_priv");
Expand Down Expand Up @@ -2324,8 +2314,6 @@ PassiveClientTestVector::PassiveClientTestVector(CipherSuite suite,
}

case REMOVE_OP: {
std::cout << "step=" << epoch << " op=remove" << std::endl;

if (members.size() == 1) {
// re-roll
break;
Expand Down Expand Up @@ -2369,9 +2357,6 @@ PassiveClientTestVector::PassiveClientTestVector(CipherSuite suite,
}

case PSK_OP: {
std::cout << "step=" << epoch << " op=psk" << std::endl;
std::cout << " by " << committer_index << std::endl;

const auto psk_id = epoch_prg.secret("epoch_prg");
const auto psk_secret = epoch_prg.secret("epoch_secret");

Expand Down

0 comments on commit e191c42

Please sign in to comment.