@@ -121,33 +121,47 @@ TEST(Abe4Test, PackFullKey) {
121121 EXPECT_EQ (packed_mpk_b64, setup_output.mpk );
122122}
123123
124- TEST (Abe4Test, EndToEndSingleAuthority) {
125- std::string auth = " auth1" ;
126- accless::abe4::SetupOutput setup_output = accless::abe4::setup ({auth});
127- ASSERT_FALSE (setup_output.msk .empty ());
128- ASSERT_FALSE (setup_output.mpk .empty ());
129-
124+ TEST (Abe4Test, EndToEndSingleAuthorityPartial) {
125+ std::string auth_id = " TEST_AUTH_ID" ;
130126 std::string gid = " test_gid" ;
131127 std::string wfId = " foo" ;
132128 std::string nodeId = " bar" ;
133129
130+ // 1. Setup partial keys
131+ accless::abe4::SetupOutput partial_setup_output =
132+ accless::abe4::setupPartial (auth_id);
133+ ASSERT_FALSE (partial_setup_output.msk .empty ());
134+ ASSERT_FALSE (partial_setup_output.mpk .empty ());
135+
136+ // 2. Keygen partial USK
137+ std::vector<accless::abe4::UserAttribute> user_attrs = {
138+ {auth_id, " wf" , wfId}, {auth_id, " node" , nodeId}};
139+ std::string partial_usk_b64 =
140+ accless::abe4::keygenPartial (gid, partial_setup_output.msk , user_attrs);
141+ ASSERT_FALSE (partial_usk_b64.empty ());
142+
143+ // 3. Pack full MPK
144+ std::string mpk =
145+ accless::abe4::packFullKey ({auth_id}, {partial_setup_output.mpk });
146+ ASSERT_FALSE (mpk.empty ());
147+
148+ // 4. Pack full USK
149+ std::string usk = accless::abe4::packFullKey ({auth_id}, {partial_usk_b64});
150+ ASSERT_FALSE (usk.empty ());
151+
152+ // 5. Define policy
134153 std::string policy =
135- auth + " .wf:" + wfId + " & " + auth + " .node:" + nodeId;
154+ auth_id + " .wf:" + wfId + " & " + auth_id + " .node:" + nodeId;
136155
156+ // 6. Encrypt
137157 accless::abe4::EncryptOutput encrypt_output =
138- accless::abe4::encrypt (setup_output. mpk , policy);
158+ accless::abe4::encrypt (mpk, policy);
139159 ASSERT_FALSE (encrypt_output.gt .empty ());
140160 ASSERT_FALSE (encrypt_output.ciphertext .empty ());
141161
142- std::vector<accless::abe4::UserAttribute> user_attrs = {
143- {auth, " wf" , wfId}, {auth, " node" , nodeId}};
144-
145- std::string usk_b64 =
146- accless::abe4::keygen (gid, setup_output.msk , user_attrs);
147- ASSERT_FALSE (usk_b64.empty ());
148-
162+ // 7. Decrypt
149163 std::optional<std::string> decrypted_gt =
150- accless::abe4::decrypt (usk_b64 , gid, policy, encrypt_output.ciphertext );
164+ accless::abe4::decrypt (usk , gid, policy, encrypt_output.ciphertext );
151165 ASSERT_TRUE (decrypted_gt.has_value ());
152166 EXPECT_EQ (decrypted_gt.value (), encrypt_output.gt );
153167}
0 commit comments