Skip to content

Commit c7d3827

Browse files
committed
tests: add sha256 tag test
Test midstate tags used in silent payments.
1 parent 568e3ae commit c7d3827

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/modules/silentpayments/tests_impl.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
693693
CHECK(n_found == test->num_found_output_pubkeys);
694694
}
695695

696+
static void silentpayments_sha256_tag_test(void) {
697+
secp256k1_sha256 sha;
698+
{
699+
/* "BIP0352/Inputs" */
700+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','I','n','p','u','t','s'};
701+
secp256k1_silentpayments_sha256_init_inputs(&sha);
702+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
703+
}
704+
{
705+
/* "BIP0352/SharedSecret" */
706+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','S','h','a','r','e','d', 'S','e','c','r','e','t'};
707+
secp256k1_silentpayments_sha256_init_sharedsecret(&sha);
708+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
709+
}
710+
{
711+
/* "BIP0352/Label" */
712+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','L','a','b','e','l'};
713+
secp256k1_silentpayments_sha256_init_label(&sha);
714+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
715+
}
716+
}
717+
718+
696719
void run_silentpayments_test_vectors(void) {
697720
size_t i;
698721

@@ -709,6 +732,7 @@ void run_silentpayments_tests(void) {
709732
test_label_api();
710733
test_recipient_api();
711734
run_silentpayments_test_vectors();
735+
silentpayments_sha256_tag_test();
712736
}
713737

714738
#endif

0 commit comments

Comments
 (0)