PackX
PackX is a Rust library for cryptographically committing 128-byte data segments to a public key. Designed for TAPEDRIVE, it requires node operators to store unique nonce values derived from their pubkey instead of the actual data, while enabling verifiable reconstruction with a specified difficulty.
Usage
solve(pubkey, data, difficulty) -> Option<Solution>- Generate a solution containing a u64 bump, 16 u8 seeds, and 128 u8 nonces for a 128-byte data segment, meeting the specified difficulty (leading zeros in the hash of the serialized solution).verify(pubkey, data, solution, difficulty) -> bool- Verify the solution against the public key, data segment, and difficulty.unpack(pubkey, solution) -> [u8; 128]- Reconstruct the original data from the solution and public key.
Example
use ;
use thread_rng;
let mut rng = thread_rng;
let mut pubkey = ;
let mut data = ;
rng.fill_bytes;
rng.fill_bytes;
let difficulty = 8; // Example difficulty (8 leading zeros in solution hash)
// Find a solution that matches the data and meets the difficulty
let solution = solve.expect;
// Verify the solution
assert!;
// Reconstruct the original data
let unpacked_data = unpack;
assert_eq!;
Notes
- Storage overhead:
152 bytesper128-byte segment(~1.1875:1 ratio). - Difficulty: The difficulty is the number of leading zeros in the Keccak256 hash of the serialized solution (152 bytes). Higher difficulties require more computation to find a valid solution.
- Parallelization: The library supports parallel nonce searches via
find_nonceandsolve_with_seed, which can be used with libraries like Rayon for performance optimization. - Solana Compatibility: The library uses a
compute_hashfunction that supports bothSolana’s keccak::hashv(with the solana feature) and thesha3crate for non-Solana environments.