PROTOCOL DOCS
Three protocols, one story — Bridgeless Encrypted Capital Markets on Solana
PROGRAM: 833YAgrbapXn…tBN8Nrvx
ORDER LIFECYCLE
SUBMIT ORDER
createInput → Order PDA
→
EXECUTE MATCH
execute_graph CPI
→
SETTLE MATCH
→ Settled
→
SIGN SETTLEMENT
approve_message CPI
→
IKA 2PC-MPC
off-chain signature
→
FINALIZE
verify sig → Finalized
→
LI.FI BRIDGE
optional cross-chain
01
ENCRYPT FHE SDK
Homomorphic order matching

Price and size are encrypted client-side via gRPC createInput before they ever touch Solana. The Noctex program then CPIs into Encrypt's execute_graph with the match_orders graph — bid ≥ ask, min(amounts), conditional fills — all evaluated on ciphertexts. The executor never sees plaintext; only ciphertext pubkeys land on the Order PDA.

INTEGRATION DETAILS
Instructionssubmit_order, execute_match, settle_match
DSL macro#[encrypt_fn] match_orders(bid, ask) → (fill_b, fill_s, exec)
Key typesEUint64 ciphertexts (fhe_type=4)
CPI seedb"__encrypt_cpi_authority"
CPI shape[disc=4, graph_len_u16, graph, num_inputs_u8] + 8 metas + 4 in + 3 out
Program4ebfzWdK…wArND8 (devnet)
02
IKA dWALLET — 2PC-MPC
Distributed settlement signing

Settlement only advances if the Ika network produces a distributed signature over the settlement digest. sign_settlement CPIs into Ika to create a MessageApproval PDA; the network signs off-chain and commits the signature back. finalize_settlement reads the MessageApproval bytes on-chain and refuses to flip to Finalized unless owner=Ika, status=Signed, sig_len > 0.

INTEGRATION DETAILS
DKGgRPC DKG via ika-pre-alpha — dWallet PDA + Ed25519 pubkey
Sign CPIsign_settlement → approve_message (disc 8, 100 bytes)
Verify gatefinalize_settlement reads bytes 172 (status) / 173-174 (sig_len) / 175+ (signature)
Hash schemekeccak256("noctex-settlement-v0|<buy>|<sell>")
dWallet3om31VWzJx6oPt37qYcUSZFosfFGZgeegX7VjQBi7aRG (Curve25519)
Live signatureb92d6c9c…4b69f07 (64-byte EddsaSha512 on-chain)
03
LI.FI SDK
Cross-chain delivery

Once a settlement is Finalized, LI.FI provides the route to deliver value cross-chain. A single Ika signature on Solana unlocks bridging to any supported EVM chain — settlement integrity stays on Noctex; LI.FI just moves the asset.

INTEGRATION DETAILS
SDK@lifi/sdk — getQuote, executeRoute
Widget@lifi/widget — embedded settlement-route UI
Flowfinalize_settlement → LI.FI route → cross-chain transfer
ChainsSolana → Ethereum / Arbitrum / Base / Optimism
IntegrationLifiSettlement panel on the trade page
LIVE ON DEVNETEACH ROW LINKS TO SOLANA EXPLORER →
Noctex program833YAgrb…CtBN8NrvxEncrypt program4ebfzWdK…wArND8Ika program87W54kGY…fiq1oYBootstrapped dWallet3om31VWz…JBi7aRGTX — execute_match (FHE CPI)JdLWuJSr…evw2TX — sign_settlement (Ika CPI)3ponRNZH…DFvbTX — finalize_settlement (sig gate)HMm7bQEn…WQciMessageApproval (status=Signed)kCq63KGk…ETBGMSY
PROGRAM INSTRUCTIONS
◈ BROWSER◇ CLI
submit_orderRecord (owner, side, encrypted_price, encrypted_amount) on a fresh Order PDA.
BROWSER + CLIOrderForm 'PLACE BUY/SELL'
execute_matchRun match_orders FHE graph via Encrypt CPI; persist output ciphertexts.
BROWSER + CLISettlementFlow step 1
settle_matchTransition both Orders Matching → Settled.
BROWSER + CLISettlementFlow step 2
sign_settlementCPI Ika approve_message; bind MessageApproval to both Orders.
BROWSER + CLISettlementFlow step 3
(Ika network signs)Off-chain 2PC-MPC: gRPC Presign + Sign; commit 64-byte signature.
CLI ONLYnoctex-ika-bootstrap sign
finalize_settlementVerify owner / status=Signed / sig_len > 0; advance to Finalized.
BROWSER + CLISettlementFlow step 4
cancel_orderOwner-only, Pending-only cancellation.
CLI ONLYbun run cancel
initialize_dwalletOne-time: record dWallet ID + CPI authority on DWalletConfig PDA.
CLI ONLYbun run init-dwallet
BROWSER vs. CLI — WHAT RUNS WHERE
◈ In the browser (Phantom-signed)
  • Encrypt gRPC-web createInput for price + amount
  • submit_order via Phantom signature
  • execute_match — pre-allocates 3 output ciphertexts then CPI
  • settle_match
  • sign_settlement — Ika approve_message CPI
  • finalize_settlement — polls MessageApproval, verifies sig gate
◇ Needs CLI (between Sign and Finalize)
  • Ika pre-alpha 2PC-MPC signing — gRPC Presign + Sign uses BCS + tonic with no browser equivalent.
  • Run noctex-ika-bootstrap sign <TX> <BUY> <SELL> from client-rust/.
  • The SettlementFlow panel prints the exact command after step 3 so the user can copy-paste.
  • Once the signature lands on-chain, step 4 (Finalize) runs from the browser again.
KEY INTEGRATION CODE
FHE match_orders graph (programs/noctex/src/fhe.rs)rust
#[encrypt_fn]
pub fn match_orders(
    bid_price: EUint64, ask_price: EUint64,
    bid_amount: EUint64, ask_amount: EUint64,
) -> (EUint64, EUint64, EUint64) {
    let matched     = bid_price.is_greater_or_equal(&ask_price);
    let min_amount  = bid_amount.min(&ask_amount);
    let fill_buyer  = if matched { min_amount } else { EUint64::from(0u64) };
    let fill_seller = if matched { min_amount } else { EUint64::from(0u64) };
    let exec_price  = if matched { ask_price  } else { EUint64::from(0u64) };
    (fill_buyer, fill_seller, exec_price)
}
Encrypt execute_graph CPI (programs/noctex/src/fhe.rs)rust
// We build the CPI inline to keep Noctex on anchor-lang 0.32.
// Wire format (verified against the Encrypt SDK):
//   ix_data  = [4, graph_len_u16_le, graph_bytes, num_inputs_u8]
//   accounts = [config(W), deposit(W), caller_program, cpi_authority(S),
//               network_encryption_key, payer(W,S), event_authority,
//               encrypt_program, ...4_inputs(W), ...3_outputs(W)]
let seeds: &[&[u8]] = &[ENCRYPT_CPI_AUTHORITY_SEED, &[cpi_authority_bump]];
invoke_signed(&ix, &infos, &[seeds])?;
Ika signature gate (programs/noctex/src/lib.rs:309)rust
pub fn finalize_settlement(ctx: Context<FinalizeSettlement>) -> Result<()> {
    let ma = &ctx.accounts.message_approval;

    require!(buy.message_approval == ma.key()
          && sell.message_approval == ma.key(), MessageApprovalMismatch);
    require!(ma.owner == &IKA_PROGRAM_ID, MessageApprovalNotIkaOwned);

    let data = ma.try_borrow_data()?;
    require!(data.len() >= 175, MessageApprovalMalformed);
    require!(data[172] == 1, SettlementNotSigned);          // status = Signed
    let sig_len = u16::from_le_bytes(data[173..175].try_into().unwrap());
    require!(sig_len > 0, SettlementSignatureMissing);

    buy.status = OrderStatus::Finalized;
    sell.status = OrderStatus::Finalized;
    Ok(())
}
Frontend submit_order (app/src/components/OrderForm.tsx)typescript
// Encrypt price + amount via gRPC-web, then submit via Phantom.
const { program, publicKey } = await getProgramWithPhantom();
const encrypt = createEncryptWebClient(ENCRYPT_GRPC_WEB);

const ids = await encrypt.createInput({
  chain: Chain.SOLANA,
  inputs: [
    { ciphertextBytes: mockCiphertextBytes(BigInt(price),  4), fheType: 4 },
    { ciphertextBytes: mockCiphertextBytes(BigInt(amount), 4), fheType: 4 },
  ],
  authorized: NOCTEX_PROGRAM_ID.toBytes(),
  networkEncryptionPublicKey: PRE_ALPHA_NETWORK_KEY,
});

const sig = await program.methods
  .submitOrder(new BN(nonce), sideArg, new PublicKey(ids[0]), new PublicKey(ids[1]))
  .accountsPartial({ order: orderPda, owner: publicKey, systemProgram: SystemProgram.programId })
  .rpc();