From 25a8275c910b9f89ef435be7c74e3a75faec53e6 Mon Sep 17 00:00:00 2001 From: Pascal Perrenoud Date: Tue, 14 May 2024 15:24:17 +0200 Subject: [PATCH] asym box : Fix condition on T --- src/boxes/asymmetric.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/boxes/asymmetric.ts b/src/boxes/asymmetric.ts index d0a03fa..146610e 100644 --- a/src/boxes/asymmetric.ts +++ b/src/boxes/asymmetric.ts @@ -6,7 +6,7 @@ export type PrivKey = CryptoKey const algorithm: RsaOaepParams = {name: "RSA-OAEP"} -export class PrivateBox { +export class PrivateBox { readonly cipher: Uint8Array; readonly _phantom!: T; @@ -29,7 +29,7 @@ export class PrivateBox { return [keys.privateKey, keys.publicKey] } - public static async encrypt(key: PubKey, data: T): Promise>> { + public static async encrypt(key: PubKey, data: Uint8Array): Promise>> { try { const cipher = await window.crypto.subtle.encrypt(algorithm, key, data) return Result.ok(new PrivateBox(new Uint8Array(cipher))) @@ -49,7 +49,7 @@ export class PrivateBox { public toString() : string { return misc.a2b64(new Uint8Array(this.cipher)) } - public static fromString(data: string) : Result> { + public static fromString(data: string) : Result> { const res = misc.b642a(data) if (res.error()) return Result.error([]) return Result.ok(new PrivateBox(res.unwrap()))