Skip to content

ffffffffhugfadil/blind-oracle-stellar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Banner

Blind Oracle

Zero-Knowledge Range Proof Oracle on Stellar Soroban

Blind Oracle: any smart contract can now ask 'is this number in range?' without ever seeing the number. Prove that private data is within a range, without revealing the data itself. Built for Stellar Hacks: Real-World ZK.

Screen Shot 1 Screen Shot 2
---

The Problem

Smart contracts need to make decisions based on private data โ€” but publishing raw data on-chain destroys privacy.

"Is BTC above $95,000 right now?" "Is this user's credit score between 600 and 850?" "Does this wallet hold enough collateral?"

The naive answer (publish the number) is unacceptable. Blind Oracle solves this with zero-knowledge proofs.


What Blind Oracle Does

Private (stays with prover)       Public (on-chain)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€          โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
price  = $97,500         โ”€โ”€ZKโ”€โ”€โ–ถ  range: [$95,000 โ€“ $200,000]
nonce  = secret                   in_range: true โœ…
                                  commitment: 0x8484...
                                  nullifier:  0x2060...

One Groth16 proof. One Stellar transaction. Market resolves. Price never revealed.

Powered by: Groth16 ยท BN254 ยท Circom 2.0 ยท Soroban ยท Poseidon


Live Demo

export ALICE_SECRET="your-stellar-secret-key"

# Interactive range proof demo
bash demo.sh

# Prediction market demo
node --experimental-vm-modules prediction-market-demo.mjs

Prediction Market Demo Results

All resolved on Stellar testnet โ€” price never revealed:

Market Question Price Range Result TX
BTC-001 BTC above $95k? HIDDEN $95kโ€“$200k YES โœ… view
BTC-002 BTC above $95k? HIDDEN $95kโ€“$200k NO โŒ view
ETH-001 ETH between $3.5kโ€“$5k? HIDDEN $3.5kโ€“$5k YES โœ… view

On-Chain Performance

Metric Value
CPU Instructions 33,176,348 / 100,000,000 (33.2%)
Min Resource Fee 37,472 stroops = 0.0037 XLM
Proof Size 256 bytes (constant)
Curve BN254 โ€” 2ร— cheaper than BLS12-381

BN254 is natively supported by Soroban and runs at roughly half the instruction cost of BLS12-381, making Blind Oracle one of the most gas-efficient ZK verifiers on Stellar.


Deployed Contract

Network Contract ID
Stellar Testnet CBXMLDKAE45OIUEOODGFMKZMFE5SA3CSR7NXW7TILBUQBVHEGNCLDQVH

View on Stellar Expert โ†’


How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     PROVER (Off-Chain)                      โ”‚
โ”‚                                                             โ”‚
โ”‚  Private: data_value, nonce                                 โ”‚
โ”‚  Public:  range_min, range_max  โ† set by market maker       โ”‚
โ”‚                                                             โ”‚
โ”‚  [Circom Circuit] โ†’ [SnarkJS Groth16] โ†’ proof.bin (256B)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚ submit
                               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  STELLAR SOROBAN (On-Chain)                 โ”‚
โ”‚                                                             โ”‚
โ”‚  verify(proof_bytes, pub_signals_bytes)                     โ”‚
โ”‚    โ†’ BN254 pairing check (33.2M instructions)               โ”‚
โ”‚    โ†’ return in_range: true / false                          โ”‚
โ”‚                                                             โ”‚
โ”‚  Market resolves. Price never stored anywhere.              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Three Guarantees Per Proof

Guarantee Mechanism
range_min โ‰ค data_value โ‰ค range_max GreaterEqThan + LessEqThan (252-bit)
commitment = Poseidon(data_value, nonce) Binding โ€” prover cannot change value after commit
nullifier = Poseidon(data_value, commitment) Replay protection โ€” same data = same nullifier

Contract Interface

// One-time: store the Groth16 verification key
set_vk(vk_bytes: Bytes) โ†’ Result<(), VerifierError>

// Per proof: verify range membership
verify(proof_bytes: Bytes, pub_signals_bytes: Bytes) โ†’ Result<bool, VerifierError>
// Returns true  โ†’ proof valid AND data is within range
// Returns false โ†’ proof valid but data is outside range
// Returns Error โ†’ malformed input

Use Cases

Private Prediction Markets

Price oracles prove a feed value is within a market's target range without ever publishing the exact price. Markets resolve trustlessly with no data leakage.

KYC / Identity

Prove age โ‰ฅ 18, credit score in range, or accreditation status โ€” without storing personal data on-chain.

DeFi Collateral

Prove collateral exceeds a threshold for undercollateralized lending without exposing portfolio composition.

Compliance Oracles

Prove transaction values stay within regulatory limits without revealing individual amounts to the protocol.


ZK Circuit

File: circuits/blind_oracle_v2.circom

Private inputs : data_value, nonce
Public inputs  : range_min, range_max   โ† verifier sets these
Public outputs : commitment, in_range, nullifier

Constraints    : 1,806
Curve          : BN254
Proof system   : Groth16

The range bounds are public inputs โ€” not hardcoded. One deployed circuit and one deployed contract serve any range, any asset, any use case.


All Test Results

Scenario Data Range Result TX
Credit Score 750 600โ€“850 โœ… in_range view
KYC Age 25 18โ€“65 โœ… in_range view
DeFi Collateral 15,000 10kโ€“50k โœ… in_range view
Credit Score FAIL 500 600โ€“850 โŒ out of range view
BTC Market YES HIDDEN $95kโ€“$200k โœ… YES view
BTC Market NO HIDDEN $95kโ€“$200k โŒ NO view
ETH Market YES HIDDEN $3.5kโ€“$5k โœ… YES view

Quick Start

# Install dependencies
npm install

# 1. Create input
cat > circuits/my_input.json << EOF
{
  "data_value": "97500",
  "nonce": "314159",
  "range_min": "95000",
  "range_max": "200000"
}
EOF

# 2. Generate witness
node circuits/blind_oracle_v2_js/generate_witness.js \
  circuits/blind_oracle_v2_js/blind_oracle_v2.wasm \
  circuits/my_input.json \
  circuits/my_witness.wtns

# 3. Generate proof
npx snarkjs groth16 prove \
  circuits/circuit_v2_final.zkey \
  circuits/my_witness.wtns \
  circuits/my_proof.json \
  circuits/my_public.json

# 4. Encode + verify on-chain
node encode-proof-v2.mjs
export ALICE_SECRET="S..."
node --experimental-vm-modules test-all-scenarios.mjs

Tech Stack

Layer Technology
ZK Proof System Groth16 (SnarkJS 0.7)
ZK Circuit Circom 2.0 + circomlib
Elliptic Curve BN254 (Barreto-Naehrig)
Hash Function Poseidon
Smart Contract Rust โ†’ WASM (Soroban SDK v22)
Blockchain Stellar Soroban Testnet
SDK @stellar/stellar-sdk v16
Trusted Setup Powers of Tau (2^16)

Documentation

File Description
ARCHITECTURE.md System design, data flow, binary formats
WHITE_PAPER.md Cryptographic construction, security analysis
GUIDE.md Developer guide, troubleshooting
DEPLOYMENTS.md All deployments and TX hashes

Security Notes

  • Trusted Setup: Single-contributor ceremony. Production requires multi-party MPC.
  • Testnet Only: Not audited for mainnet.
  • Nullifier Registry: On-chain nullifier tracking not yet implemented (replay protection is off-chain).
  • Reserve Inputs: ZK proves computation correctness, not input truthfulness.

License

MIT

About

๐Ÿ”ฎ Blind Oracle: ZK range proofs on Stellar โ€” KYC, DeFi collateral, and private prediction markets

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors