penumbra_sdk_txhash/auth_hash.rs
1/// A hash of a transaction's _authorizing data_, describing both its effects on
2/// the chain state as well as the cryptographic authorization of those effects.
3///
4/// In practice this is simply a hash of the `TransactionBody`.
5///
6/// The transaction's binding signature is formed over the transaction's
7/// `AuthHash`. Because the binding signature is formed using the randomness
8/// for the balance commitments for each action, this prevents replaying proofs
9/// from one transaction to another without knowledge of the openings of the
10/// balance commitments, binding the proofs to the transaction they were
11/// originally computed for.
12#[derive(Clone, Copy, Eq, PartialEq)]
13pub struct AuthHash(pub [u8; 32]);
14
15impl std::fmt::Debug for AuthHash {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 f.debug_tuple("AuthHash")
18 .field(&hex::encode(self.0))
19 .finish()
20 }
21}
22
23impl AuthHash {
24 pub fn as_bytes(&self) -> &[u8] {
25 &self.0[..]
26 }
27}
28
29pub trait AuthorizingData {
30 fn auth_hash(&self) -> AuthHash;
31}