A secure, distributed oracle system built on Algorand that implements Shamir's Secret Sharing (SRS) with OPRF (Oblivious Pseudorandom Function) evaluation capabilities. This is an example implementation of an oracle, written in Rust, that listens for OPRF evaluation requests on the Algorand blockchain, processes them, and posts sesults back to the blockchain using the (SRS smart contracts)[https://github.com/blockshake-io/srs_smart_contracts].
SRS Oracle is a decentralized system that provides secure secret sharing and recovery using cryptographic primitives. The system consists of:
- Oracles: Distributed nodes that perform OPRF evaluations
- Registry: A smart contract that manages user accounts and configurations
- Client: An example of a command-line interface for user registration and account recovery
- Shamir Secret Sharing: Distributes secrets across multiple oracles using threshold cryptography
- OPRF Evaluation: Implements oblivious pseudorandom function evaluation for secure computation
- Argon2 Key Stretching: Configurable key derivation function for enhanced security
- Algorand Integration: Built on Algorand blockchain for decentralized operation
- Account Recovery: Secure recovery mechanism using seed phrases
-
Oracle Nodes (
src/main.rs)- Process OPRF evaluation requests
- Handle encrypted shard decryption
- Respond with evaluated elements
-
Registry Smart Contract
- Manages user accounts and configurations
- Stores encrypted OPRF configurations
- Handles user registration and topology management
-
Client (
examples/client.rs)- Interactive command-line interface
- User registration and account recovery
- OPRF evaluation coordination
-
Shamir Implementation (
src/shamir.rs)- Secret sharing and reconstruction
- Lagrange interpolation
- Threshold cryptography
- Rust 1.70+ and Cargo
- Algorand node (local or testnet)
- Algorand indexer (local or testnet)
- Algonaut SDK (custom fork)
- Clone the repository:
git clone <repository-url>
cd srs_oracle- Install dependencies:
cargo buildEach oracle expects the following environment variables:
APP_ID="1045"
ENCRYPTION_SK="d9a61a8a04114e1a59259dfa3bafdb35700ae5b24b6de08112d8140a83163095"
ACCOUNT_MNEMONIC="gallery moment cute stuff prison pyramid question spot average basic thank twin erupt spawn car roast old lens fold aware industry desert figure absorb myth"
ALGOD_URL="https://testnet-api.4160.nodely.dev"
ALGOD_TOKEN=""
INDEXER_URL="https://testnet-idx.4160.nodely.dev"
TOPOLOGY_ID=1Generate new keypairs using:
cargo run --example generate_keypairThe registry application ID and topology must be configured in the client.
Start individual oracle nodes:
# Oracle 1
./scripts/oracle1.sh
# Oracle 2
./scripts/oracle2.sh
# Oracle 3
./scripts/oracle3.shStart the interactive client:
./scripts/client.shregister: Register a new user accountrecover: Recover an existing account using seed phraselogout: Log out from current sessionshow-topology: Display current oracle topologyshow-argon2: Show current Argon2 configurationconfigure-argon2: Configure Argon2 parametershelp: Show available commandsexit: Exit the client
- Generate Seed Phrase: The system generates a random 4-word seed phrase
- Shamir Sharing: The secret is split into shares using threshold cryptography
- OPRF Evaluation: Each oracle evaluates the blinded input
- Key Derivation: Argon2 is used to stretch the OPRF output
- Account Creation: A new Algorand account is created and funded
- Configuration Storage: Encrypted configuration is stored in the registry
- Input Credentials: Username and seed phrase are provided
- Configuration Retrieval: OPRF configuration is retrieved from registry
- OPRF Evaluation: Oracles evaluate the blinded input
- Key Derivation: Argon2 derives the encryption key
- Account Recovery: The original account is recovered using the decrypted seed
- Threshold Cryptography: Secrets are distributed across multiple oracles
- Oblivious Evaluation: Oracles cannot learn the original input
- Encrypted Storage: All sensitive data is encrypted
- Key Stretching: Argon2 provides resistance against brute force attacks
- Blockchain Security: Algorand provides consensus and immutability
- Uses BLS12-381 curve for efficient pairing operations
- Implements blinding and unblinding for privacy
- Supports threshold evaluation across multiple oracles
- Configurable threshold for secret reconstruction
- Lagrange interpolation for share combination
- Secure against up to (threshold-1) compromised oracles
- Configurable memory, time, and parallelism parameters
- Resistant to GPU and ASIC attacks
- Supports multiple variants (Argon2d, Argon2i, Argon2id)
# Build the library
cargo build
# Build with optimizations
cargo build --release# Run the client example
cargo run --example client
# Generate a new keypair
cargo run --example generate_keypair- algonaut: Algorand SDK for blockchain interaction
- blstrs: BLS12-381 curve implementation
- crypto-box: Public-key authenticated encryption
- argon2: Password hashing and key derivation
- tokio: Async runtime for concurrent operations
- serde: Serialization framework
[Add your license information here]
[Add contribution guidelines here]
[Add support information here]