Skip to content

regolith-labs/verus-hash

Repository files navigation

Verus Hash Solana Implementation

This project implements the VerusHash v2.2 algorithm for use within the Solana blockchain environment. It consists of:

  1. verus crate: A Rust crate containing the core VerusHash logic, adapted to be compilable for both native host targets (using optimized intrinsics if available) and the Solana SBF (Solana Bytecode Format) target (using a portable C implementation).
  2. program crate: A Solana program (smart contract) written in Rust that exposes an instruction to verify a VerusHash solution on-chain. It uses the verus crate for the hashing logic.
  3. client crate: A command-line client application that interacts with the deployed Solana program. It uses the verus crate (native host version) to search for a valid nonce that satisfies a given difficulty target and then submits this solution to the on-chain program for verification.
  4. origin-impl directory: Contains the original C/C++ source code from the VerusCoin repository for reference.
  5. verus/c directory: Contains the C/C++ source code adapted for the Solana SBF environment (portable, no stdlib dependencies, etc.).

Development & Testing Workflow

The current development cycle involves building the on-chain program, deploying it to a local validator (or testnet/devnet), and then running the client to test the interaction.

Prerequisites:

  • Rust toolchain installed (rustup)
  • Solana CLI tool suite installed
  • A running Solana validator (e.g., solana-test-validator)

Steps:

  1. Build the Solana Program: Compile the program crate into the SBF bytecode.

    cargo build-sbf
    # This command compiles the program and places the output (`program.so`) in the `target/deploy/` directory.
    
  2. Deploy the Program: Deploy the compiled program to your target Solana cluster (local validator, devnet, etc.). You'll need the program's keypair (e.g., program/target/deploy/program-keypair.json generated by cargo build-sbf if it doesn't exist, or provide your own).

    Example using the default keypair location and deploying to localhost:

    # Make sure your Solana CLI is configured for the target cluster (e.g., localhost)
    # solana config set --url localhost
    
    # Deploy the program
    solana program deploy target/deploy/program.so --program-id program/target/deploy/program-keypair.json

    Note: Replace --program-id with the actual path to your program's keypair file if it differs.

    Take note of the Program ID output by the deploy command. You may need to update PROGRAM_ID constant in client/src/main.rs if it changes or if you are deploying with a specific ID.

  3. Build the Client: Navigate to the client directory and build the client application.

    cd client
    cargo build
  4. Run the Client: Execute the client application. It will connect to the RPC endpoint specified in client/src/main.rs (defaulting to localhost), search for a valid nonce using the native VerusHash implementation, and then send a transaction to the deployed program to verify the solution on-chain.

    cargo run

    The client will print output indicating whether the nonce search was successful and whether the on-chain verification passed or failed.

This cycle (modify code -> build program -> deploy -> build client -> run client) is repeated as needed during development and testing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published