signature : Add test, minor fix

This commit is contained in:
2024-06-06 13:13:50 +02:00
parent 544a2a55a5
commit 9885f4c4e6
2 changed files with 61 additions and 1 deletions
+6 -1
View File
@@ -7,8 +7,13 @@ export async function gen_privkey() : Promise<Uint8Array> {
log.trace("generate keypair")
return ed.utils.randomPrivateKey()
}
export async function gen_keypair() : Promise<[Uint8Array, Uint8Array]> {
const privkey = await gen_privkey()
const pubkey = await get_pubkey(privkey)
return [privkey, pubkey]
}
export async function get_pubkey(privkey: Uint8Array) : Promise<Uint8Array> {
log.trace("derive pubky")
log.trace("derive pubkey")
return ed.getPublicKeyAsync(privkey)
}
export async function sign(message: Uint8Array, privkey: Uint8Array) : Promise<Uint8Array> {