Elliptic Curve Integrated Encryption Scheme for secp256k1
npm install eciesjs12b




Elliptic Curve Integrated Encryption Scheme for secp256k1 in TypeScript.
This is the JavaScript/TypeScript version of eciespy with a built-in class-like secp256k1 API, you may go there for detailed documentation and learn the mechanism under the hood.
If you want a WASM version to run directly in browsers, check ecies-wasm.
``bash`
npm install eciesjs
`typescript`
> import { encrypt, decrypt, PrivateKey } from 'eciesjs'
> const k1 = new PrivateKey()
> const data = Buffer.from('this is a test')
> decrypt(k1.toHex(), encrypt(k1.publicKey.toHex(), data)).toString()
'this is a test'
Parameters:
- receiverRawPub - Receiver's secp256k1 public key, hex string or buffer
- msg - Data to encrypt
Returns: Buffer
Parameters:
- receiverRawPrv - Receiver's secp256k1 private key, hex string or buffer
- msg - Data to decrypt
Returns: Buffer
- Methods
`typescript`
static fromHex(hex: string): PrivateKey;
constructor(secret?: Buffer);
toHex(): string;
encapsulate(pub: PublicKey): Buffer;
multiply(pub: PublicKey): Buffer;
equals(other: PrivateKey): boolean;
- Properties
`typescript`
readonly secret: Buffer;
readonly publicKey: PublicKey;
- Methods
`typescript`
static fromHex(hex: string): PublicKey;
constructor(buffer: Buffer);
toHex(compressed?: boolean): string;
decapsulate(priv: PrivateKey): Buffer;
equals(other: PublicKey): boolean;
- Properties
`typescript`
readonly uncompressed: Buffer;
readonly compressed: Buffer;
- Bump dependencies
- Update documentation
- API change: encrypt/decrypt now can take both hex string and Buffer
- API change: use HKDF-sha256 to derive shared keys instead of sha256`
- Bump dependencies
- Update documentation
- Bump dependencies
- Update documentation
- First beta version release