(publicKey: PublicKey, privateKey: PrivateKey)
| 2 | import type { PublicKey } from './public-key'; |
| 3 | |
| 4 | export function wrapKeyPair(publicKey: PublicKey, privateKey: PrivateKey) { |
| 5 | return new (class KeyPair { |
| 6 | get publicKey() { |
| 7 | return publicKey; |
| 8 | } |
| 9 | get privateKey() { |
| 10 | return privateKey; |
| 11 | } |
| 12 | |
| 13 | encrypt( |
| 14 | plaintext: Uint8Array, |
| 15 | recipientsPublicKey: PublicKey, |
| 16 | params?: { padding?: boolean }, |
| 17 | ): Uint8Array { |
| 18 | return privateKey.encrypt( |
| 19 | plaintext, |
| 20 | recipientsPublicKey, |
| 21 | publicKey, |
| 22 | params, |
| 23 | ); |
| 24 | } |
| 25 | decrypt( |
| 26 | ciphertext: Uint8Array, |
| 27 | params?: { padding?: boolean }, |
| 28 | ): Uint8Array { |
| 29 | return privateKey.decrypt(ciphertext, params); |
| 30 | } |
| 31 | })(); |
| 32 | } |
| 33 | |
| 34 | export type KeyPair = ReturnType<typeof wrapKeyPair>; |
no outgoing calls
no test coverage detected