Add KeyPair type for asym primitives

This commit is contained in:
2024-05-14 22:23:58 +02:00
parent f30516bd2c
commit 3d2fe5f517
3 changed files with 14 additions and 12 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ import * as misc from 'misc'
export type PubKey = CryptoKey
export type PrivKey = CryptoKey
export type KeyPair = [PrivKey, PubKey]
const algorithm: RsaOaepParams = {name: "RSA-OAEP"}
@@ -14,7 +15,7 @@ export class PrivateBox<T> {
this.cipher = cipher
}
public static async gen_keypair(extractable: boolean = false): Promise<[PrivKey, PubKey]> {
public static async gen_keypair(extractable: boolean = false): Promise<KeyPair> {
const keys = await window.crypto.subtle.generateKey(
{
name: "RSA-OAEP",
+2 -1
View File
@@ -2,6 +2,7 @@ import {Result} from 'result'
export type PrivKey = CryptoKey
export type PubKey = CryptoKey
export type KeyPair = [PrivKey, PubKey]
const algorithm: EcdsaParams = {
name: "ECDSA",
@@ -13,7 +14,7 @@ const algorithm: EcdsaParams = {
* @param extractable if the keys must be extractable or not
* @return [privkey, pubkey] keys
*/
export async function gen_keypair(extractable: boolean = false) : Promise<[PrivKey, PubKey]> {
export async function gen_keypair(extractable: boolean = false) : Promise<KeyPair> {
let key = await window.crypto.subtle.generateKey(
{
name: "ECDSA",