Skip to content

Commit b66ba9e

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

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
@@ -727,6 +727,29 @@ void run_silentpayments_test_vector_receive(const struct bip352_test_vector *tes
727727
}
728728
}
729729

730+
static void silentpayments_sha256_tag_test(void) {
731+
secp256k1_sha256 sha;
732+
{
733+
/* "BIP0352/Inputs" */
734+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','I','n','p','u','t','s'};
735+
secp256k1_silentpayments_sha256_init_inputs(&sha);
736+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
737+
}
738+
{
739+
/* "BIP0352/SharedSecret" */
740+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','S','h','a','r','e','d', 'S','e','c','r','e','t'};
741+
secp256k1_silentpayments_sha256_init_sharedsecret(&sha);
742+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
743+
}
744+
{
745+
/* "BIP0352/Label" */
746+
static const unsigned char tag[] = {'B','I','P','0','3','5','2','/','L','a','b','e','l'};
747+
secp256k1_silentpayments_sha256_init_label(&sha);
748+
test_sha256_tag_midstate(&sha, tag, sizeof(tag));
749+
}
750+
}
751+
752+
730753
void run_silentpayments_test_vectors(void) {
731754
size_t i;
732755

@@ -743,6 +766,7 @@ void run_silentpayments_tests(void) {
743766
test_label_api();
744767
test_recipient_api();
745768
run_silentpayments_test_vectors();
769+
silentpayments_sha256_tag_test();
746770
}
747771

748772
#endif

0 commit comments

Comments
 (0)