auth: add encryptSecretKey & decryptSecretKey functions

This commit is contained in:
Alex Gleason
2024-10-02 17:56:30 -05:00
parent 70f56af281
commit e73a8d71dc
3 changed files with 57 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
import { generateToken, getTokenHash } from '@/utils/auth.ts';
import { generateSecretKey } from 'nostr-tools';
import { decryptSecretKey, encryptSecretKey, generateToken, getTokenHash } from '@/utils/auth.ts';
Deno.bench('generateToken', async () => {
await generateToken();
@@ -9,3 +11,18 @@ Deno.bench('getTokenHash', async (b) => {
b.start();
await getTokenHash(token);
});
Deno.bench('encryptSecretKey', async (b) => {
const sk = generateSecretKey();
const decrypted = generateSecretKey();
b.start();
await encryptSecretKey(sk, decrypted);
});
Deno.bench('decryptSecretKey', async (b) => {
const sk = generateSecretKey();
const decrypted = generateSecretKey();
const encrypted = await encryptSecretKey(sk, decrypted);
b.start();
await decryptSecretKey(sk, encrypted);
});