Skip to content

10-trix/Proof-Of-Existence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🔐 Proof of Existence — Stellar Soroban dApp

Store SHA-256 file hashes on the Stellar blockchain. Prove any file existed at a specific point in time — immutably.

📁 Project Structure

proof-of-existence/
├── contracts/
│   └── proof-of-existence/
│       ├── Cargo.toml          # Rust dependencies (soroban-sdk)
│       └── src/
│           └── lib.rs          # Soroban smart contract
├── frontend/
│   ├── index.html              # Main UI
│   ├── styles.css              # Premium dark theme
│   └── app.js                  # SHA-256 hashing + Stellar SDK integration
└── README.md

🚀 Quick Start

Prerequisites

  1. Rust + Soroban target

    # Install Rust
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    
    # Add WASM target
    rustup target add wasm32-unknown-unknown
  2. Stellar CLI

    # Install via cargo
    cargo install stellar-cli --locked
    
    # Or on macOS
    brew install stellar-cli

🔨 Build the Contract

cd contracts/proof-of-existence

# Build to WASM
stellar contract build

The compiled WASM will be at:

target/wasm32-unknown-unknown/release/proof_of_existence.wasm

🌐 Deploy to Stellar Testnet

Step 1: Configure Testnet Identity

# Generate a new identity for testnet
stellar keys generate --global deployer --network testnet

# Fund it from friendbot
stellar keys fund deployer --network testnet

# Verify the address
stellar keys address deployer

Step 2: Deploy the Contract

# Deploy the WASM to testnet
stellar contract deploy \
  --wasm target/wasm32-unknown-unknown/release/proof_of_existence.wasm \
  --source deployer \
  --network testnet

Save the returned Contract ID! You'll need it for the frontend (e.g., CABC...XYZ).

Step 3: Test via CLI

# Store a hash (32 bytes hex)
stellar contract invoke \
  --id CCNUSX5OS43RFKZDMO4KQJASQS55ZPH3DX5BLWRUMUHUDPVB2AGO66DM \
  --source deployer \
  --network testnet \
  -- \
  store_hash \
  --registrar $(stellar keys address deployer) \
  --hash 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20

# Verify the hash
stellar contract invoke \
  --id CCNUSX5OS43RFKZDMO4KQJASQS55ZPH3DX5BLWRUMUHUDPVB2AGO66DM \
  --source deployer \
  --network testnet \
  -- \
  verify_hash \
  --hash 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20

🖥️ Run the Frontend

cd frontend

# Option 1: Python
python -m http.server 8080

# Option 2: Node.js
npx serve .

# Option 3: VS Code Live Server extension

Then open http://localhost:8080 in your browser.

Frontend Configuration

  1. Open the Network Configuration panel
  2. Enter your Contract ID (from deploy step)
  3. Enter your Testnet Secret Key (S...)
  4. RPC URL and passphrase are pre-filled for testnet

📋 Smart Contract API

store_hash(registrar: Address, hash: BytesN<32>)

  • Stores a SHA-256 hash on-chain
  • Requires registrar authorization
  • Panics if hash is already registered (no duplicates)
  • Records: registrar address + ledger timestamp

verify_hash(hash: BytesN<32>) -> Option<HashRecord>

  • Returns Some(HashRecord) if the hash exists
  • Returns None if not found
  • Read-only — no signing required for simulation

HashRecord Struct

Field Type Description
registrar Address The account that registered the hash
timestamp u64 Ledger timestamp at registration

🔑 Key Design Decisions

Decision Rationale
BytesN<32> as key SHA-256 produces exactly 32 bytes — perfect fit
Persistent storage Data should survive across ledgers
TTL extension (~30 days) Prevents accidental archival
Duplicate rejection Ensures first-registrant wins
Read-only verify via simulation No gas cost for verification queries

🧪 Run Contract Tests

cd contracts/proof-of-existence
cargo test

Expected output:

test test::test_store_and_verify ... ok
test test::test_duplicate_hash_rejected ... ok

⚠️ Security Notes

  • Never use mainnet keys in the frontend — this is a testnet demo
  • Files never leave the browser — only the SHA-256 hash is transmitted
  • For production, integrate a wallet like Freighter instead of raw secret keys

🛠️ Tech Stack

  • Smart Contract: Rust + Soroban SDK
  • Frontend: HTML + CSS + Vanilla JS
  • Hashing: Web Crypto API (SHA-256)
  • Blockchain: Stellar Network (Soroban)
  • SDK: @stellar/stellar-sdk (CDN)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors