Component Interactions

Component Interactions in Roru Labs

This document details how the various components of the Roru ecosystem interact with each other, providing developers with a comprehensive understanding of system integration points.

Interaction Patterns

Wallet to SDK

Interaction Flow:

  1. Wallet calls SDK API

  2. SDK validates input

  3. SDK constructs protocol message

  4. SDK handles response

  5. Wallet updates UI

APIs Used:

  • Transaction builder API

  • Proof generation API

  • State sync API

  • Offline transfer API

Data Format:

  • JSON for API calls

  • Protocol buffers for internal communication

  • Encrypted channels for sensitive data

SDK to Protocol

Interaction Flow:

  1. SDK constructs transaction

  2. Protocol validates structure

  3. Protocol selects notes

  4. Protocol generates proof

  5. Protocol creates bundle

  6. SDK returns to wallet

Protocol Operations:

  • Note selection algorithms

  • Proof circuit execution

  • Nullifier generation

  • Commitment creation

SDK to Infra

Interaction Flow:

  1. SDK connects to Infra endpoints

  2. Infra authenticates connection

  3. SDK sends requests

  4. Infra processes in enclaves

  5. Infra returns encrypted responses

  6. SDK decrypts and processes

Infra Services:

  • Encrypted RPC gateways

  • Prover clusters

  • Sync nodes

  • Relayer clusters

Protocol to Blockchain

Interaction Flow:

  1. Protocol creates settlement transaction

  2. Adapter formats for target chain

  3. Relayer broadcasts to blockchain

  4. Blockchain confirms transaction

  5. State updated in protocol

Adapter Functions:

  • Chain-specific formatting

  • Gas estimation

  • Fee calculation

  • Transaction construction

Synchronization Patterns

State Synchronization

Wallet to Sync Node:

  1. Wallet requests state root

  2. Sync node returns current root

  3. Wallet compares with local

  4. Wallet requests Merkle proofs

  5. Sync node provides proofs

  6. Wallet verifies and updates

Incremental Updates:

  • Only changed state downloaded

  • Merkle proofs for efficiency

  • Batch updates when possible

  • Encrypted synchronization

Multi-Device Sync

Device to Device:

  1. Device A creates transaction

  2. Encrypted sync to Device B

  3. Device B validates

  4. Both devices updated

  5. State consistent across devices

Sync Protocol:

  • End-to-end encryption

  • Conflict resolution

  • State verification

  • Incremental updates

Hardware Interactions

Wallet to Roru One

Pairing Flow:

  1. Wallet initiates pairing

  2. Roru One generates code

  3. Both devices confirm

  4. Encrypted connection established

  5. Keys synchronized (encrypted)

Transaction Signing:

  1. Wallet creates transaction

  2. Sends to Roru One

  3. Roru One displays/communicates details

  4. User confirms on device

  5. Roru One signs in secure element

  6. Returns signed transaction

  7. Wallet broadcasts

Offline Operations:

  1. Roru One creates transaction

  2. Signs offline

  3. Generates proof locally

  4. Creates bundle

  5. Transfers via NFC/Bluetooth

  6. Wallet receives and queues

Roru One to Network

Attestation Flow:

  1. Roru One generates attestation

  2. Sends to attestation server

  3. Server verifies hardware

  4. Server issues certificate

  5. Device can authenticate

Firmware Updates:

  1. Server pushes update

  2. Device verifies signature

  3. Device installs in secure boot

  4. Device attests new firmware

  5. Update complete

Infrastructure Interactions

Node to Node

Gossip Protocol:

  1. Node receives transaction

  2. Validates locally

  3. Propagates to neighbors

  4. Network converges

  5. State synchronized

Consensus:

  • State root consensus

  • Proof verification consensus

  • Settlement consensus

  • No blockchain consensus needed

Enclave Processing

TEE/SGX Flow:

  1. Request received

  2. Verified by enclave

  3. Data processed in enclave

  4. Results encrypted

  5. Returned to caller

Attestation:

  • Remote attestation

  • Enclave integrity proof

  • Trust establishment

  • Secure communication

API Interaction Patterns

RESTful APIs

Request Format:

  • HTTPS endpoints

  • JSON request body

  • Authentication headers

  • Rate limiting

Response Format:

  • JSON response

  • Error codes

  • Pagination

  • Metadata

WebSocket APIs

Connection:

  • WSS (WebSocket Secure)

  • Authentication on connect

  • Heartbeat for keepalive

  • Reconnection logic

Message Types:

  • State updates

  • Transaction notifications

  • Proof status

  • Error messages

gRPC APIs

Service Definition:

  • Protocol buffer schemas

  • Streaming support

  • Bidirectional streams

  • Error handling

Use Cases:

  • High-performance operations

  • Real-time updates

  • Batch operations

  • Internal services

Error Handling

Error Propagation

Error Flow:

  1. Error occurs in component

  2. Error wrapped with context

  3. Propagated to caller

  4. SDK handles gracefully

  5. User-friendly message

Error Types:

  • Network errors

  • Validation errors

  • Cryptographic errors

  • State errors

Retry Logic

Retry Strategies:

  • Exponential backoff

  • Maximum retry count

  • Circuit breaker pattern

  • Fallback mechanisms

Performance Optimization

Caching Strategies

Local Caching:

  • State cache in wallet

  • Proof cache

  • Address cache

  • Transaction cache

Cache Invalidation:

  • State root changes

  • Time-based expiration

  • Manual invalidation

  • Event-driven updates

Batch Operations

Batching Benefits:

  • Reduced network calls

  • Lower latency

  • Better throughput

  • Cost efficiency

Batch Types:

  • Transaction batching

  • Proof batching

  • State update batching

  • Network request batching

Security Interactions

Authentication Flow

User Authentication:

  1. User provides credentials

  2. Wallet authenticates

  3. Session established

  4. Encrypted communication

  5. Token refresh

Device Authentication:

  1. Device generates keypair

  2. Attestation to server

  3. Server verifies

  4. Certificate issued

  5. Device authenticated

Authorization Flow

Transaction Authorization:

  1. User initiates transaction

  2. Wallet requests authorization

  3. Roru One confirms (if used)

  4. Authorization granted

  5. Transaction proceeds

Conclusion

Component interactions in Roru:

  • Clear Interfaces: Well-defined APIs

  • Secure Communication: Encrypted channels

  • Efficient Protocols: Optimized data flows

  • Error Handling: Robust error management

  • Performance: Optimized interactions

Understanding these interactions is essential for effective development and integration.

Last updated