miden_core/program/request.rs
1//! Content-addressing for recursive proof packages.
2
3use super::domain::{PROOF_REQUEST_DOMAIN_ID, domain_selector};
4use crate::{Felt, Word, ZERO, chiplets::hasher};
5
6/// Domain tag for proof-request keys: the registered selector
7/// `(PROOF_REQUEST_DOMAIN_ID << 8) | 1` (see the [`domain`](super::domain) module).
8pub const PROOF_REQUEST_DOMAIN_TAG: Felt = domain_selector(PROOF_REQUEST_DOMAIN_ID, 1);
9
10/// Returns the advice-map key addressing a proof package for `claim_commitment` under the
11/// verifier identified by `verifier_root`.
12///
13/// The key is `H_tag(claim_commitment ‖ verifier_root)` (one rate block, domain-separated). It
14/// is a lookup address, not a trust anchor: the verifier re-checks the retrieved package against
15/// its statement, so a wrong package fails verification. Both inputs are program-owned rather
16/// than values taken from advice.
17pub fn proof_request_key(verifier_root: Word, claim_commitment: Word) -> Word {
18 // Absorb claim_commitment first so the MASM mirror needs a single word-swap to place the
19 // rate; the order is otherwise arbitrary (a domain-separated hash of the two words).
20 let mut preimage = [ZERO; 2 * 4];
21 preimage[0..4].copy_from_slice(claim_commitment.as_elements());
22 preimage[4..8].copy_from_slice(verifier_root.as_elements());
23 hasher::hash_elements_in_domain(&preimage, PROOF_REQUEST_DOMAIN_TAG)
24}