Comparing version 0.4.12 to 0.4.13
/** | ||
* Encrypts a message. | ||
* Encrypts data with a receiver's public key. | ||
* @description From version 0.5.0, `Uint8Array` will be returned instead of `Buffer`. | ||
@@ -7,8 +7,8 @@ * To keep the same behavior, use `Buffer.from(encrypt(...))`. | ||
* @param receiverRawPK - Raw public key of the receiver, either as a hex string or a Uint8Array. | ||
* @param msg - Message to encrypt. | ||
* @param data - Data to encrypt. | ||
* @returns Encrypted payload, format: `public key || encrypted`. | ||
*/ | ||
export declare function encrypt(receiverRawPK: string | Uint8Array, msg: Uint8Array): Buffer; | ||
export declare function encrypt(receiverRawPK: string | Uint8Array, data: Uint8Array): Buffer; | ||
/** | ||
* Decrypts a message. | ||
* Decrypts data with a receiver's private key. | ||
* @description From version 0.5.0, `Uint8Array` will be returned instead of `Buffer`. | ||
@@ -18,6 +18,6 @@ * To keep the same behavior, use `Buffer.from(decrypt(...))`. | ||
* @param receiverRawSK - Raw private key of the receiver, either as a hex string or a Uint8Array. | ||
* @param msg - Message to decrypt. | ||
* @param data - Data to decrypt. | ||
* @returns Decrypted plain text. | ||
*/ | ||
export declare function decrypt(receiverRawSK: string | Uint8Array, msg: Uint8Array): Buffer; | ||
export declare function decrypt(receiverRawSK: string | Uint8Array, data: Uint8Array): Buffer; | ||
export { ECIES_CONFIG } from "./config"; | ||
@@ -24,0 +24,0 @@ export { PrivateKey, PublicKey } from "./keys"; |
@@ -11,3 +11,3 @@ "use strict"; | ||
/** | ||
* Encrypts a message. | ||
* Encrypts data with a receiver's public key. | ||
* @description From version 0.5.0, `Uint8Array` will be returned instead of `Buffer`. | ||
@@ -17,6 +17,9 @@ * To keep the same behavior, use `Buffer.from(encrypt(...))`. | ||
* @param receiverRawPK - Raw public key of the receiver, either as a hex string or a Uint8Array. | ||
* @param msg - Message to encrypt. | ||
* @param data - Data to encrypt. | ||
* @returns Encrypted payload, format: `public key || encrypted`. | ||
*/ | ||
function encrypt(receiverRawPK, msg) { | ||
function encrypt(receiverRawPK, data) { | ||
return Buffer.from(_encrypt(receiverRawPK, data)); | ||
} | ||
function _encrypt(receiverRawPK, data) { | ||
var ephemeralSK = new keys_1.PrivateKey(); | ||
@@ -28,7 +31,7 @@ var receiverPK = receiverRawPK instanceof Uint8Array | ||
var ephemeralPK = ephemeralSK.publicKey.toBytes((0, config_1.isEphemeralKeyCompressed)()); | ||
var encrypted = (0, utils_2.symEncrypt)(sharedKey, msg); | ||
return Buffer.from((0, utils_1.concatBytes)(ephemeralPK, encrypted)); | ||
var encrypted = (0, utils_2.symEncrypt)(sharedKey, data); | ||
return (0, utils_1.concatBytes)(ephemeralPK, encrypted); | ||
} | ||
/** | ||
* Decrypts a message. | ||
* Decrypts data with a receiver's private key. | ||
* @description From version 0.5.0, `Uint8Array` will be returned instead of `Buffer`. | ||
@@ -38,6 +41,9 @@ * To keep the same behavior, use `Buffer.from(decrypt(...))`. | ||
* @param receiverRawSK - Raw private key of the receiver, either as a hex string or a Uint8Array. | ||
* @param msg - Message to decrypt. | ||
* @param data - Data to decrypt. | ||
* @returns Decrypted plain text. | ||
*/ | ||
function decrypt(receiverRawSK, msg) { | ||
function decrypt(receiverRawSK, data) { | ||
return Buffer.from(_decrypt(receiverRawSK, data)); | ||
} | ||
function _decrypt(receiverRawSK, data) { | ||
var receiverSK = receiverRawSK instanceof Uint8Array | ||
@@ -47,6 +53,6 @@ ? new keys_1.PrivateKey(receiverRawSK) | ||
var keySize = (0, config_1.ephemeralKeySize)(); | ||
var ephemeralPK = new keys_1.PublicKey(msg.subarray(0, keySize)); | ||
var encrypted = msg.subarray(keySize); | ||
var ephemeralPK = new keys_1.PublicKey(data.subarray(0, keySize)); | ||
var encrypted = data.subarray(keySize); | ||
var sharedKey = ephemeralPK.decapsulate(receiverSK, (0, config_1.isHkdfKeyCompressed)()); | ||
return Buffer.from((0, utils_2.symDecrypt)(sharedKey, encrypted)); | ||
return (0, utils_2.symDecrypt)(sharedKey, encrypted); | ||
} | ||
@@ -53,0 +59,0 @@ var config_2 = require("./config"); |
@@ -28,3 +28,3 @@ "use strict"; | ||
get: function () { | ||
return Buffer.from(this._uncompressed); // TODO: Uint8Array | ||
return Buffer.from(this._uncompressed); // TODO: delete | ||
}, | ||
@@ -37,3 +37,3 @@ enumerable: false, | ||
get: function () { | ||
return Buffer.from(this.data); // TODO: Uint8Array | ||
return Buffer.from(this.data); // TODO: delete | ||
}, | ||
@@ -40,0 +40,0 @@ enumerable: false, |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"engines": { | ||
@@ -60,3 +60,3 @@ "node": ">=16", | ||
"dependencies": { | ||
"@ecies/ciphers": "^0.2.1", | ||
"@ecies/ciphers": "^0.2.2", | ||
"@noble/ciphers": "^1.0.0", | ||
@@ -67,9 +67,9 @@ "@noble/curves": "^1.6.0", | ||
"devDependencies": { | ||
"@types/node": "^22.9.0", | ||
"@vitest/coverage-v8": "^2.1.4", | ||
"typescript": "^5.6.3", | ||
"undici": "^6.20.1", | ||
"vitest": "^2.1.4" | ||
"@types/node": "^22.10.2", | ||
"@vitest/coverage-v8": "^2.1.8", | ||
"typescript": "^5.7.2", | ||
"undici": "^7.1.1", | ||
"vitest": "^2.1.8" | ||
}, | ||
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee" | ||
"packageManager": "pnpm@9.14.4+sha512.c8180b3fbe4e4bca02c94234717896b5529740a6cbadf19fa78254270403ea2f27d4e1d46a08a0f56c89b63dc8ebfd3ee53326da720273794e6200fcf0d184ab" | ||
} |
@@ -5,3 +5,5 @@ # eciesjs | ||
[![License](https://img.shields.io/github/license/ecies/js.svg)](https://github.com/ecies/js) | ||
[![Npm Package](https://img.shields.io/npm/v/eciesjs.svg)](https://www.npmjs.com/package/eciesjs) | ||
[![NPM Package](https://img.shields.io/npm/v/eciesjs.svg)](https://www.npmjs.com/package/eciesjs) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/eciesjs)](https://npm-stat.link/eciesjs) | ||
[![Bundle size](https://badgen.net/bundlephobia/minzip/eciesjs)](https://bundlephobia.com/package/eciesjs@latest) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/ecies/js/ci.yml)](https://github.com/ecies/js/actions) | ||
@@ -56,3 +58,3 @@ [![Codecov](https://img.shields.io/codecov/c/github/ecies/js.svg)](https://codecov.io/gh/ecies/js) | ||
- `node:crypto`'s `xchacha20` does not work on bun (pure JS implementation is used instead) | ||
- `node:crypto`'s `chacha20-poly1305` does not work on bun (pure JS implementation is used instead) | ||
- `aes-256-gcm` only works with 12 bytes nonce on deno (deno is not handling package exports correctly) | ||
@@ -66,3 +68,3 @@ | ||
### `encrypt(receiverRawPK: string | Uint8Array, msg: Uint8Array): Buffer` | ||
### `encrypt(receiverRawPK: string | Uint8Array, data: Uint8Array): Buffer` | ||
@@ -72,7 +74,7 @@ Parameters: | ||
- **receiverRawPK** - Receiver's public key, hex string or Uint8Array | ||
- **msg** - Data to encrypt | ||
- **data** - Data to encrypt | ||
Returns: **Buffer** | ||
### `decrypt(receiverRawSK: string | Uint8Array, msg: Uint8Array): Buffer` | ||
### `decrypt(receiverRawSK: string | Uint8Array, data: Uint8Array): Buffer` | ||
@@ -82,3 +84,3 @@ Parameters: | ||
- **receiverRawSK** - Receiver's private key, hex string or Uint8Array | ||
- **msg** - Data to decrypt | ||
- **data** - Data to decrypt | ||
@@ -85,0 +87,0 @@ Returns: **Buffer** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37351
575
194
Updated@ecies/ciphers@^0.2.2