pub struct CalculationReceipt {
pub receipt_id: Uuid,
pub input_hash: String,
pub output_hash: String,
pub ruleset_id: String,
pub ruleset_version: String,
pub factor_dataset_id: String,
pub factor_dataset_version: String,
pub factor_set_hash: Option<String>,
pub computed_at: DateTime<Utc>,
pub jws: Option<String>,
}Expand description
Proof-of-calculation envelope emitted by every calculator function.
Carries enough information to reproduce or audit the result: both inputs
and numeric outputs are JCS-hashed (RFC 8785) so an auditor can verify the
same inputs produce the same outputs, and the exact ruleset + factor dataset
versions are recorded. The receipt may be signed by the vault via
seal_with_jws after calling
canonical_bytes_for_signing.
Intended to be stored alongside the computed value in the proof-bound store.
Fields§
§receipt_id: UuidUnique receipt identifier (UUIDv7, time-sortable).
input_hash: StringSHA-256 of the JCS (RFC 8785) canonical JSON of the calculator inputs.
output_hash: StringSHA-256 of the JCS (RFC 8785) canonical JSON of the numeric output values.
Empty string until populated via with_output_hash.
ruleset_id: StringMachine-readable identifier of the ruleset used.
ruleset_version: StringVersion of the ruleset (semver-shaped string).
factor_dataset_id: StringIdentifier of the factor dataset (empty if no factor provider was used).
factor_dataset_version: StringVersion of the factor dataset (empty if no factor provider was used).
factor_set_hash: Option<String>SHA-256 of the full factor table at calculation time.
None when the calculation did not use a FactorProvider.
computed_at: DateTime<Utc>UTC timestamp when the calculation ran.
jws: Option<String>JWS signature produced by the vault/engine after calculation.
None until the caller calls seal_with_jws.
Implementations§
Source§impl CalculationReceipt
impl CalculationReceipt
pub fn new( input_hash: impl Into<String>, ruleset_id: impl Into<String>, ruleset_version: impl Into<String>, ) -> Self
Sourcepub fn with_output_hash(self, hash: impl Into<String>) -> Self
pub fn with_output_hash(self, hash: impl Into<String>) -> Self
Bind the numeric output values to this receipt.
Sourcepub fn with_factor_provider(self, provider: &dyn FactorProvider) -> Self
pub fn with_factor_provider(self, provider: &dyn FactorProvider) -> Self
Attach factor-provider provenance to this receipt.
Sourcepub fn seal_with_jws(self, jws: String) -> Self
pub fn seal_with_jws(self, jws: String) -> Self
Attach a JWS signature produced by the external signing infrastructure.
Call after canonical_bytes_for_signing
to avoid signing the jws field itself.
Sourcepub fn canonical_bytes_for_signing(&self) -> Result<Vec<u8>, CalcError>
pub fn canonical_bytes_for_signing(&self) -> Result<Vec<u8>, CalcError>
JCS-canonical bytes of this receipt without the jws field.
Pass these bytes to the vault’s signing infrastructure, then call
seal_with_jws with the resulting
JWS to produce the final sealed receipt.
Trait Implementations§
Source§impl Clone for CalculationReceipt
impl Clone for CalculationReceipt
Source§fn clone(&self) -> CalculationReceipt
fn clone(&self) -> CalculationReceipt
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more