pd_cipher::crypto
Core cryptographic types and operations. Core cryptographic operations for token-based encryption.
This module provides the fundamental types and operations for working with tokenized and encrypted data in the PD.Cipher SDK.
Types
- [
Plaintext] - Represents a sequence of unencrypted tokens. PDContext- Context metadata for decrypting tokens.
Workflow
The typical encryption workflow is:
- Create a
PDCipher. - Generate or load a
Key. - Create tokenized data from your input.
- Call encryption methods to produce encrypted tokens and context.
- Store encrypted tokens and context separately for efficient ML inference.
- Call decryption methods with tokens and context to recover the original data.
Type Aliases
Token
Represents a single, unencrypted piece of data ready for encryption.
In the context of text processing, a token is typically a word, but it can be any meaningful unit of data. This is the raw input before encryption.
Usage in SDK
Tokens are the fundamental unit of data that PD.Cipher processes. They are:
- Input to encryption operations
- Classified as numeric or string types
- Processed through the tokenization pipeline
- Converted to deterministic cipher tokens
Examples
- Text tokens:
b"Alice",b"sends",b"money" - Numeric tokens:
b"123.45",b"1000" - Binary data: Any sequence of bytes representing structured data
pub type Token = ...
CipherToken
Represents a single, encrypted token.
This is the encrypted, deterministic representation that corresponds to a plaintext Token.
The same plaintext token always produces the same CipherToken, enabling pattern
preservation for machine learning applications.
Security Properties
- Deterministic: Same input → same output (for ML training)
- Encrypted: Content is cryptographically protected
- Truncated: Typically 8-16 characters vs 128-character raw hash
pub type CipherToken = ...