Skip to content

Commit ef3763a

Browse files
committed
tests: add sha256 tag test
Test midstate tags used in silent payments.
1 parent 16ffb01 commit ef3763a

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
@@ -696,6 +696,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
696696
}
697697
}
698698

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

@@ -713,6 +736,7 @@ void run_silentpayments_tests(void) {
713736
test_label_api();
714737
test_recipient_api();
715738
run_silentpayments_test_vectors();
739+
silentpayments_sha256_tag_test();
716740
}
717741

718742
#endif

0 commit comments

Comments
 (0)