Expand description
Cryptographic receipt system for ggen operations.
This crate provides a production-ready receipt system with Ed25519 signatures for verifiable operation tracking. Receipts can be chained together to form an auditable trail of operations.
§Features
- Ed25519 digital signatures for cryptographic verification
- SHA-256 hashing for data integrity
- Receipt chaining with hash links
- Full serialization support with serde
- Comprehensive error handling
§Examples
§Creating and signing a receipt
use ggen_receipt::{Receipt, generate_keypair};
let (signing_key, verifying_key) = generate_keypair();
let receipt = Receipt::new(
"my-operation".to_string(),
vec!["input-hash-1".to_string()],
vec!["output-hash-1".to_string()],
None,
)
.sign(&signing_key)
.expect("Failed to sign receipt");
// Verify the signature
receipt.verify(&verifying_key).expect("Verification failed");§Building a receipt chain
use ggen_receipt::{Receipt, ReceiptChain, generate_keypair};
let (signing_key, verifying_key) = generate_keypair();
// Create genesis receipt
let genesis = Receipt::new(
"genesis-op".to_string(),
vec![],
vec![],
None,
)
.sign(&signing_key)
.expect("Failed to sign");
let mut chain = ReceiptChain::from_genesis(genesis.clone())
.expect("Failed to create chain");
// Add a linked receipt
let receipt2 = Receipt::new(
"second-op".to_string(),
vec![],
vec![],
None,
)
.chain(&genesis)
.expect("Failed to chain")
.sign(&signing_key)
.expect("Failed to sign");
chain.append(receipt2).expect("Failed to append");
// Verify the entire chain
chain.verify(&verifying_key).expect("Chain verification failed");Re-exports§
pub use chain::ReceiptChain;pub use envelope::payload_hash;pub use envelope::EnvelopeChain;pub use envelope::EnvelopeChainLink;pub use envelope::EnvelopeSignature;pub use envelope::PayloadRef;pub use envelope::Producer;pub use envelope::ReceiptEnvelope;pub use envelope::ENVELOPE_SCHEMA;pub use envelope::HASH_PREFIX;pub use envelope::SIGNATURE_ALGORITHM;pub use error::ReceiptError;pub use error::Result;pub use receipt::generate_keypair;pub use receipt::hash_data;pub use receipt::Receipt;
Modules§
- chain
- Receipt chain implementation for maintaining hash-linked receipts.
- envelope
- Receipt envelope (
chatmangpt.receipt.envelope.v1). - error
- Error types for the receipt system.
- receipt
- Receipt implementation with Ed25519 signatures.
Functions§
- create_
chained_ receipt - Convenience function to create a new receipt chained to a parent.