Add examples
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user