Files
libcrypto/examples/pwd-to-signing.test.ts
T
2024-06-06 01:51:04 +02:00

18 lines
524 B
TypeScript

import {expect} from 'bun:test'
import {hkdf, pbkdf, Usage} from '../src/kdf'
import {get_pubkey, sign, verify} from '../src/signature'
const salt = new Uint8Array(32)
const pwd = "test"
const message = new TextEncoder().encode("Yeet")
const kd = await pbkdf(salt, pwd)
const privk = await hkdf(kd, Usage.sign) as Uint8Array
const pubk = await get_pubkey(privk)
const sig = await sign(message, privk)
const verification = await verify(message, pubk, sig)
expect(verification).toBeTrue()
console.log("pwd-to-signing OK")