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

15 lines
452 B
TypeScript

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