auths_verifier
Overview
auths_verifier provides the core logic necessary to verify the cryptographic signatures and validity of Auths Attestation objects.
Its key characteristic is its minimal dependency set, intentionally excluding heavy libraries like git2 or CLI frameworks like clap. This makes it suitable for use cases where the full auths_id context (including Git repository access) is unavailable or undesirable, such as:
- FFI Integration: Embedding verification logic into native mobile applications (iOS/Swift, Android/Kotlin) or other C-compatible environments.
- WASM Integration: Verifying attestations client-side in web browsers or other WebAssembly runtimes.
- Backend Services: Allowing servers to verify attestations without needing local Git checkouts.
- CI/CD Pipelines & Tools: Verifying attestations as part of automated checks.
Core Functionality
The primary entry point is the verify_with_keys function:
This function takes:
- An
Attestationstruct (deserialized from JSON or constructed otherwise). - The raw 32-byte Ed25519 public key of the issuer (the identity that created the attestation).
It performs the following checks:
- Checks if the
att.revokedflag is true. - Checks if
att.expires_atis in the past. - (Optionally, can be extended for timestamp skew checks).
- Verifies the
att.identity_signatureagainst a canonical representation of the attestation data using the providedissuer_pk_bytes. - Verifies the
att.device_signatureagainst the same canonical representation using theatt.device_public_keystored within the attestation struct itself. - It returns
Ok(())if all checks pass, or anErr(AttestationError)detailing the reason for failure.
Architecture / Key Components
- src/core.rs: Defines the core data structures (
Attestation,CanonicalAttestationData) and the canonicalization logic (canonicalize_attestation_data) required for consistent signature verification. src/types.rs: Defines common types likeDeviceDID.src/error.rs: Defines the AttestationError enum used for reporting verification failures.src/verify.rs: Contains the main verify_with_keys verification logic.src/ffi.rs: (If feature enabled) Contains the C-compatible Foreign Function Interface (extern "C"functions) for use by other languages.src/wasm.rs: (If feature enabled) Contains the WebAssembly bindings (#[wasm_bindgen]functions) for browser/JS usage.
Usage
use ;
use fs;
use hex;
// 1. Load attestation (e.g., from file)
let att_bytes = read?;
let att: Attestation = from_json?; // Use inherent method
// 2. Get issuer's public key bytes (e.g., from config, storage, or another source)
let issuer_pk_hex = "aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899";
let issuer_pk_bytes = decode?;
// 3. Verify
match verify_with_keys
FFI (C/Swift/Kotlin...)
(Requires building the crate as a cdylib)
-
Include Header: Include the generated
auths_verifier.hheader file. -
Prepare Data: Get the attestation JSON as a byte array (
const uint8_t*,size_t len) and the issuer's raw 32-byte public key (const uint8_t*,size_t len). -
Call Function:
#include "auths_verifier.h"
#include <stdint.h>
#include <stddef.h>
// Assume att_json_bytes, att_json_len, issuer_pk_bytes, issuer_pk_len are populated
int32_t result = ffi_verify_attestation_json;
if else
- Error Codes: Consult the
ERR_VERIFY_*constants defined inffi.rsand exported in the header for specific failure reasons.
WASM (JavaScript/Web)
(Requires building with wasm-pack and the wasm feature enabled)
- Import: Import the generated JavaScript module.
- Call Function:
import init from './pkg/auths_verifier.js'; // Adjust path
;
- Error Handling: The function throws a
JavaScripterror (derived fromJsValue) containing theAttestationErrormessage on failure.
Building
🦀 Standard Rust Build
This compiles the crate as a standard Rust library and binary for release.
⸻
🧩 FFI Build (Dynamic Library + Header)
- Ensure cdylib Configuration
Make sure your Cargo.toml contains the correct crate type:
[lib]
crate-type = ["rlib", "cdylib"]
- Install cbindgen
- Configure cbindgen.toml
Create a cbindgen.toml in the crate root.
- Generate Header File
- Build the Dynamic Library
The .dylib, .so, or .dll will be output in target/release/.
⸻
🌐 WASM Build
- Enable WASM Feature
Ensure your Cargo.toml includes:
[features]
default = []
wasm = ["wasm-bindgen"]
- Install
wasm-pack
- Build for Web or Node
Navigate to the crates/auths-verifier directory:
Web (for browser):
Node.js (optional):
This will generate a pkg/ directory containing the .wasm binary and corresponding JavaScript bindings.
⸻
🚀 Future Ideas
- Achieve #![no_std] compatibility (potentially using alloc) for minimal WASM builds.
- Provide more granular error codes via FFI for easier debugging.
- Expose helper functions (e.g. canonicalization, DID parsing) via FFI/WASM.
- Add FFI/WASM support for verifying revocation data structures independently.