Skip to content

CipherBlock-io/cipherblock-operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cipherblock

Portable cryptographic reputation management system

What is Cipherblock?

Cipherblock enables anyone to operate a reputation platform where users build verifiable identity and trust metrics that follow them across services. Service providers (like Uber drivers), forecasters, freelancers, and professionals can carry their ratings and reputation across any platform using the same cryptographic keys.

Key Features

  • πŸ”‘ Portable Identity: Same keys work across all operators
  • πŸ“Š Portable Reputation: Trust history follows you everywhere
  • πŸ”’ Tamper-Proof: Cryptographically signed transactions and blocks
  • ⚑ Fast: Thousands of transactions per second
  • 🌐 Decentralized Ecosystem: Multiple competing operators
  • πŸ” Transparent: All transactions publicly verifiable
  • πŸš€ Serverless: Built on Firebase (zero server management)

Project Status

Phase 1: Core Cryptography βœ… COMPLETE

The foundational cryptographic layer is fully implemented and tested:

  • βœ… Keypair generation (secp256k1)
  • βœ… Transaction signing and verification
  • βœ… Block signing and verification
  • βœ… Hashing functions (SHA-256)
  • βœ… Comprehensive test suite (27 tests passing)
  • βœ… Browser & Node.js support

Phase 2: Transaction Validation βœ… COMPLETE

Complete validation for all 8 transaction types:

  • βœ… Common validation (signature, nonce, format)
  • βœ… TOKEN_TRANSFER validation
  • βœ… RATE transaction validation
  • βœ… NFT transactions (MINT, TRANSFER, orders)
  • βœ… ASSET_BURN validation
  • βœ… FEE_UPDATE validation
  • βœ… State-aware checks (balances, ownership, nonces)
  • βœ… Comprehensive test suite (26 validation tests)

Phase 3: State Management βœ… COMPLETE

Complete state execution for all transaction types:

  • βœ… Transaction execution (all 8 types)
  • βœ… Balance tracking (regular and locked)
  • βœ… NFT ownership and locking
  • βœ… Order book management
  • βœ… Order matching with self-cancellation
  • βœ… Order expiration
  • βœ… Fee collection and updates
  • βœ… Nonce tracking
  • βœ… Rating storage
  • βœ… Comprehensive test suite (17 state tests)

Phase 4: Block Processing Engine βœ… COMPLETE

Complete block processing with integrated validation and state:

  • βœ… Transaction validation and execution
  • βœ… Block creation and signing
  • βœ… Genesis block creation
  • βœ… Block verification
  • βœ… Block hashing for chain linking
  • βœ… Order matching during finalization
  • βœ… Comprehensive test suite (10 block tests)

What's Next

Phase 5: Firebase Backend

  • Cloud Functions (submitTransaction, processBlock)
  • Firestore schema and collections
  • Distributed locking for block processing
  • Mempool management
  • Genesis block deployment

Phase 6: Browser Client

  • Wallet UI (key generation and management)
  • Blockchain explorer
  • Transaction submission
  • Real-time blockchain updates

Quick Start

Prerequisites

  • Node.js 18+
  • npm

Install Dependencies

npm install

Run Tests

npm test

Usage Example

import { generateKeypair, signTransaction } from './src/crypto/index.js';
import { validateTransaction } from './src/transactions/index.js';

// Generate a wallet
const wallet = generateKeypair();
console.log('Address:', wallet.address);

// Create a transaction
const tx = {
  transaction_type: 'TOKEN_TRANSFER',
  sender_address: wallet.address,
  recipient_address: '02...',
  amount: 100,
  nonce: 1,
  timestamp: new Date().toISOString()
};

// Sign it
const signature = await signTransaction(tx, wallet.privateKey);
const signedTx = { ...tx, sender_signature: signature };

// Validate against blockchain state
const state = {
  balances: { [wallet.address]: 1000 },
  nonces: { [wallet.address]: 0 },
  fee_schedule: { token_transfer_fee: 0.01 },
  // ... other state
};

const result = validateTransaction(signedTx, state);
if (result.valid) {
  console.log('Transaction is valid!');
} else {
  console.error('Invalid:', result.error);
}

Architecture

Technology Stack

  • Cryptography: @noble/secp256k1, @noble/hashes
  • Backend: Firebase Cloud Functions (2nd gen), Firestore
  • Client: Vanilla JavaScript (Web Crypto API)
  • Testing: Jest

Design Principles

  1. Centralized Processing, Decentralized Ecosystem

    • Each operator processes transactions serially for speed
    • Multiple competing operators create decentralization
  2. Portable Identity

    • Same cryptographic keys work everywhere
    • Users own their private keys
  3. Tamper-Proof History

    • Users save signed blocks
    • Can prove if operator modifies history
  4. Market Competition

    • Bad operators lose users
    • Good operators attract adoption
  5. Simplicity

    • Non-Turing-complete (fixed transaction types)
    • Easy to audit and verify

Documentation

Use Cases

Service Provider Reputation

Uber drivers, Etsy sellers, and freelancers carry ratings across platforms.

Driver on Lyft β†’ Earns 4.9β˜… rating β†’ Applies to Uber β†’
Full rating history visible β†’ Fast-tracked approval

Prediction Markets

Track forecasting accuracy across markets and platforms.

User predicts 10 events β†’ 8 correct β†’
Verifiable 80% accuracy β†’ Consulting opportunities

Professional Credentials

Verifiable work history and peer endorsements.

Developer earns reputation on Platform A β†’
Switches to Platform B β†’ Reputation follows

Project Structure

cipherblock/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ crypto/                      βœ… Complete
β”‚   β”‚   β”œβ”€β”€ index.js                 # Main exports
β”‚   β”‚   β”œβ”€β”€ keys.js                  # Key management
β”‚   β”‚   β”œβ”€β”€ signing.js               # Signing/verification
β”‚   β”‚   β”œβ”€β”€ keys.test.js             # Tests
β”‚   β”‚   β”œβ”€β”€ signing.test.js          # Tests
β”‚   β”‚   └── README.md                # Crypto documentation
β”‚   β”œβ”€β”€ transactions/                βœ… Complete
β”‚   β”‚   β”œβ”€β”€ index.js                 # Main exports
β”‚   β”‚   β”œβ”€β”€ types.js                 # Transaction types & schemas
β”‚   β”‚   β”œβ”€β”€ validator.js             # Validation logic
β”‚   β”‚   β”œβ”€β”€ validator.test.js        # Tests
β”‚   β”‚   └── README.md                # Validation documentation
β”‚   β”œβ”€β”€ state/                       βœ… Complete
β”‚   β”‚   β”œβ”€β”€ index.js                 # Main exports
β”‚   β”‚   β”œβ”€β”€ manager.js               # State management logic
β”‚   β”‚   β”œβ”€β”€ manager.test.js          # Tests
β”‚   β”‚   └── README.md                # State documentation
β”‚   └── blocks/                      βœ… Complete
β”‚       β”œβ”€β”€ index.js                 # Main exports
β”‚       β”œβ”€β”€ processor.js             # Block processing logic
β”‚       β”œβ”€β”€ processor.test.js        # Tests
β”‚       └── README.md                # Block documentation
β”œβ”€β”€ cipherblock-functional-spec.md   # System requirements
β”œβ”€β”€ cipherblock-tech-spec.md         # Implementation spec
β”œβ”€β”€ package.json
β”œβ”€β”€ jest.config.js
└── README.md                        # This file

Testing

# Run all tests
npm test

# Watch mode
npm run test:watch

Current Test Results:

Test Suites: 5 passed, 5 total
Tests:       80 passed, 80 total
Time:        ~1s

Security

Private Keys

  • Generated client-side
  • Never transmitted to operator
  • User responsible for storage
  • Production: encrypt before storing

Signatures

  • All transactions signed by sender
  • All blocks signed by operator
  • Tamper detection via saved blocks
  • Replay prevention via nonces

Verification

  • Anyone can verify signatures
  • Anyone can reconstruct state from genesis
  • Operator cannot forge signatures

Contributing

This is currently a personal project. Contributions, suggestions, and feedback are welcome!

License

MIT

Roadmap

  • Phase 1: Core Cryptography
  • Phase 2: Transaction Validation
  • Phase 3: State Management
  • Phase 4: Block Processing Engine
  • Phase 5: Firebase Backend
  • Phase 6: Browser Client
  • Phase 7: Production Deployment

Built with ❀️ for portable reputation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published