From 3c89fd0a5127b7382b9fc93e239de21001d8bb23 Mon Sep 17 00:00:00 2001 From: Jonathan Protzenko Date: Thu, 13 Jun 2024 16:49:39 -0700 Subject: [PATCH] Fix a missing conversion at the boundary that was causing the test to crash --- js/MLS_JS.ml | 6 ++++-- js/test.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/MLS_JS.ml b/js/MLS_JS.ml index b29f509..6e2c6fa 100644 --- a/js/MLS_JS.ml +++ b/js/MLS_JS.ml @@ -33,7 +33,7 @@ let _ = | Success (key_package, hash, priv_key) -> Js.some (object%js val keyPackage = uint8array_of_bytes key_package - val privKey = priv_key + val privKey = uint8array_of_bytes priv_key val hash = uint8array_of_bytes hash end) | InternalError s -> @@ -139,7 +139,9 @@ let _ = let payload = bytes_of_uint8array payload in let lookup hash = let priv: _ Js.Opt.t = Js.Unsafe.fun_call lookup [| Js.Unsafe.inject (uint8array_of_bytes hash) |] in - Option.map bytes_of_uint8array (Js.Opt.to_option priv) + let priv = Js.Opt.to_option priv in + Printf.printf "lookup was successful? %b\n" (Option.is_some priv); + Option.map bytes_of_uint8array priv in let key_pair = bytes_of_uint8array keyPair##.pubKey, keyPair##.privKey in match MLS.process_welcome_message (FStar_Seq_Base.empty (), payload) key_pair lookup with diff --git a/js/test.js b/js/test.js index 6ef985d..f0c13e5 100644 --- a/js/test.js +++ b/js/test.js @@ -57,6 +57,11 @@ var test_main = () => { ({ state: state_B, groupId } = MLS.processWelcomeMessage(welcomeMessage.payload, signKeyPair_B, (hash) => { console.log("looking into B's store", hash); + let v = store_B[hash]; + if (!v) + console.log("hash not found in B's store"); + else + console.log("hash found in B's store, value is", v); return (store_B[hash] || null) })); console.log("B joined the group", groupId);