algenta-crypto

Cryptography and hashing kernels. Compiled Mojo, loaded in-process.

10 modules · 55 functions · CPU

Get started

pip install kernels torch
from kernels import get_kernel

kernel = get_kernel(
    "thyn-ai/algenta-crypto",
    version=1,
    backend="cpu",
    trust_remote_code=["thyn-ai/algenta-crypto"],
)
kernel.crypto.crc32.crc32_hex("hello")  # -> "3610a686"  CRC-32 as hex

backend="cpu" selects the CPU build. On a Mac the loader otherwise looks for a Metal build, which this family does not ship. trust_remote_code names the repositories you allow; Hugging Face's trusted publishers load without it.

Plain Python in, plain Python out. Lists, tuples, buffers and tensors are accepted wherever the contract expects a list; structured results are dictionaries. Some functions take a list and the number of elements to use from it, which may not exceed the list's length; multi-dimensional data is passed flattened, row-major, with its dimensions. Functions that update an argument do so in place, as help() says. Every call is checked against the published contract before it reaches native code. An invalid call raises KernelError with a stable code, never a crash.

Any function can also be called by name, with args as a list or a dict of parameter names:

kernel.execute("crypto.aes_sbox", "add_round_key", [...])

What's inside

Module Functions What it does
crypto.aes_sbox 8 AES core steps: S-box and inverse S-box lookups, SubBytes, ShiftRows, key mixing by XOR
crypto.base64 4 Base64 encoding and decoding (RFC 4648): standard with padding, and URL-safe without
crypto.chacha20 8 ChaCha20 stream cipher: 64-byte keystream blocks and XOR encryption and decryption of bytes
crypto.crc32 3 CRC-32 checksums (zlib polynomial) as integers or hex, and combining two checksums
crypto.hash_chain 9 Hash chains and Merkle trees over a non-cryptographic FNV-1a style hash: roots, proofs, checks
crypto.hmac 2 HMAC-SHA256 message authentication codes (RFC 2104) with constant-time verification
crypto.pbkdf2 7 PBKDF2 key derivation with HMAC-SHA256 (RFC 2898), plus SHA-256 and HMAC over raw bytes
crypto.uuid 2 Random version 4 UUIDs (RFC 4122) as a dashed 36-character string or 32 hex characters
feature_hashing 4 Hashing trick for categorical and text features: seeded FNV-1a buckets, signs, collision odds
perceptual_hash 8 Perceptual image hashes: average, difference and DCT hashes, Hamming distance, duplicate check

kernel.CONTRACT holds every signature, including the length rules for list arguments; help(kernel.feature_hashing) documents each function.

Requirements

  • Apple silicon: macOS 15 or later for the CPU build.
  • Linux arm64 and x86-64, glibc 2.35 or later.
  • kernels 0.17 or later and PyTorch 2.5 to 2.14. PyTorch has to be installed: the loader picks the build for your PyTorch version. The kernel itself never imports it.

Windows is not supported.

Notes

Calls into one kernel instance run one at a time; use processes for parallelism. Runtime state does not survive fork(); start worker processes with spawn.

License

Algenta Community License 1.1 (LICENSE). Free for personal, research and open-source use, and for internal use at organizations with fewer than 50 employees and under $5M in annual revenue. Beyond that, a commercial license is required: https://algenta.ai/pricing.

Enforced in the compiled library, not just in this text: one concurrent native worker per device (ABI §9). A second process, family or thread waits its turn rather than running in parallel. That is the Community licence's worker floor made real; parallel execution comes with a commercial license.

Support

Generally Available on the platforms listed under Requirements. Within v1, functions are only added; removals or signature changes ship as v2. Platforms, accelerators and PyTorch releases not listed are not supported. Documentation: https://docs.algenta.ai (the kernels guide: https://docs.algenta.ai/guides/kernels-on-hugging-face). Community: https://discord.gg/w8NDsph9an or this repository's Community tab. Commercial licences and support: https://algenta.ai/pricing.

Downloads last month
2
algenta
mojo
cpu
other
Torch
2.14
OS
macoslinux
Arch
x86_64aarch64