mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
Add support for nip44
This commit is contained in:
19
nip44.test.ts
Normal file
19
nip44.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import crypto from 'node:crypto'
|
||||
|
||||
import {encrypt, decrypt} from './nip44.ts'
|
||||
import {getPublicKey, generatePrivateKey} from './keys.ts'
|
||||
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line no-undef
|
||||
globalThis.crypto = crypto
|
||||
|
||||
test('encrypt and decrypt message', async () => {
|
||||
let sk1 = generatePrivateKey()
|
||||
let sk2 = generatePrivateKey()
|
||||
let pk1 = getPublicKey(sk1)
|
||||
let pk2 = getPublicKey(sk2)
|
||||
|
||||
expect(await decrypt(sk2, pk1, await encrypt(sk1, pk2, 'hello'))).toEqual(
|
||||
'hello'
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user