Completed refactoring to separate nip files, and updating build.sh
This commit is contained in:
72
nostr_core/nip044.h
Normal file
72
nostr_core/nip044.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* NIP-44: Encrypted Payloads (Versioned)
|
||||
* https://github.com/nostr-protocol/nips/blob/master/44.md
|
||||
*/
|
||||
|
||||
#ifndef NOSTR_NIP044_H
|
||||
#define NOSTR_NIP044_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// NIP-44 constants
|
||||
// #define NOSTR_NIP44_MAX_PLAINTEXT_SIZE 65535
|
||||
|
||||
/**
|
||||
* NIP-44: Encrypt a message using ECDH + ChaCha20 + HMAC
|
||||
*
|
||||
* @param sender_private_key 32-byte sender private key
|
||||
* @param recipient_public_key 32-byte recipient public key (x-only)
|
||||
* @param plaintext Message to encrypt
|
||||
* @param output Buffer for encrypted output (base64 encoded)
|
||||
* @param output_size Size of output buffer
|
||||
* @return NOSTR_SUCCESS on success, error code on failure
|
||||
*/
|
||||
int nostr_nip44_encrypt(const unsigned char* sender_private_key,
|
||||
const unsigned char* recipient_public_key,
|
||||
const char* plaintext,
|
||||
char* output,
|
||||
size_t output_size);
|
||||
|
||||
/**
|
||||
* NIP-44: Encrypt a message with a specific nonce (for testing)
|
||||
*
|
||||
* @param sender_private_key 32-byte sender private key
|
||||
* @param recipient_public_key 32-byte recipient public key (x-only)
|
||||
* @param plaintext Message to encrypt
|
||||
* @param nonce 32-byte nonce
|
||||
* @param output Buffer for encrypted output (base64 encoded)
|
||||
* @param output_size Size of output buffer
|
||||
* @return NOSTR_SUCCESS on success, error code on failure
|
||||
*/
|
||||
int nostr_nip44_encrypt_with_nonce(const unsigned char* sender_private_key,
|
||||
const unsigned char* recipient_public_key,
|
||||
const char* plaintext,
|
||||
const unsigned char* nonce,
|
||||
char* output,
|
||||
size_t output_size);
|
||||
|
||||
/**
|
||||
* NIP-44: Decrypt a message using ECDH + ChaCha20 + HMAC
|
||||
*
|
||||
* @param recipient_private_key 32-byte recipient private key
|
||||
* @param sender_public_key 32-byte sender public key (x-only)
|
||||
* @param encrypted_data Encrypted message (base64 encoded)
|
||||
* @param output Buffer for decrypted plaintext
|
||||
* @param output_size Size of output buffer
|
||||
* @return NOSTR_SUCCESS on success, error code on failure
|
||||
*/
|
||||
int nostr_nip44_decrypt(const unsigned char* recipient_private_key,
|
||||
const unsigned char* sender_public_key,
|
||||
const char* encrypted_data,
|
||||
char* output,
|
||||
size_t output_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NOSTR_NIP044_H
|
||||
Reference in New Issue
Block a user