esdb_gater_crypto_nif (reckon_gater v1.3.0)

View Source

NIF acceleration for cryptographic operations (Enterprise Edition)

This module provides high-performance native implementations of compute-intensive cryptographic operations used in capability tokens.

Community vs Enterprise Edition

- Community Edition (hex.pm): NIF not available, pure Erlang fallbacks used - Enterprise Edition: Add reckon_nifs dependency for 5-10x faster NIFs

The NIF is optional and auto-detected at runtime. All operations have pure Erlang fallbacks in their respective modules (esdb_identity, etc.).

Enabling NIF Acceleration

Add reckon_nifs to your dependencies: {reckon_nifs, "0.1.0"}

The NIFs are automatically loaded when the reckon_nifs application starts.

Functions

- base58_encode/1: Base58btc encoding for DIDs (5-10x faster) - base58_decode/1: Base58btc decoding for DID parsing (5-10x faster) - match_resource_pattern/2: Resource URI pattern matching (3-5x faster)

Summary

Functions

Decode Base58 to binary

Encode binary to Base58 (Bitcoin alphabet)

Check if NIF acceleration is available

Match a resource pattern against a resource URI

Functions

base58_decode(Base58)

-spec base58_decode(binary()) -> {ok, binary()} | {error, term()}.

Decode Base58 to binary

Fast native implementation of Base58 decoding for DID parsing. Falls back to esdb_identity:base58_decode/1 if NIF unavailable.

base58_encode(Data)

-spec base58_encode(binary()) -> binary().

Encode binary to Base58 (Bitcoin alphabet)

Fast native implementation of Base58 encoding for DID generation. Falls back to esdb_identity:base58_encode/1 if NIF unavailable.

is_loaded()

-spec is_loaded() -> boolean().

Check if NIF acceleration is available

Returns true if the Rust NIF is loaded, false otherwise. Use this to check before calling NIF functions directly.

match_resource_pattern(Pattern, Resource)

-spec match_resource_pattern(binary(), binary()) -> boolean().

Match a resource pattern against a resource URI

Supports: - Exact match: Pattern equals Resource - Wildcard suffix: "esdb://realm/*" matches any path - Prefix match: "esdb://realm/orders-*" matches prefix