| Crates.io | saorsa-logic |
| lib.rs | saorsa-logic |
| version | 0.1.0 |
| created_at | 2025-12-14 18:27:18.150391+00 |
| updated_at | 2025-12-14 18:27:18.150391+00 |
| description | Pure logic crate for Saorsa network - zkVM compatible, no_std |
| homepage | https://github.com/dirvine/saorsa-logic |
| repository | https://github.com/dirvine/saorsa-logic |
| max_upload_size | |
| id | 1984896 |
| size | 82,317 |
Pure verification logic for the Saorsa network, designed for zkVM compatibility.
saorsa-logic extracts the core verification logic from the Saorsa network into a no_std compatible crate. This enables:
┌─────────────────────────────────────────────────────────────────┐
│ saorsa-node │
│ (CLI, config, auto-upgrade) │
└────────────────────────────┬────────────────────────────────────┘
│
┌────────────────────────────▼────────────────────────────────────┐
│ saorsa-core │
│ (Networking, DHT, trust, storage) │
└────────────────────────────┬────────────────────────────────────┘
│
┌────────────────────────────▼────────────────────────────────────┐
│ saorsa-logic │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ attestation │ │ data │ │ merkle │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
┌────────▼────────┐
│ zkVM (SP1) │
│ Proves logic │
└─────────────────┘
Implements Entangled Attestation - binding node identity to software:
use saorsa_logic::attestation::{derive_entangled_id, verify_entangled_id};
let public_key = [0u8; 1952]; // ML-DSA-65 public key
let binary_hash = [1u8; 32]; // BLAKE3 of binary
let nonce = 12345u64;
// Derive EntangledId
let id = derive_entangled_id(&public_key, &binary_hash, nonce);
// Verify
assert!(verify_entangled_id(&id, &public_key, &binary_hash, nonce));
Content-addressing and verification:
use saorsa_logic::data::{compute_content_hash, verify_content_hash};
let data = b"Hello, Saorsa!";
let hash = compute_content_hash(data);
assert!(verify_content_hash(data, &hash).is_ok());
Merkle tree construction and proof verification:
use saorsa_logic::merkle::{build_tree_root, generate_proof, hash_leaf};
let leaves: Vec<[u8; 32]> = (0..4).map(|i| hash_leaf(&[i])).collect();
let root = build_tree_root(&leaves);
let proof = generate_proof(&leaves, 0).unwrap();
assert!(proof.verify(&leaves[0], &root).is_ok());
// In your SP1 guest program
use saorsa_logic::attestation::derive_entangled_id;
fn main() {
// Read inputs
let public_key: Vec<u8> = sp1_zkvm::io::read();
let binary_hash: [u8; 32] = sp1_zkvm::io::read();
let nonce: u64 = sp1_zkvm::io::read();
// Compute (this is what gets proven)
let entangled_id = derive_entangled_id(&public_key, &binary_hash, nonce);
// Commit to public outputs
sp1_zkvm::io::commit(&entangled_id);
sp1_zkvm::io::commit(&binary_hash);
}
std - Enable standard library (for native execution)alloc - Enable heap allocationzkvm - Generic zkVM optimizationssp1 - SP1-specific optimizationsrisc0 - RISC Zero-specific optimizationstest-utils - Testing utilitiesThis crate is no_std by default:
# no_std (zkVM)
saorsa-logic = "0.1"
# With std (native)
saorsa-logic = { version = "0.1", features = ["std"] }
MIT OR Apache-2.0