Skip to content

Commit e1f2d3f

Browse files
committed
tests: add sha256 tag test
Test midstate tags used in silent payments.
1 parent 185c8bc commit e1f2d3f

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
@@ -706,6 +706,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
706706
}
707707
}
708708

709+
static void silentpayments_sha256_tag_test(void) {
710+
secp256k1_sha256 sha;
711+
{
712+
/* "BIP0352/Inputs" */
713+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','I','n','p','u','t','s'};
714+
secp256k1_silentpayments_sha256_init_inputs(&sha);
715+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
716+
}
717+
{
718+
/* "BIP0352/SharedSecret" */
719+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','S','h','a','r','e','d', 'S','e','c','r','e','t'};
720+
secp256k1_silentpayments_sha256_init_sharedsecret(&sha);
721+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
722+
}
723+
{
724+
/* "BIP0352/Label" */
725+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','L','a','b','e','l'};
726+
secp256k1_silentpayments_sha256_init_label(&sha);
727+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
728+
}
729+
}
730+
731+
709732
void run_silentpayments_test_vectors(void) {
710733
size_t i;
711734

@@ -722,6 +745,7 @@ void run_silentpayments_tests(void) {
722745
test_label_api();
723746
test_recipient_api();
724747
run_silentpayments_test_vectors();
748+
silentpayments_sha256_tag_test();
725749
}
726750

727751
#endif

0 commit comments

Comments
 (0)