Add examples

This commit is contained in:
2024-06-06 01:51:04 +02:00
parent 44094a31f1
commit c05f0536e2
5 changed files with 78 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
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")