Skip to content

Commit 179759e

Browse files
josibaketheStack
authored andcommitted
tests: add sha256 tag test
Test midstate tags used in silent payments.
1 parent 6cf228d commit 179759e

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
@@ -636,6 +636,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
636636
CHECK(n_found == test->num_found_output_pubkeys);
637637
}
638638

639+
static void silentpayments_sha256_tag_test(void) {
640+
secp256k1_sha256 sha;
641+
{
642+
/* "BIP0352/Inputs" */
643+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','I','n','p','u','t','s'};
644+
secp256k1_silentpayments_sha256_init_inputs(&sha);
645+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
646+
}
647+
{
648+
/* "BIP0352/SharedSecret" */
649+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','S','h','a','r','e','d', 'S','e','c','r','e','t'};
650+
secp256k1_silentpayments_sha256_init_sharedsecret(&sha);
651+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
652+
}
653+
{
654+
/* "BIP0352/Label" */
655+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','L','a','b','e','l'};
656+
secp256k1_silentpayments_sha256_init_label(&sha);
657+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
658+
}
659+
}
660+
661+
639662
void run_silentpayments_test_vectors(void) {
640663
size_t i;
641664

@@ -653,6 +676,7 @@ static const struct tf_test_entry tests_silentpayments[] = {
653676
CASE1(test_label_api),
654677
CASE1(test_recipient_api),
655678
CASE1(run_silentpayments_test_vectors),
679+
CASE1(silentpayments_sha256_tag_test),
656680
};
657681

658682
#endif

0 commit comments

Comments
 (0)