Files
libcrypto/examples/ecdh-wraps-key.test.ts
T
2024-06-06 01:51:04 +02:00

15 lines
464 B
TypeScript

import {expect} from 'bun:test'
import {PrivateWrap, SecretBox} from '../index'
const k_wraps = await PrivateWrap.gen_keypair()
const k_wrapped = await SecretBox.gen_key()
const cipher = await PrivateWrap.encrypt(k_wrapped, k_wraps.publicKey)
const box = await cipher.toString()
const unbox = await PrivateWrap.fromString(box)
const plain = await unbox.decrypt(k_wraps.privateKey) as CryptoKey
expect(plain).toEqual(k_wrapped)
console.log("ecdh-wraps-key OK")