Package Exports
- hybrid-ecies
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hybrid-ecies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Install
Install nodejs
npm i hybrid-ecies
npm test
Usage
// Typescript
import { ECIES, JWK } from 'hybrid-ecies';
let ecies = new ECIES();
// use ecies to call methods
// javascript
const { ECIES } = require('hybrid-ecies');
let ecies = new ECIES();
// use ecies to call methodsClass: ECIES
Hybrid EC encryption scheme that EC curve secp256k1, and chacha20-poly1305 or aes-256-gcm to encrypt data. The returned data is a packed Buffer with the public key, nonce/iv, tag, and encrypted data.
Hierarchy
- ECIES
Index
Methods
- JWKtoBuffer
- createKeyPair
- decryptAES256
- decryptChaCha20
- encryptAES256
- encryptChaCha20
- getPublicKey
- getSecret
- privateJWK
- publicJWK
Methods
JWKtoBuffer
▸ JWKtoBuffer(jwk: JWK): Buffer
Defined in ecies.ts:126
Return a Buffer from either a public or private JWK.
Parameters:
| Name | Type | Description |
|---|---|---|
jwk |
JWK | public or private JSON Web Key |
Returns: Buffer
Buffer of either public or private key
createKeyPair
▸ createKeyPair(): Buffer
Defined in ecies.ts:24
This creates a EC secp256k1 key pair and returns the private key as a buffer.
Returns: Buffer
EC Private Key as a Buffer
decryptAES256
▸ decryptAES256(privateKey: Buffer, encodedData: Buffer): Buffer
Defined in ecies.ts:165
Takes private EC key of the public key used to encrypt the data and decrypts it.
Parameters:
| Name | Type | Description |
|---|---|---|
privateKey |
Buffer | EC Key used to encrypt the data. |
encodedData |
Buffer | Buffer(Bytes) - ECPubKey(33) iv(12) tag(16) encData(variable) |
Returns: Buffer
Buffer of decrypted data.
decryptChaCha20
▸ decryptChaCha20(privateKey: Buffer, encodedData: Buffer): Buffer
Defined in ecies.ts:221
Takes private EC key of the public key used to encrypt the data and decrypts it.
Parameters:
| Name | Type | Description |
|---|---|---|
privateKey |
Buffer | EC Key used to encrypt the data. |
encodedData |
Buffer | Buffer(Bytes) - ECPubKey(33) nonce(12) tag(16) encData(variable) |
Returns: Buffer
Buffer of decrypted data.
encryptAES256
▸ encryptAES256(publicKey: Buffer, data: Buffer): Buffer
Defined in ecies.ts:143
This takes an EC public key as input, creates an EC pair to encrypt the data. Returns a packed buffer of the EC public key, nonce, tag, and encrypted data.
Parameters:
| Name | Type | Description |
|---|---|---|
publicKey |
Buffer | EC Public Key |
data |
Buffer | Data to encrypt |
Returns: Buffer
Buffer(Bytes) - ECPubKey(33) iv(12) tag(16) encData(variable)
encryptChaCha20
▸ encryptChaCha20(publicKey: Buffer, data: Buffer): Buffer
Defined in ecies.ts:193
This takes an EC public key as input, creates an EC pair to encrypt the data. Returns a packed buffer of the EC public key, nonce, tag, and encrypted data.
Parameters:
| Name | Type | Description |
|---|---|---|
publicKey |
Buffer | EC Public Key |
data |
Buffer | Data to encrypt |
Returns: Buffer
Buffer(Bytes) - ECPubKey(33) nonce(12) tag(16) encData(variable)
getPublicKey
▸ getPublicKey(privateKey: Buffer, compress?: Boolean): Buffer
Defined in ecies.ts:50
Takes EC private key and returns the public key.
Parameters:
| Name | Type | Description |
|---|---|---|
privateKey |
Buffer | EC Private Key |
compress? |
Boolean | If true return only the x value |
Returns: Buffer
publicKey X,Y buffer
getSecret
▸ getSecret(privateKey: Buffer, publicKey: Buffer): Buffer
Defined in ecies.ts:37
This returns the calculated secret from a private and public key.
Parameters:
| Name | Type |
|---|---|
privateKey |
Buffer |
publicKey |
Buffer |
Returns: Buffer
secret
privateJWK
▸ privateJWK(privateKey: Buffer): JWK
Defined in ecies.ts:64
This takes an EC private key and returns the JWK.
Parameters:
| Name | Type | Description |
|---|---|---|
privateKey |
Buffer | EC private key |
Returns: JWK
Json Web Token
publicJWK
▸ publicJWK(publicKey: Buffer): JWK
Defined in ecies.ts:78
This takes an EC public key and returns the JWK.
Parameters:
| Name | Type | Description |
|---|---|---|
publicKey |
Buffer | EC Public Key |
Returns: JWK
Json Web Token
JWK
Interface: JWK
JSON Wek Token
Hierarchy
- JWK
Index
Properties
Properties
crv
• crv: string
Defined in ecies.ts:9
Optional d
• d? : undefined | string
Defined in ecies.ts:8
kid
• kid: string
Defined in ecies.ts:10
kty
• kty: string
Defined in ecies.ts:7
x
• x: string
Defined in ecies.ts:11
Optional y
• y? : undefined | string
Defined in ecies.ts:12