signature : Use SubtleCrypto
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
2024-06-06 23:33:19 +02:00
parent 1749459be7
commit 5ee8fc00d0
5 changed files with 117 additions and 23 deletions
+3 -3
View File
@@ -1,15 +1,15 @@
import {expect} from 'bun:test'
import {hkdf, pbkdf, Usage} from '../src/kdf'
import {get_pubkey, sign, verify} from '../src/signature'
import {derive_keypair, 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 source = await hkdf(kd, Usage.sign) as Uint8Array
const [privk, pubk] = await derive_keypair(source)
const sig = await sign(message, privk)
const verification = await verify(message, pubk, sig)