JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25860F
  • License MIT

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.

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

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