Skip to content

Cardinal-Cryptography/ecies-encryption-lib

Repository files navigation

ECIES Encryption Library

This repo contains ECIES encryption using secp256k1 + AES-GCM

🔐 Crypto Stack

  • EC key exchange via secp256k1 (ECDH)
  • AES-256-GCM for authenticated encryption
  • HKDF for key derivation

📂 Project Structure

  • rust/
    • lib/ — Full keygen + ECIES encrypt/decrypt in Rust
    • cli/clap-based CLI
  • ts/
    • lib/ — TypeScript ECIES using @noble/secp256k1 + WebCrypto
    • cli/commander-based CLI

Integration test

We include an integration test for JS <--> Rust compatibility.

./ecies-integration-test.sh

🚀 Usage

git clone https://github.com/Cardinal-Cryptography/ecies-encryption-lib.git
cd ecies-encryption-lib

Run the rust example

cargo build
./target/debug/ecies-encryption-cli example

Or run subcommands like:

./target/debug/ecies-encryption-cli generate-keypair
./target/debug/ecies-encryption-cli encrypt --pubkey <hex> --message "hello"
./target/debug/ecies-encryption-cli decrypt --privkey <hex> --ciphertext <hex>

Run the TypeScript example

pnpm install
pnpm build

Then

pnpm tsx ./ts/cli/index.ts example
pnpm tsx ./ts/cli/index.ts generate-keypair
pnpm tsx ./ts/cli/index.ts encrypt --pubkey <hex> --message "hello"
pnpm tsx ./ts/cli/index.ts decrypt --privkey <hex> --ciphertext <hex>

WARNING

Using encrypt or decrypt directly does not hide plaintext length which might be a problem in some cases. Use encrypt-padded and decrypt-padded to change the original plaintext length (add padding carefully).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •