| Crates.io | northroot-proof-engine |
| lib.rs | northroot-proof-engine |
| version | 0.3.2 |
| created_at | 2025-11-07 03:16:45.095977+00 |
| updated_at | 2025-11-07 04:23:20.30604+00 |
| description | Core proof computation and validation library for PoSH (Proof of Shape) and PoX (Proof of Execution) |
| homepage | |
| repository | https://github.com/Northroot-Labs/northroot-engine |
| max_upload_size | |
| id | 1921097 |
| size | 245,378 |
Core proof computation and validation library for the Northroot Proof system.
The Northroot Proof Engine provides foundational cryptographic and validation primitives for the modular proof architecture:
Add to your Cargo.toml:
[dependencies]
northroot-proof-engine = "0.3.0"
use northroot_proof_engine::{compute_sha256, validate_trace_id};
// Compute SHA-256 hash
let hash = compute_sha256("Hello, world!");
println!("Hash: {}", hash);
// Validate trace ID
match validate_trace_id("tr_01H1234567890") {
Ok(_) => println!("Valid trace ID"),
Err(e) => println!("Invalid: {}", e),
}
The engine includes a CLI tool for demonstrations and validation:
# Run end-to-end workflow demo
cargo run --bin northroot-cli -- demo workflow
# Benchmark hash operations
cargo run --bin northroot-cli -- bench hash
# Validate a proof JSON file
cargo run --bin northroot-cli -- validate tests/golden/pox_span_commitment.json
See CLI Guide for more details.
use northroot_proof_engine::{
compute_span_commitment_hash, sign_span_commitment, verify_span_commitment_signature,
ArtifactRef, MethodRef, SpanCommitment, SpanStatus,
};
use ed25519_dalek::SigningKey;
use rand::rngs::OsRng;
// Create a span commitment
let commitment = SpanCommitment {
schema_version: "proof.v2".to_string(),
trace_id: "tr_01H1234567890".to_string(),
span_id: "sp-0001".to_string(),
method_ref: MethodRef { /* ... */ },
data_shape_hash: "sha256:...".to_string(),
span_shape_hash: "sha256:...".to_string(),
inputs: vec![],
outputs: vec![],
start_time: "2025-11-06T12:00:00.000Z".to_string(),
end_time: "2025-11-06T12:00:00.042Z".to_string(),
status: SpanStatus::OK,
meta: None,
};
// Sign the commitment
let mut csprng = OsRng;
let signing_key = SigningKey::generate(&mut csprng);
let signature = sign_span_commitment(&commitment, &signing_key, "did:key:zExecutor".to_string())?;
// Verify the signature
let verifying_key = signing_key.verifying_key();
let verified = verify_span_commitment_signature(
&commitment,
&signature,
verifying_key.as_bytes(),
)?;
The engine is optimized for deterministic, fast hash computation and canonicalization. Typical performance characteristics:
Run benchmarks with:
cargo bench
Or use the CLI for quick performance testing:
cargo run --bin northroot-cli -- bench hash
See Benchmarks for detailed performance data.
The northroot-cli tool provides several commands:
demo workflow - Demonstrates end-to-end PoSH → PoX workflowbench hash - Benchmarks hash and canonicalization operationsvalidate <file> - Validates proof JSON filesSee CLI Guide for complete documentation.
Current: v0.3.0
This version includes CLI tool, enhanced testing, and improved documentation. Breaking changes will require a major version bump.
# Install git hooks (run once)
./scripts/setup-hooks.sh
Automatically runs on commit:
cargo fmt)Automatically runs before push:
cargo clippy)cargo test)cargo build --release)CHANGELOG.md with changes./scripts/release.sh <version>
# Example: ./scripts/release.sh 0.2.1
git push origin main
git push origin v<version>
GitHub Actions will automatically:
Note: You'll need to set the CRATES_IO_TOKEN secret in GitHub repository settings.
MIT License - see LICENSE file for details.