ic_auth_types 0.9.1

Shared Rust data types, byte wrappers, and deterministic CBOR helpers for IC-Auth.
Documentation

ic_auth_types

License Crates.io Test Docs.rs Latest Version

IC-Auth is a web authentication system based on the Internet Computer.

ic_auth_types provides the shared Rust data model for IC-Auth: delegation records, compact wire forms, Base64URL byte wrappers, XID identifiers, and CBOR helpers used by signers and verifiers.

Features

  • Delegation, SignedDelegation, SignInResponse, and compact p/e/t wire forms.
  • ByteBufB64, ByteArrayB64, and BytesB64 for binary fields that become Base64URL strings in JSON and byte strings in CBOR.
  • Xid, a compact 12-byte, lexicographically sortable identifier with optional interoperability with the xid crate.
  • CandidType and Serde support for IC canister interfaces, JSON APIs, and CBOR payloads.
  • cbor_into_vec, cbor_from_slice, and deterministic RFC 8949 CBOR helpers for signed or hashed payloads.

Installation

Add this to your Cargo.toml:

[dependencies]
ic_auth_types = "0.9"

Enable interoperability with the original xid crate:

[dependencies]
ic_auth_types = { version = "0.9", features = ["xid"] }

Example

use candid::Principal;
use ic_auth_types::{
    ByteBufB64, Delegation, DelegationCompact, deterministic_cbor_into_vec,
};

fn main() -> Result<(), String> {
    let delegation = Delegation {
        pubkey: ByteBufB64::from(vec![1, 2, 3]),
        expiration: 1_900_000_000_000_000_000,
        targets: Some(vec![Principal::management_canister()]),
    };

    let compact: DelegationCompact = delegation.into();
    let bytes = deterministic_cbor_into_vec(&compact)?;
    assert!(!bytes.is_empty());

    Ok(())
}

Feature Flags

  • default: no optional dependencies.
  • xid: enables conversion to and from xid::Id.
  • full: currently aliases xid.

Related Crates

  • ic_auth_verifier: signature, envelope, delegation-chain, and deep-link verification utilities.

License

Copyright © 2024-2026 LDC Labs.

ldclabs/ic-auth is licensed under the MIT License. See LICENSE for the full license text.