npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hybrid-ecies

v1.3.0

Published

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.

Downloads

16

Readme

hybrid-eciesGlobals

hybrid-ecies

Build Status

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 methods

hybrid-eciesGlobals"ecies"ECIES

Class: ECIES

Hybrid EC encryption scheme that takes an 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

Methods

JWKtoBuffer

JWKtoBuffer(jwk: JWK): Buffer

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

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

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

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

This takes an EC public key as input, creates an unique EC pair to encrypt the data. Returns a packed buffer of the EC public key, nonce, tag, and encrypted data. Optional to supply Private Key

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)

encryptAES256(publicKey: Buffer, privateKey: Buffer, data: Buffer): Buffer

Parameters:

Name | Type | ------ | ------ | publicKey | Buffer | privateKey | Buffer | data | Buffer |

Returns: Buffer


encryptChaCha20

encryptChaCha20(publicKey: Buffer, data: any): Buffer

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. Optional to supply Private Key

Parameters:

Name | Type | Description | ------ | ------ | ------ | publicKey | Buffer | EC Public Key | data | any | Data to encrypt |

Returns: Buffer

Buffer(Bytes) - ECPubKey(33) nonce(12) tag(16) encData(variable)

encryptChaCha20(publicKey: Buffer, privateKey: Buffer, data: any): Buffer

Parameters:

Name | Type | ------ | ------ | publicKey | Buffer | privateKey | Buffer | data | any |

Returns: Buffer


getDER

getDER(ecKey: Buffer, type: "Private" | "Public"): Buffer

Parameters:

Name | Type | ------ | ------ | ecKey | Buffer | type | "Private" | "Public" |

Returns: Buffer


getPEM

getPEM(ecKey: Buffer, encoding: "RAW" | "DER", type: "Private" | "Public"): string

Parameters:

Name | Type | ------ | ------ | ecKey | Buffer | encoding | "RAW" | "DER" | type | "Private" | "Public" |

Returns: string


getPublicKey

getPublicKey(privateKey: Buffer, compress?: Boolean): Buffer

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

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

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

This takes an EC public key and returns the JWK.

Parameters:

Name | Type | Description | ------ | ------ | ------ | publicKey | Buffer | EC Public Key |

Returns: JWK

Json Web Token

hybrid-eciesGlobals

hybrid-ecies

Index

Modules

hybrid-eciesGlobals"ecies"JWK

Interface: JWK

JSON Wek Token

Hierarchy

  • JWK

Index

Properties

Properties

crv

crv: string


Optional d

d? : undefined | string


kid

kid: string


kty

kty: string


x

x: string


Optional y

y? : undefined | string

hybrid-eciesGlobals"ecies"

Module: "ecies"

Index

Classes

Interfaces