0.1.1 • Published 4 years ago

ec_hydrid_ecies v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Build Status

Class: ECIES

Hybred EC encrytion scheme that EC curve secp256k1, and chacha20-poly1305 to encrypt data. The returned data is a packed Buffer with the public key, nonce, tag, and encrypted data.

Hierarchy

  • ECIES

Index

Methods

Methods

JWKtoBuffer

JWKtoBuffer(jwk: JWK): Buffer

Defined in ecies.ts:128

Return a Buffer from either a public or private JWK.

Parameters:

NameTypeDescription
jwkJWKpublic 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


decryptChaCha20

decryptChaCha20(privateKey: Buffer, encodedData: Buffer): Buffer

Defined in ecies.ts:174

Takes private EC key of the public key used to encrypt the data and decrypts it.

Parameters:

NameTypeDescription
privateKeyBufferEC Key used to encrypt the data.
encodedDataBufferBuffer(Bytes) - ECPubKey(32) nonce(12) tag(16) encData(variable)

Returns: Buffer

Buffer of decrypted data.


encryptChaCha20

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

Defined in ecies.ts:146

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:

NameTypeDescription
publicKeyBufferEC Public Key
dataBufferData to encrypt

Returns: Buffer

Buffer(Bytes) - ECPubKey(32) 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:

NameTypeDescription
privateKeyBufferEC Private Key
compress?BooleanIf 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:

NameType
privateKeyBuffer
publicKeyBuffer

Returns: Buffer

secret


privateJWK

privateJWK(privateKey: Buffer): JWK

Defined in ecies.ts:66

This takes an EC private key and returns the JWK.

Parameters:

NameTypeDescription
privateKeyBufferEC private key

Returns: JWK

Json Web Token


publicJWK

publicJWK(publicKey: Buffer): JWK

Defined in ecies.ts:80

This takes an EC public key and returns the JWK.

Parameters:

NameTypeDescription
publicKeyBufferEC Public Key

Returns: JWK

Json Web Token