Smart contracts implementing the ProofBridge cross-chain settlement protocol. Two implementations sharing identical protocol logic across different blockchain ecosystems.
CHAIN 1 (Ad Chain) CHAIN 2 (Order Chain)
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ │ │ │
│ ┌────────────────────┐ │ │ ┌────────────────────┐ │
│ │ AdManager │◄─────┼──────┼──────┤ OrderPortal │ │
│ └────────────────────┘ │ │ └────────────────────┘ │
│ │ │ │ │ │
│ │ Manager │ │ Manager │ │
│ ▼ │ │ ▼ │
│ ┌────────────────────┐ │ │ ┌────────────────────┐ │
│ │ MerkleManager │ │ │ │ MerkleManager │ │
│ └────────────────────┘ │ │ └────────────────────┘ │
│ ▲ │ │ ▲ │
│ │ Manager │ │ Manager │ │
│ │ │ │ │ │
│ ┌────────────────────┐ │ │ ┌────────────────────┐ │
│ │ OrderPortal │──────┼──────┼─────►│ AdManager │ │
│ └────────────────────┘ │ │ └────────────────────┘ │
│ │ │ │ │ │
│ ┌────────────────────┐ │ │ ┌────────────────────┐ │
│ │ Verifier │ │ │ │ Verifier │ │
│ └────────────────────┘ │ │ └────────────────────┘ │
│ │ │ │
└──────────────────────────────┘ └──────────────────────────────┘
- Maker creates an Ad on AdManager, funding it with the destination-chain token.
- Bridger opens an order on OrderPortal, depositing the source-chain token.
- The system relays the order hash to the maker off-chain; the maker locks an amount from the Ad against that order.
- After the maker fulfills the user on the opposite chain, a zk proof is generated and submitted to unlock:
- On OrderPortal: release order-token to the maker destination recipient recorded in the order.
- On AdManager: release ad token from contract to the bridger's designated recipient.
Replay is prevented via:
- EIP-712 struct hash that binds chain ids and contract addresses.
- A nullifier recorded once per successful proof.
- Bidirectional chain linking ensures contracts only accept proofs from configured counterparts.
- Manager permissions on MerkleManager restrict who can append order hashes.
NATIVE TOKENS are denoted by the all-0xEE sentinel address on EVM.
The destination chain contract where liquidity providers (makers) manage their advertisements and fulfill cross-chain orders.
Core Functions:
- createAd: Creates a new liquidity advertisement with specified parameters
- fundAd: Deposits tokens into an existing ad to increase available liquidity
- withdrawFromAd: Withdraws unused tokens from an ad
- closeAd: Permanently closes an ad and withdraws all remaining funds
- lockForOrder: Reserves liquidity for a specific EIP-712 order hash, appends to MMR
- unlock: Verifies ZK proof, consumes nullifier, transfers ad token to the orderRecipient
- setChain / setTokenRoute: Admin configuration for cross-chain routing
Key Storage:
chains[orderChainId] → { supported, orderPortal }: Source chain configurationtokenRoute[adToken][orderChainId] → orderToken: Cross-chain token mappingads[adId] → { creator, token, balance, locked, open, … }: Ad state managementorders[orderHash] → Status: Order execution trackingnullifiers[hash] → bool: Proof replay prevention
The source chain contract where users initiate cross-chain transfers by creating orders.
Core Functions:
- createOrder: Initiates a cross-chain order by depositing source chain tokens, appends to MMR
- unlock: Verifies ZK proof and releases funds to the designated recipient
- setChain / setTokenRoute: Admin configuration
Key Storage:
chains[dstChainId] → { supported, adManager }: Destination chain configurationtokenRoute[token1][dstChainId] → token2: Cross-chain token routingorders[orderHash] → Status: Order lifecycle managementnullifiers[hash] → bool: Prevents proof reuse
Poseidon2-based Merkle Mountain Range (MMR) for order hash storage and inclusion proofs.
Core Functions:
- appendOrderHash: Adds new order hashes to the MMR (manager-only)
- getRootHash: Returns the current MMR root for proof verification
- verifyProof: Validates inclusion proofs against the MMR
Technical Features:
- Poseidon2 Hashing: Same hash function as the Noir ZK circuit
- Field Modular Reduction: Applies BN254 field mod to order hashes for circuit compatibility
- Root History: Maintains roots for proof validation
- Cross-Chain Compatible: EVM and Stellar implementations produce identical roots
UltraHonk zero-knowledge proof verifier.
- Proving System: UltraHonk (keccak-based Fiat-Shamir for on-chain verification)
- Elliptic Curve: BN254
- Verification Key: Stored on-chain at construction
-
Domain:
EIP712Domain(string name, string version)name = "Proofbridge"version = "1"
Note: We do not include
chainIdorverifyingContractin the domain. Instead, those values are explicit fields in the Order struct.
Order {
orderChainToken // source token (order chain)
adChainToken // destination token (ad chain)
amount // transfer amount
bridger // bridger address
orderChainId // source chain ID
orderPortal // order portal contract address
orderRecipient // recipient on order chain
adChainId // destination chain ID
adManager // ad manager contract address
adId // advertisement identifier
adCreator // ad creator address
adRecipient // recipient on ad chain
salt // caller-controlled nonce
}
Address encoding differs by implementation:
- EVM:
address(20 bytes, zero-padded to 32 for hashing) - Stellar:
BytesN<32>(full 32 bytes —C...for contracts,G...for ed25519 accounts)
Both produce identical EIP-712 hashes when given the same 32-byte values.
The protocol employs a ZK proof system for privacy-preserving cross-chain settlements:
Proof Generation Process:
- Secret Generation: Each participant generates a private secret for nullifier computation
- Nullifier Calculation:
nullifierHash = poseidon2(secret_half, orderHashMod)— bridger uses left half, ad creator uses right half - Circuit Execution: Noir circuit validates the relationship between secrets, nullifiers, and MMR inclusion
- Proof Creation: UltraHonk backend generates proof with keccak-based Fiat-Shamir
Proof circuits: See proof_circuits/
The circuit produces 4 public inputs (each 32 bytes, 128 bytes total):
OrderPortal.unlock (Source Chain):
adCreator's nullifierHash: Poseidon2 commitment proving ad creator's secret knowledgeorderHashMod: EIP-712 order hash reduced to BN254 fieldtargetRoot: MMR root at the time of proof generation0: Chain flag (0 = source chain / order portal)
AdManager.unlock (Destination Chain):
bridger's nullifierHash: Poseidon2 commitment proving bridger's secret knowledgeorderHashMod: EIP-712 order hash reduced to BN254 fieldtargetRoot: MMR root at the time of proof generation1: Chain flag (1 = destination chain / ad manager)
Multi-Layer Protection:
- EIP-712 Domain Separation: Prevents cross-contract and cross-chain replay attacks
- Nullifier Uniqueness: Cryptographic guarantee against double-spending
- MMR Integrity: Tamper-proof order history with Poseidon2 hashing
- Manager Permissions: Only authorized contracts can append to the MMR
- Bidirectional Chain Linking: Contracts only accept proofs from configured counterparts
Economic Security:
- Collateral Requirements: Makers must lock funds before order matching
- Slashing Mechanisms: Penalties for malicious behavior or failed settlements (TBA)
- Liquidity Guarantees: Orders are only created when sufficient liquidity is available (TBA)