mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
- Created common types (Hash, Address) in crypto/common - Created hexutil utilities for hex encoding/decoding - Created math utilities for big integer operations - Created minimal RLP encoder for crypto package needs - Updated all imports from github.com/luxfi/geth to local packages - All tests pass with no functionality changes
2.2 KiB
2.2 KiB
Geth Dependency Removal Notes
Summary
Successfully removed all dependencies on github.com/luxfi/geth from the crypto package by implementing the necessary types and utilities locally.
Changes Made
1. Created Common Types (common/types.go)
- Implemented
Hashtype (32-byte array) with all necessary methods - Implemented
Addresstype (20-byte array) with EIP-55 compliant checksumming - Added common big integer constants (Big0, Big1, etc.)
- Added helper functions for hex encoding/decoding
2. Created Hex Utilities (common/hexutil/)
- Implemented hex encoding/decoding with 0x prefix support
- Added types for JSON marshaling (Big, Uint64, Uint, Bytes)
- Supports all the hex utility functions previously imported from geth
3. Created Math Utilities (common/math/)
- Implemented big integer math functions (BigPow, BigMax, BigMin)
- Added PaddedBigBytes for encoding big integers with padding
- Implemented safe arithmetic operations (SafeAdd, SafeSub, SafeMul, SafeDiv)
- Added other utility functions like ReadBits, U256, S256
4. Created RLP Encoding (rlp/encode.go)
- Minimal RLP encoder implementation supporting:
- Basic types: []byte, string, uint64, *big.Int
- Common types: common.Address, common.Hash
- Lists: []interface{}
- Sufficient for crypto package needs (primarily CreateAddress function)
5. Updated All Imports
- Changed all imports from
github.com/luxfi/geth/*togithub.com/luxfi/crypto/* - Updated files:
- crypto.go
- crypto_test.go
- signature_test.go
- signature_cgo.go
- secp256k1/ethereum.go
- kzg4844/kzg4844.go
- kzg4844/kzg4844_ckzg_cgo.go
Testing
- All existing tests pass
- No functionality changes, only dependency removal
- The CreateAddress function works correctly with the new RLP encoder
Benefits
- No external dependency on geth
- Reduced binary size (only includes necessary code)
- Better control over the implementation
- Easier to maintain and update
Notes
- The implementations are minimal but complete for crypto package needs
- If more RLP functionality is needed in the future, the encoder can be extended
- The common types match the geth interface exactly for compatibility