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/// Submitted ECDSA/secp256k1 signature metadata, never a trusted key selection.
9#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct RootSignatureMaterial {
11 /// Submitted key lookup hint.
12 pub key_name: String,
13 /// Ordered derivation components, without normalization.
14 pub derivation_path: Vec<Vec<u8>>,
15 /// Submitted SEC1 key bytes.
16 pub public_key: Vec<u8>,
17 /// Submitted compact signature, with no implied length or scalar validity.
18 pub signature: Vec<u8>,
19}
20
21/// Owned root authorization material; duplicated certificate/leaf fields remain distinct.
22#[derive(Clone, Debug, Eq, PartialEq)]
23pub struct RootDelegation {
24 /// Certificate committed by the claims' key-binding identity.
25 pub certificate: DelegationCertificate,
26 /// Submitted root batch header.
27 pub header: RootBatchHeader,
28 /// Submitted issuer authorization leaf, requiring certificate agreement.
29 pub leaf: DelegationLeaf,
30 /// Ordered sibling steps.
31 pub witness: Vec<MerkleStep>,
32 /// Submitted root signature material.
33 pub signature: RootSignatureMaterial,
34}
35
36/// Owned certified proof; successful construction authenticates nothing.
37#[derive(Clone, Debug, Eq, PartialEq)]
38pub struct CertifiedProofMaterial {
39 /// Submitted root authorization.
40 pub delegation: RootDelegation,
41 /// Opaque IC signature/certificate/witness bytes.
42 pub issuer_signature_cbor: Vec<u8>,
43 /// Submitted issuer canister-signature DER key.
44 pub issuer_public_key_der: Vec<u8>,
45}
46
47/// Claimed proof variant, checked against independently protected enrollment.
48#[derive(Clone, Debug, Eq, PartialEq)]
49pub enum CredentialProof {
50 /// Root-delegated IC canister signature.
51 Certified(Box<CertifiedProofMaterial>),
52 /// Opaque Ed25519 signature bytes requiring strict verification.
53 Ed25519(Vec<u8>),
54}
55
56/// Untrusted credential retaining the exact received signed claims bytes.
57#[derive(Clone, Debug, Eq, PartialEq)]
58pub struct Credential {
59 /// Canonical claims candidate; never decode/re-encode during projection.
60 pub claims: Vec<u8>,
61 /// Submitted proof; the host selects the verifier from protected enrollment.
62 pub proof: CredentialProof,
63}