develop herolib crypto #34

Merged
thabeta merged 21 commits from develop-herolib-crypto into develop 2025-12-31 17:26:47 +00:00
Member

PR Description

Consolidate Ed25519 Keys and HTTP Signatures into Unified Crypto Package

This PR consolidates the herolib-keys and herolib-httpsig packages into a single herolib-crypto package with feature flags for selective compilation.


📦 Changes

Package Consolidation

  • Removed: packages/keys/ and packages/httpsig/ standalone packages
  • Created: packages/crypto/ unified package
  • Result: 2 packages → 1 package

Module Structure

packages/crypto/
├── src/
│   ├── keys/           # Ed25519 cryptography
│   ├── httpsig/        # HTTP Message Signatures (RFC 9421/9530)
│   └── rhai/           # Unified Rhai bindings
├── rhaiexamples/       # 6 Rhai examples (4 keys + 2 httpsig)
└── rhai_tests/         # 2 Rhai test suites

Feature Flags

default = ["keys", "httpsig"]
keys = ["dep:ed25519-dalek", "dep:rand", "dep:sha2", "dep:base64", "dep:hex"]
httpsig = ["keys", "dep:http"]
rhai = ["dep:rhai"]
full = ["keys", "httpsig", "rhai"]

Users can now compile only what they need:

  • Keys only: default-features = false, features = ["keys"]
  • Full package: features = ["full"]

Integration Updates

  • herodo: Updated to use herolib-crypto with features = ["full"]
  • rhai aggregator: Updated to use herolib-crypto
  • Rhai registration: Single register_crypto_module() function

Verification

Compilation

  • Keys only: Compiles successfully
  • HTTP signatures: Compiles successfully
  • Full features: Compiles successfully

Tests

  • 54 unit tests passing
  • 16 doc tests passing
  • 6 Rhai examples working
  • 2 Rhai test suites passing (13 tests total)

Integration

  • herodo compiles and runs successfully
  • All Rhai examples execute correctly

# PR Description ## Consolidate Ed25519 Keys and HTTP Signatures into Unified Crypto Package This PR consolidates the `herolib-keys` and `herolib-httpsig` packages into a single `herolib-crypto` package with feature flags for selective compilation. --- ## 📦 Changes ### Package Consolidation - **Removed**: `packages/keys/` and `packages/httpsig/` standalone packages - **Created**: `packages/crypto/` unified package - **Result**: 2 packages → 1 package ### Module Structure ``` packages/crypto/ ├── src/ │ ├── keys/ # Ed25519 cryptography │ ├── httpsig/ # HTTP Message Signatures (RFC 9421/9530) │ └── rhai/ # Unified Rhai bindings ├── rhaiexamples/ # 6 Rhai examples (4 keys + 2 httpsig) └── rhai_tests/ # 2 Rhai test suites ``` ### Feature Flags ```toml default = ["keys", "httpsig"] keys = ["dep:ed25519-dalek", "dep:rand", "dep:sha2", "dep:base64", "dep:hex"] httpsig = ["keys", "dep:http"] rhai = ["dep:rhai"] full = ["keys", "httpsig", "rhai"] ``` Users can now compile only what they need: - Keys only: `default-features = false, features = ["keys"]` - Full package: `features = ["full"]` ### Integration Updates - **herodo**: Updated to use `herolib-crypto` with `features = ["full"]` - **rhai aggregator**: Updated to use `herolib-crypto` - **Rhai registration**: Single [register_crypto_module()](cci:1://file:///Users/abouelsaad/Projects/herolib_rust/packages/crypto/src/rhai/mod.rs:19:0-40:1) function --- ## ✅ Verification ### Compilation - ✅ Keys only: Compiles successfully - ✅ HTTP signatures: Compiles successfully - ✅ Full features: Compiles successfully ### Tests - ✅ **54 unit tests** passing - ✅ **16 doc tests** passing - ✅ **6 Rhai examples** working - ✅ **2 Rhai test suites** passing (13 tests total) ### Integration - ✅ herodo compiles and runs successfully - ✅ All Rhai examples execute correctly ---
# Conflicts:
#	packages/herodo/src/main.rs
- Create herolib-crypto as a unified wrapper package
- Re-export herolib-keys and herolib-httpsig under crypto namespace
- Provide unified Rhai registration via register_crypto_module()
- Update herodo to use crypto package instead of separate keys/httpsig
- Update rhai aggregator to use crypto package
- Add comprehensive README for crypto package
- All tests passing (2 doc tests)

Benefits:
- Single entry point for cryptographic operations
- Simplified dependency management
- Unified Rhai integration
- Maintains clean module boundaries via re-exports
Merge herolib-keys and herolib-httpsig into a single herolib-crypto package with feature flags for selective compilation.

Changes:
- Move all source code from keys and httpsig into crypto package
- Add feature flags: keys (default), httpsig (default), rhai, full
- Update herodo to use herolib-crypto with full features
- Update rhai aggregator to use herolib-crypto
- Remove standalone packages/keys and packages/httpsig directories
- Move Rhai examples and tests into packages/crypto/ (following core pattern)
- Update README with feature flag documentation and examples

Benefits:
- Single package for all cryptographic operations (3 packages → 1)
- Selective compilation via feature flags
- Unified Rhai integration
- Simplified dependency management
- Consistent package structure with examples/tests inside package

Feature usage:
- Default: keys + httpsig enabled
- Keys only: default-features = false, features = ["keys"]
- Full: features = ["full"] (includes rhai support)
- Update all doc examples to use herolib_crypto instead of herolib-keys/herolib-httpsig
- Fix rhai module function calls to use correct crate paths
- Enable serde feature for ed25519-dalek
- Fix import paths in utils.rs and test modules
- Recreate empty lib.rs and rhai/mod.rs files with proper content

All tests passing (50 unit + 14 doc tests)
herodo compilation successful
Move sha2, base64, and hex dependencies to keys feature since the keys
module utilities require them. This allows keys feature to compile
independently without httpsig.

Verified all feature combinations:
- keys only: 
- httpsig (includes keys): 
- full (all features): 
All packages now use rhai 1.23.6 for consistency.
Verified: compilation, tests, and Rhai examples all passing.
thabeta approved these changes 2025-12-31 17:26:43 +00:00
thabeta merged commit f9bf66829b into develop 2025-12-31 17:26:47 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_research/herolib_rust!34
No description provided.