Skip to main content

Crate ic_auth_types

Crate ic_auth_types 

Source
Expand description

Shared data types and serialization helpers for IC-Auth.

This crate contains the wire-facing structures used by the Rust verifier, the TypeScript SDK, and applications that exchange IC-Auth delegations or signed envelopes. Byte fields use Base64URL strings in human-readable formats such as JSON while preserving compact byte strings in binary formats such as CBOR.

The CBOR helpers wrap cbor2 and provide deterministic RFC 8949 encoding for values that are signed or hashed. cbor_from_slice also contains the compatibility path needed by IC/Candid-specific types such as candid::Principal.

§Examples

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

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 bytes = deterministic_cbor_into_vec(&delegation).unwrap();
assert!(!bytes.is_empty());

Structs§

ByteArray
Wrapper around [u8; N] to serialize and deserialize efficiently.
ByteArrayB64
Wrapper around [u8; N] to serialize and deserialize efficiently. If the serialization format is human readable (formats like JSON and YAML), it will be encoded in Base64URL. Otherwise, it will be serialized as a byte array.
ByteBuf
Wrapper around Vec<u8> to serialize and deserialize efficiently.
ByteBufB64
Wrapper around Vec<u8> to serialize and deserialize efficiently. If the serialization format is human readable (formats like JSON and YAML), it will be encoded in Base64URL. Otherwise, it will be serialized as a byte array.
Bytes
Wrapper around [u8] to serialize and deserialize efficiently.
BytesB64
Wrapper around borrowed/owned byte slice to serialize and deserialize efficiently. If the serialization format is human readable (formats like JSON and YAML), it will be encoded in Base64URL. Otherwise, it will be serialized as a byte array.
Delegation
A delegation from one key to another.
DelegationCompact
DelegationCompact is a compact representation of a Delegation. It is used to reduce the size of the delegation when it is serialized.
SignInResponse
SignedDelegation
SignedDelegation is a Delegation that has been signed by an Identity.
SignedDelegationCompact
SignedDelegationCompact is a compact representation of a SignedDelegation. It is used to reduce the size of the delegation when it is serialized.
Xid
Represents a unique identifier with 12 bytes. Based on the xid. See: https://github.com/rs/xid

Constants§

EMPTY_XID
A constant representing an empty XID (all zeros)
RAW_LEN
Length of the raw XID byte array

Functions§

cbor_from_slice
Deserializes one CBOR item from a byte slice.
cbor_into
Serializes a value as CBOR into a writer.
cbor_into_vec
Serializes a value as CBOR into a new Vec<u8>.
deterministic_cbor_into
Serializes a value into a writer using RFC 8949 deterministic CBOR.
deterministic_cbor_into_vec
Serializes a value into a new Vec<u8> using RFC 8949 deterministic CBOR.