Upgrade nip4 and nip44 to be able to handle 1MB payloads.

This commit is contained in:
2025-10-24 18:56:30 -04:00
parent 45fb6d061d
commit 23c2a58c2b
16 changed files with 216 additions and 96 deletions

View File

@@ -671,8 +671,8 @@ int test_vector_7_10kb_payload(void) {
printf("Last 80 chars: \"...%.80s\"\n", encrypted + encrypted_len - 80);
printf("\n");
// Test decryption with our ciphertext
char* decrypted = malloc(NOSTR_NIP04_MAX_PLAINTEXT_SIZE);
// Test decryption with our ciphertext - allocate larger buffer for safety
char* decrypted = malloc(NOSTR_NIP04_MAX_PLAINTEXT_SIZE + 1024); // 1MB + 1KB extra
if (!decrypted) {
printf("❌ MEMORY ALLOCATION FAILED for decrypted buffer\n");
free(large_plaintext);
@@ -680,7 +680,7 @@ int test_vector_7_10kb_payload(void) {
return 0;
}
printf("Testing decryption of 1MB ciphertext (Bob decrypts from Alice)...\n");
result = nostr_nip04_decrypt(sk2, pk1, encrypted, decrypted, NOSTR_NIP04_MAX_PLAINTEXT_SIZE);
result = nostr_nip04_decrypt(sk2, pk1, encrypted, decrypted, NOSTR_NIP04_MAX_PLAINTEXT_SIZE + 1024);
if (result != NOSTR_SUCCESS) {
printf("❌ 1MB DECRYPTION FAILED: %s\n", nostr_strerror(result));