Fixed bug in nip44.c, was an error in ecdh_shared_secret. Added comments
This commit is contained in:
BIN
tests/bip32_test
BIN
tests/bip32_test
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/nip04_test
BIN
tests/nip04_test
Binary file not shown.
BIN
tests/nip05_test
BIN
tests/nip05_test
Binary file not shown.
BIN
tests/nip11_test
BIN
tests/nip11_test
Binary file not shown.
BIN
tests/nip44_test
BIN
tests/nip44_test
Binary file not shown.
@@ -83,12 +83,6 @@ static int hex_to_bytes(const char* hex, unsigned char* bytes, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bytes_to_hex(const unsigned char* bytes, size_t len, char* hex) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
sprintf(hex + i * 2, "%02x", bytes[i]);
|
||||
}
|
||||
hex[len * 2] = '\0';
|
||||
}
|
||||
|
||||
static int test_nip44_round_trip(const nip44_test_vector_t* tv) {
|
||||
printf("Test: %s\n", tv->name);
|
||||
@@ -364,31 +358,39 @@ int main() {
|
||||
size_t num_vectors = sizeof(test_vectors) / sizeof(test_vectors[0]);
|
||||
for (size_t i = 0; i < num_vectors; i++) {
|
||||
total_tests++;
|
||||
printf("Test #%d\n", total_tests);
|
||||
if (test_nip44_round_trip(&test_vectors[i]) == 0) {
|
||||
passed_tests++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// Test decryption vectors (cross-compatibility)
|
||||
size_t num_decryption_vectors = sizeof(decryption_test_vectors) / sizeof(decryption_test_vectors[0]);
|
||||
for (size_t i = 0; i < num_decryption_vectors; i++) {
|
||||
total_tests++;
|
||||
printf("Test #%d\n", total_tests);
|
||||
if (test_nip44_decryption_vector(&decryption_test_vectors[i]) == 0) {
|
||||
passed_tests++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// Test encryption variability (NIP-44 non-deterministic behavior)
|
||||
total_tests++;
|
||||
printf("Test #%d\n", total_tests);
|
||||
if (test_nip44_encryption_variability() == 0) {
|
||||
passed_tests++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Test error conditions
|
||||
total_tests++;
|
||||
printf("Test #%d\n", total_tests);
|
||||
if (test_nip44_error_conditions() == 0) {
|
||||
passed_tests++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Final results
|
||||
printf("\nTest Results: %d/%d passed\n", passed_tests, total_tests);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
tests/wss_test
BIN
tests/wss_test
Binary file not shown.
Reference in New Issue
Block a user