ic_auth_protocol_types/credential.rs
1//! Owned, untrusted credential material shared by transport and verification.
2//!
3//! These records carry no codec, signature, enrollment or session behavior.
4//! Producers may construct invalid values; the selected verifier owns admission.
5
6use crate::{DelegationCertificate, DelegationLeaf, MerkleStep, RootBatchHeader};
7
8///
9/// RootSignatureMaterial
10///
11/// Submitted ECDSA/secp256k1 signature metadata, never a trusted key selection.
12///
13
14#[derive(Clone, Debug, Eq, PartialEq)]
15pub struct RootSignatureMaterial {
16 /// Submitted key lookup hint.
17 pub key_name: String,
18 /// Ordered derivation components, without normalization.
19 pub derivation_path: Vec<Vec<u8>>,
20 /// Submitted SEC1 key bytes.
21 pub public_key: Vec<u8>,
22 /// Submitted compact signature, with no implied length or scalar validity.
23 pub signature: Vec<u8>,
24}
25
26///
27/// RootDelegation
28///
29/// Owned root authorization material; duplicated certificate/leaf fields remain distinct.
30///
31
32#[derive(Clone, Debug, Eq, PartialEq)]
33pub struct RootDelegation {
34 /// Certificate committed by the claims' key-binding identity.
35 pub certificate: DelegationCertificate,
36 /// Submitted root batch header.
37 pub header: RootBatchHeader,
38 /// Submitted issuer authorization leaf, requiring certificate agreement.
39 pub leaf: DelegationLeaf,
40 /// Ordered sibling steps.
41 pub witness: Vec<MerkleStep>,
42 /// Submitted root signature material.
43 pub signature: RootSignatureMaterial,
44}
45
46///
47/// CertifiedProofMaterial
48///
49/// Owned certified proof; successful construction authenticates nothing.
50///
51
52#[derive(Clone, Debug, Eq, PartialEq)]
53pub struct CertifiedProofMaterial {
54 /// Submitted root authorization.
55 pub delegation: RootDelegation,
56 /// Opaque IC signature/certificate/witness bytes.
57 pub issuer_signature_cbor: Vec<u8>,
58 /// Submitted issuer canister-signature DER key.
59 pub issuer_public_key_der: Vec<u8>,
60}
61
62///
63/// CredentialProof
64///
65/// Claimed proof variant, checked against independently protected enrollment.
66///
67
68#[derive(Clone, Debug, Eq, PartialEq)]
69pub enum CredentialProof {
70 /// Root-delegated IC canister signature.
71 Certified(Box<CertifiedProofMaterial>),
72 /// Opaque Ed25519 signature bytes requiring strict verification.
73 Ed25519(Vec<u8>),
74}
75
76///
77/// Credential
78///
79/// Untrusted credential retaining the exact received signed claims bytes.
80///
81
82#[derive(Clone, Debug, Eq, PartialEq)]
83pub struct Credential {
84 /// Canonical claims candidate; never decode/re-encode during projection.
85 pub claims: Vec<u8>,
86 /// Submitted proof; the host selects the verifier from protected enrollment.
87 pub proof: CredentialProof,
88}