feat: nip44 v2
This commit is contained in:
@ -3,12 +3,10 @@ import * as utils from "@noble/curves/abstract/utils";
|
||||
import { unwrap } from "@snort/shared";
|
||||
|
||||
import {
|
||||
decodeEncryptionPayload,
|
||||
EventKind,
|
||||
EventSigner,
|
||||
FullRelaySettings,
|
||||
HexKey,
|
||||
MessageEncryptorVersion,
|
||||
NostrEvent,
|
||||
NostrLink,
|
||||
NotSignedNostrEvent,
|
||||
@ -262,23 +260,6 @@ export class EventPublisher {
|
||||
return await this.#sign(eb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic decryption using NIP-23 payload scheme
|
||||
*/
|
||||
async decryptGeneric(content: string, from: string) {
|
||||
const pl = decodeEncryptionPayload(content);
|
||||
switch (pl.v) {
|
||||
case MessageEncryptorVersion.Nip4: {
|
||||
const nip4Payload = `${base64.encode(pl.ciphertext)}?iv=${base64.encode(pl.nonce)}`;
|
||||
return await this.#signer.nip4Decrypt(nip4Payload, from);
|
||||
}
|
||||
case MessageEncryptorVersion.XChaCha20: {
|
||||
return await this.#signer.nip44Decrypt(content, from);
|
||||
}
|
||||
}
|
||||
throw new Error("Not supported version");
|
||||
}
|
||||
|
||||
async decryptDm(note: NostrEvent) {
|
||||
if (note.kind === EventKind.SealedRumor) {
|
||||
const unseal = await this.unsealRumor(note);
|
||||
|
Reference in New Issue
Block a user