Production System - Structured Field Hashing + PhoneLock Protocol™ Protocol
class PhoneLockProtocol { private verificationWindow = 5 * 60 * 1000; // 5 minutes private smsTimeout = 60 * 1000; // 1 minute for SMS // Create phone-locked attestation async createPhoneLockedAttestation( wireDetails: WireInstructions, buyerInfo: BuyerInfo ): Promise<AttestationId> { // Validate and hash phone number const phoneHash = this.hashPhoneNumber(buyerInfo.phone); // Create attestation with phone binding const attestation = { wireDetails, phoneNumberHash: phoneHash, requiresPhoneLock: true, verificationWindow: this.verificationWindow, fieldHashes: this.createFieldHashes(wireDetails) }; // Store on blockchain with phone lock return await this.storeOnBlockchain(attestation); } // Request verification (ONLY works from registered phone) async requestVerification( attestationId: string, phoneNumber: string ): Promise<SessionId> { // Verify phone matches attestation if (!this.verifyPhoneMatch(attestationId, phoneNumber)) { throw new Error('Phone not authorized for this wire'); } // Send SMS with time-locked link const session = await this.createSecureSession(); await this.sendSMS(phoneNumber, { message: `xTitle Wire Verification\nCode: ${session.code}\nLink: verify.xtitle.io/s/${session.id}\nExpires in 60 seconds` }); return session.id; } }
interface WireInstructions { bank: string; account: string; routing: string; amount: number; } class StructuredHashingService { // Create individual field hashes for granular detection private createFieldHashes(wire: WireInstructions): FieldHashes { return { bank: this.hashField(wire.bank, 'BANK'), account: this.hashField(wire.account, 'ACCOUNT'), routing: this.hashField(wire.routing, 'ROUTING'), amount: this.hashField(wire.amount.toString(), 'AMOUNT') }; } // Verify with specific field detection public async verifyWire( attestationId: string, wire: WireInstructions ): VerificationResult { const stored = await this.getStoredHashes(attestationId); const current = this.createFieldHashes(wire); const mismatches = []; for (const field in current) { if (stored[field] !== current[field]) { mismatches.push({ field, severity: this.calculateSeverity(field), message: `${field} has been modified` }); } } return { valid: mismatches.length === 0, mismatches, fraudScore: this.calculateFraudScore(mismatches) }; } }
# Multi-AZ deployment for high availability resource "aws_autoscaling_group" "api" { name = "xtitle-api-asg" min_size = 3 max_size = 10 desired_capacity = 3 vpc_zone_identifier = aws_subnet.private[*].id launch_template { id = aws_launch_template.api.id version = "$Latest" } } # RDS PostgreSQL with encryption resource "aws_db_instance" "main" { engine = "postgres" engine_version = "15.3" instance_class = "db.r6g.xlarge" storage_encrypted = true multi_az = true }
export default { async fetch(request, env, ctx) { // Rate limiting check const ip = request.headers.get('CF-Connecting-IP'); const rateLimit = await checkRateLimit(ip, env); if (rateLimit.exceeded) { return new Response('Too Many Requests', { status: 429 }); } // Fraud detection at edge if (await detectSuspiciousPattern(request)) { ctx.waitUntil(logSecurityEvent(request, env)); return new Response('Forbidden', { status: 403 }); } return fetch(request); } }
# Custom metrics for fraud detection wire_verification_total{status="success"} 8547 wire_verification_total{status="failed"} 23 field_hash_mismatches_total{field="account"} 12 field_hash_mismatches_total{field="routing"} 7 fraud_detection_score_histogram{le="0.5"} 8523 fraud_detection_score_histogram{le="0.9"} 8540 xrpl_transaction_duration_seconds{quantile="0.95"} 0.045
name: Deploy Production on: push: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - name: Run Tests run: | npm test npm run test:integration npm run test:security deploy: needs: test steps: - name: Deploy to AWS run: | terraform apply -auto-approve ./scripts/deploy.sh production