hyphae_engine/proof/
mod.rs1mod codec;
6mod model;
7mod verify;
8
9pub use model::{
10 MAX_RESULT_PROOF_BYTES, ProofAnchor, ProofError, ProvenOperation, ProvenResult,
11 RESULT_PROOF_FORMAT_VERSION, ResultProof, ResultProofArtifact, VerificationLimits,
12 VerificationReport,
13};
14pub use verify::{read_result_proof, verify_result_proof, write_result_proof};
15
16use hyphae_query::{Query, QueryResult, Record};
17use hyphae_storage::SnapshotInfo;
18
19use self::codec::{decode_proof, encode_proof, finalize_proof};
20
21impl ResultProof {
22 pub fn for_get(
28 snapshot: &SnapshotInfo,
29 key: Vec<u8>,
30 result: Option<Record>,
31 ) -> Result<Self, ProofError> {
32 finalize_proof(
33 ProofAnchor::from_snapshot(snapshot),
34 ProvenOperation::Get { key },
35 ProvenResult::Get(result),
36 )
37 }
38
39 pub fn for_query(
46 snapshot: &SnapshotInfo,
47 query: Query,
48 result: QueryResult,
49 ) -> Result<Self, ProofError> {
50 finalize_proof(
51 ProofAnchor::from_snapshot(snapshot),
52 ProvenOperation::Query(query),
53 ProvenResult::Query(result),
54 )
55 }
56
57 pub fn to_bytes(&self) -> Result<Vec<u8>, ProofError> {
64 encode_proof(self)
65 }
66
67 pub fn from_bytes(encoded: &[u8]) -> Result<Self, ProofError> {
74 decode_proof(encoded)
75 }
76}