This repo contains ECIES encryption using secp256k1 + AES-GCM
- EC key exchange via
secp256k1(ECDH) - AES-256-GCM for authenticated encryption
- HKDF for key derivation
rust/lib/— Full keygen + ECIES encrypt/decrypt in Rustcli/—clap-based CLI
ts/lib/— TypeScript ECIES using@noble/secp256k1+ WebCryptocli/—commander-based CLI
We include an integration test for JS <--> Rust compatibility.
./ecies-integration-test.sh
git clone https://github.com/Cardinal-Cryptography/ecies-encryption-lib.git
cd ecies-encryption-libRun the rust example
cargo build
./target/debug/ecies-encryption-cli exampleOr 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 buildThen
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>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).