hailin
6b85401d5c
fix(mnemonic): fix recovery-by-mnemonic using hash verification instead of address matching
...
## Problem
MPC wallet addresses have no cryptographic relationship with recovery mnemonics,
so address-based verification always failed for account recovery.
## Solution
Changed mnemonic verification from address matching to hash-based verification:
- Mnemonic acts as identity credential, verified by hash stored in blockchain-service
- Uses accountSequence to lookup stored mnemonic hash for verification
## Changes
### blockchain-service
- recovery-mnemonic.adapter.ts:
- generateMnemonic() now async, uses bcrypt (rounds=12) for secure hashing
- verifyMnemonic() now async, supports both bcrypt and legacy SHA256 hashes
- Added backward compatibility for existing SHA256 hashed mnemonics
- mnemonic-verification.service.ts:
- await verifyMnemonic() for async bcrypt comparison
- address-derivation.service.ts:
- await generateMnemonic() for async bcrypt hashing
- package.json: added bcrypt dependency
### identity-service
- user-application.service.ts:
- Changed recoverByMnemonic() to use verifyMnemonicByAccount (hash verification)
- Added rate limiting: 5 failed attempts per hour per accountSequence
- Uses Redis to track failed verification attempts
- redis.service.ts:
- Added incr() and expire() methods for rate limiting
- Added updateKeygenStatusAtomic() with Lua script for atomic state transitions
- mpc-keygen-completed.handler.ts:
- Uses atomic Redis update to prevent race conditions
- blockchain-wallet.handler.ts:
- Uses atomic Redis update for completed status
## Security Improvements
- bcrypt with 12 rounds for mnemonic hashing (anti-brute-force)
- Rate limiting prevents brute force attacks on mnemonic recovery
- Atomic Redis operations prevent race conditions in wallet creation flow
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 09:02:24 -08:00
hailin
50388c1115
feat(blockchain-service): implement complete blockchain service with DDD + Hexagonal architecture
...
- Domain layer: ChainType, EvmAddress, TxHash, TokenAmount, BlockNumber value objects
- Domain events: DepositDetected, DepositConfirmed, WalletAddressCreated, TransactionBroadcasted
- Aggregates: DepositTransaction, MonitoredAddress, TransactionRequest
- Infrastructure: Prisma ORM, Redis cache, Kafka messaging, EVM blockchain adapters
- Application services: AddressDerivation, DepositDetection, BalanceQuery
- API: Health, Balance, Internal controllers with Swagger documentation
- Deployment: Docker, docker-compose, deploy.sh, health-check scripts
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 20:54:58 -08:00