@@ -61,8 +61,8 @@ TEST_CASE_METHOD(TreeKEMTest, "Node public key")
6161TEST_CASE_METHOD (TreeKEMTest, " TreeKEM Private Key" )
6262{
6363 const auto size = LeafCount{ 5 };
64- const auto index = LeafIndex{ 2 };
65- const auto intersect = NodeIndex{ 3 };
64+ const auto adder_index = LeafIndex{ 1 };
65+ const auto joiner_index = LeafIndex{ 2 };
6666 const auto random = random_bytes (32 );
6767 const auto priv = HPKEPrivateKey::derive (suite, random);
6868 const auto priv2 = HPKEPrivateKey::generate (suite);
@@ -75,22 +75,27 @@ TEST_CASE_METHOD(TreeKEMTest, "TreeKEM Private Key")
7575 pub.add_leaf (leaf_node);
7676 }
7777
78- // create() populates the direct path
79- auto priv_create = TreeKEMPrivateKey::create (pub, index , random);
80- REQUIRE (priv_create.path_secrets .find (NodeIndex (4 )) !=
78+ // create() populates the direct path in the private key
79+ auto priv_create = TreeKEMPrivateKey::create (pub, adder_index , random);
80+ REQUIRE (priv_create.path_secrets .find (NodeIndex (2 )) !=
8181 priv_create.path_secrets .end ());
82- REQUIRE (priv_create.path_secrets .find (NodeIndex (5 )) !=
82+ REQUIRE (priv_create.path_secrets .find (NodeIndex (1 )) !=
8383 priv_create.path_secrets .end ());
8484 REQUIRE (priv_create.path_secrets .find (NodeIndex (3 )) !=
8585 priv_create.path_secrets .end ());
8686 REQUIRE (priv_create.path_secrets .find (NodeIndex (7 )) !=
8787 priv_create.path_secrets .end ());
8888 REQUIRE (priv_create.update_secret .size () == hash_size);
8989
90+ // Populate the direct path from the into the public key manually
91+ pub.node_at (NodeIndex{ 1 }) = OptionalNode{ Node{ ParentNode{} } };
92+ pub.node_at (NodeIndex{ 3 }) = OptionalNode{ Node{ ParentNode{} } };
93+ pub.node_at (NodeIndex{ 7 }) = OptionalNode{ Node{ ParentNode{} } };
94+
9095 // joiner() populates the leaf and the path above the ancestor,
9196 // but not the direct path in the middle
92- auto priv_joiner =
93- TreeKEMPrivateKey::joiner ( pub, index , priv, intersect , random);
97+ auto priv_joiner = TreeKEMPrivateKey::joiner (
98+ pub, joiner_index , priv, joiner_index. ancestor (adder_index) , random);
9499 REQUIRE (priv_joiner.private_key (NodeIndex (4 )));
95100 REQUIRE (priv_joiner.path_secrets .find (NodeIndex (3 )) !=
96101 priv_joiner.path_secrets .end ());
@@ -103,7 +108,7 @@ TEST_CASE_METHOD(TreeKEMTest, "TreeKEM Private Key")
103108
104109 // set_leaf_priv() properly sets the leaf secret
105110 priv_joiner.set_leaf_priv (priv2);
106- REQUIRE (priv_joiner.private_key (NodeIndex (index )) == priv2);
111+ REQUIRE (priv_joiner.private_key (NodeIndex (joiner_index )) == priv2);
107112 REQUIRE (priv_joiner.update_secret .size () == hash_size);
108113 REQUIRE (priv_joiner.update_secret == last_update_secret);
109114
0 commit comments