askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
49 lines (48 loc) • 1.49 kB
TypeScript
/**
* Cryptographic utilities for NIP-174
*/
import { Event } from 'nostr-tools';
/**
* Generates a random key pair
*
* @returns Object containing private key and public key
*/
export declare function generateRandomKeyPair(): {
privateKey: Uint8Array<ArrayBufferLike>;
publicKey: string;
};
/**
* Encrypts data using NIP-44
*
* @param data - The data to encrypt
* @param recipientPubkey - Recipient's public key
* @param senderPrivkey - Sender's private key
* @returns Encrypted data as string
*/
export declare function encrypt(data: string, recipientPubkey: string, senderPrivkey: Uint8Array): string;
/**
* Decrypts data using NIP-44
*
* @param encryptedData - The encrypted data
* @param senderPubkey - Sender's public key
* @param recipientPrivkey - Recipient's private key
* @returns Decrypted data as string
*/
export declare function decrypt(encryptedData: string, senderPubkey: string, recipientPrivkey: Uint8Array): string;
/**
* Creates and signs a Nostr event
*
* @param kind - Event kind
* @param content - Event content
* @param tags - Event tags
* @param privkey - Private key to sign the event
* @returns Signed event
*/
export declare function createEvent(kind: number, content: string, tags: string[][], privkey: Uint8Array): Event;
/**
* Validates a Nostr event
*
* @param event - The event to validate
* @returns True if the event is valid, false otherwise
*/
export declare function validateNostrEvent(event: Event): boolean;