comparison test for debugging

This commit is contained in:
2025-08-16 17:48:02 -04:00
parent 19452f45c2
commit df23fd618a
12 changed files with 277 additions and 50 deletions

View File

@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../nostr_core/nip004.h"
#include "../nostr_core/nostr_common.h"
#include "../nostr_core/utils.h"
int main(void) {
// Test vector 1 from the existing test
const char* sk1_hex = "91ba716fa9e7ea2fcbad360cf4f8e0d312f73984da63d90f524ad61a6a1e7dbe";
const char* pk2_hex = "dcb33a629560280a0ee3b6b99b68c044fe8914ad8a984001ebf6099a9b474dc3";
const char* plaintext = "nanana";
// Convert hex keys to bytes using the system function
unsigned char sk1[32], pk2[32];
nostr_hex_to_bytes(sk1_hex, sk1, 32);
nostr_hex_to_bytes(pk2_hex, pk2, 32);
// Allocate output buffer
char* encrypted = malloc(NOSTR_NIP04_MAX_ENCRYPTED_SIZE);
if (!encrypted) {
printf("Memory allocation failed\n");
return 1;
}
// Call the encryption function
int result = nostr_nip04_encrypt(sk1, pk2, plaintext, encrypted, NOSTR_NIP04_MAX_ENCRYPTED_SIZE);
if (result == NOSTR_SUCCESS) {
printf("%s\n", encrypted);
} else {
printf("Error: %s\n", nostr_strerror(result));
}
free(encrypted);
return 0;
}