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§
- Byte
Array - Wrapper around
[u8; N]to serialize and deserialize efficiently. - Byte
Array B64 - 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. - Byte
BufB64 - 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. - Bytes
B64 - 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.
- Delegation
Compact - DelegationCompact is a compact representation of a
Delegation. It is used to reduce the size of the delegation when it is serialized. - Sign
InResponse - Signed
Delegation - SignedDelegation is a
Delegationthat has been signed by anIdentity. - Signed
Delegation Compact - 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§
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.