feat: POW miner

This commit is contained in:
2023-08-18 00:35:48 +01:00
parent 667518a2df
commit 2a851c442d
14 changed files with 209 additions and 40 deletions

View File

@ -23,10 +23,10 @@ export class Nip4WebCryptoEncryptor implements MessageEncryptor {
return {
ciphertext: new Uint8Array(result),
nonce: iv,
v: MessageEncryptorVersion.Nip4
v: MessageEncryptorVersion.Nip4,
} as MessageEncryptorPayload;
}
async decryptData(payload: MessageEncryptorPayload, sharedSecet: Uint8Array) {
const key = await this.#importKey(sharedSecet);
const result = await window.crypto.subtle.decrypt(
@ -35,7 +35,7 @@ export class Nip4WebCryptoEncryptor implements MessageEncryptor {
iv: payload.nonce,
},
key,
payload.ciphertext
payload.ciphertext,
);
return new TextDecoder().decode(result);
}