You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix client ephemeral key entropy: architectural consistency and validation
This commit resolves a critical architectural inconsistency between client and server
ephemeral key generation that resulted in reduced entropy for client keys.
Problem:
- Client used function pattern: this.N = function() { return new BigInteger(...) }
- Server used property pattern: this.N = new BigInteger(...)
- randomA(N) was incorrectly passed the constructor function instead of BigInteger
- Result: client generated ~252 bits entropy vs server's 2048 bits
Solution:
- Unified architecture: both client and server now use property pattern
- Updated all this.N() calls to this.N property access (7 locations)
- Updated all this.g() calls to this.g property access (4 locations)
- Fixed randomA() to use this.N internally without parameter
- Added input validation to prevent functions in crypto operations
- Enhanced build process with JSHint linting
Testing:
- Client now generates correct 2048-bit ephemeral keys (512 hex chars)
- Server maintains 2048-bit generation (consistent behavior)
- All existing tests pass with architectural fix
- Added entropy validation test to prevent regression
Technical Details:
- Fixes issue #28: Client ephemeral key generation uses 252 bits instead of 2048 bits
- Implements architectural consistency plan from issue #29
- Maintains backward compatibility for all public APIs
- No breaking changes to existing functionality
0 commit comments