1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Schema identity for payloads.
/// Prefix for sedimentree types.
pub const SEDIMENTREE_PREFIX: = *b"ST";
/// Prefix for subduction types.
pub const SUBDUCTION_PREFIX: = *b"SU";
/// Schema identity tag.
///
/// This trait provides the schema header that identifies a type
/// in the wire format. It's shared between encoding and decoding.
///
/// # Discriminant
///
/// Types that share a schema (e.g., multiple signed variants within
/// one protocol) use [`DISCRIMINANT`](Self::DISCRIMINANT) to
/// distinguish themselves. The discriminant is included in the
/// [`Signed<T>`] wire bytes between the schema header and the issuer,
/// making it part of the signed region. This prevents tag-swapping
/// attacks where a valid signature is reused for a different variant.
///
/// The combination `SCHEMA || DISCRIMINANT` must be globally unique
/// across all signed types.
///
/// [`Signed<T>`]: https://docs.rs/subduction_crypto/latest/subduction_crypto/signed/struct.Signed.html