Skip to content

Commit 136be9b

Browse files
committed
tests: add sha256 tag test
Test midstate tags used in silent payments.
1 parent cdda5ef commit 136be9b

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
@@ -668,6 +668,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
668668
}
669669
}
670670

671+
static void silentpayments_sha256_tag_test(void) {
672+
secp256k1_sha256 sha;
673+
{
674+
/* "BIP0352/Inputs" */
675+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','I','n','p','u','t','s'};
676+
secp256k1_silentpayments_sha256_init_inputs(&sha);
677+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
678+
}
679+
{
680+
/* "BIP0352/SharedSecret" */
681+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','S','h','a','r','e','d', 'S','e','c','r','e','t'};
682+
secp256k1_silentpayments_sha256_init_sharedsecret(&sha);
683+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
684+
}
685+
{
686+
/* "BIP0352/Label" */
687+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','L','a','b','e','l'};
688+
secp256k1_silentpayments_sha256_init_label(&sha);
689+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
690+
}
691+
}
692+
693+
671694
void run_silentpayments_test_vectors(void) {
672695
size_t i;
673696

@@ -685,6 +708,7 @@ void run_silentpayments_tests(void) {
685708
test_label_api();
686709
test_recipient_api();
687710
run_silentpayments_test_vectors();
711+
silentpayments_sha256_tag_test();
688712
}
689713

690714
#endif

0 commit comments

Comments
 (0)