(
plaintext: Uint8Array,
recipientsPublicKey: PublicKey,
sendersPublicKey: PublicKey,
params?: { padding?: boolean },
)
| 10 | } |
| 11 | |
| 12 | encrypt( |
| 13 | plaintext: Uint8Array, |
| 14 | recipientsPublicKey: PublicKey, |
| 15 | sendersPublicKey: PublicKey, |
| 16 | params?: { padding?: boolean }, |
| 17 | ): Uint8Array { |
| 18 | if (params?.padding) { |
| 19 | plaintext = sodium.pad(plaintext, 8); |
| 20 | } |
| 21 | |
| 22 | const nonce = sodium.randombytes_buf(sodium.crypto_box_NONCEBYTES); |
| 23 | |
| 24 | const ciphertext = sodium.crypto_box_easy( |
| 25 | plaintext, |
| 26 | nonce, |
| 27 | recipientsPublicKey.value, |
| 28 | value, |
| 29 | ); |
| 30 | |
| 31 | return concatUint8Arrays(sendersPublicKey.value, nonce, ciphertext); |
| 32 | } |
| 33 | decrypt(message: Uint8Array, params?: { padding?: boolean }): Uint8Array { |
| 34 | const sendersPublicKey = message.slice( |
| 35 | 0, |
nothing calls this directly
no test coverage detected