Skip to content

Conversation

@JanKuczma
Copy link
Collaborator

@JanKuczma JanKuczma commented Aug 12, 2025

This pull request updates the ECIES encryption library to version 0.2.0 and introduces significant improvements to the TypeScript and Rust implementations, focusing on clearer APIs, better type safety, and improved interoperability between the two languages. The changes include refactoring encryption/decryption functions to consistently use byte arrays, adding new utility functions for key conversion and hex handling, and enhancing documentation and error handling. Integration tests and CLI commands are also updated to reflect these improvements.

API and Type Safety Improvements

  • Refactored all TypeScript encryption and decryption functions (encrypt, decrypt, encryptPadded, etc.) to accept and return Uint8Array instead of strings, improving type safety and clarity. Added utility functions like toHexString, fromHexString, and ensureBytes for robust hex conversion and byte handling.
  • Added publicKeyFromPrivateKey to TypeScript for deriving a public key from a private key, and documented all major functions for clarity.

Rust Library Enhancements

  • Added a method to derive a public key from a private key (PrivKey::public_key) and improved documentation for all major functions in rust/lib/src/lib.rs.
  • Refactored encryption and decryption functions to use explicit byte array parameters and updated padding logic for consistency with the TypeScript implementation.

Version Bumps

  • Bumped the version to 0.2.0 in package.json, ts/lib/package.json, and rust/lib/Cargo.toml to reflect these breaking and additive changes.

@Marcin-Radecki Marcin-Radecki requested a review from Copilot August 12, 2025 09:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the ECIES encryption library to version 0.1.7, introducing breaking API changes that improve type safety by switching from string-based to byte array-based function signatures. The changes standardize all encryption/decryption functions to work with Uint8Array inputs and outputs, while adding utility functions for hex conversion and key derivation.

  • Refactored all TypeScript encryption/decryption functions to use Uint8Array instead of strings
  • Added utility functions for hex conversion (toHexString, fromHexString, ensureBytes) and key derivation (publicKeyFromPrivateKey)
  • Updated CLI and integration tests to handle the new byte array-based API

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ts/lib/src/index.ts Core library refactoring with new byte-based APIs, utility functions, and comprehensive documentation
ts/cli/index.ts CLI updates to work with new byte array APIs, adding encoding/decoding steps
tests/integration-test.sh Added debug output for integration test troubleshooting
package.json, ts/lib/package.json, rust/lib/Cargo.toml Version bumps to 0.1.7
rust/lib/src/lib.rs Added public key derivation method and improved function documentation
Comments suppressed due to low confidence (1)

Copy link
Contributor

@Marcin-Radecki Marcin-Radecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@JanKuczma JanKuczma merged commit 151527f into main Aug 12, 2025
1 check passed
@JanKuczma JanKuczma deleted the rm-encoding branch August 12, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants