Module utils

Source

Modules§

field_as_string

Structs§

DistributedLock
A distributed lock implementation using Redis SET NX EX pattern.
EncryptedData
Encrypted data container that holds the nonce and ciphertext
EncryptionContext
Provides task-local context for AAD during encryption/decryption operations.
FieldEncryption
Main encryption service for field-level encryption
LockGuard
A guard that represents an acquired distributed lock.
RedisConnections
Holds separate connection pools for read and write operations.

Enums§

AddressDerivationError
DerError
Ed25519Error
EncryptionError
EthereumJsonRpcError
Ethereum-specific JSON-RPC error codes (EIP-1474)
Secp256k1Error
StandardJsonRpcError
Standard JSON-RPC 2.0 error codes

Functions§

base64_decode
base64_encode
base64_url_decode
base64_url_encode
calculate_intrinsic_gas
Calculates the intrinsic gas for a given transaction
calculate_scheduled_timestamp
Calculates a future timestamp by adding delay seconds to the current time
check_authorization_header
Checks if the authorization header in the request matches the expected API key.
create_secure_redirect_policy
Creates a secure redirect policy that only allows HTTP to HTTPS upgrades on the same host.
decrypt_sensitive_field
Decrypts sensitive data from base64 format
decrypt_sensitive_field_auto
Decrypts sensitive data with automatic version detection
derive_ethereum_address_from_der
Derive EVM address from the DER payload.
derive_ethereum_address_from_pem
Derive EVM address from the PEM string.
derive_solana_address_from_der
Derive Solana address from DER/SPKI encoded Ed25519 public key. Solana addresses are base58-encoded Ed25519 public keys.
derive_solana_address_from_pem
Derive Solana address from a PEM-encoded public key.
derive_stellar_address_from_der
Derive Stellar address from DER/SPKI encoded Ed25519 public key. Stellar addresses use StrKey encoding (G prefix for public accounts).
derive_stellar_address_from_pem
Derive Stellar address from a PEM-encoded public key. Stellar uses Ed25519 keys and addresses are encoded with StrKey format (G prefix for accounts).
deserialize_option_secret_string
Helper function to deserialize optional secrets from encrypted base64 storage.
deserialize_optional_u64
deserialize_optional_u128
deserialize_optional_u128_as_number
Deserialize optional u128 from number
deserialize_secret_string
Helper function to deserialize secrets from encrypted base64 storage.
deserialize_secret_vec
Helper function to deserialize secrets from encrypted base64 storage.
deserialize_u64
deserialize_u128
deserialize_u128_as_number
Deserialize u128 from number (non-optional)
encrypt_sensitive_field
Encrypts sensitive data if encryption is configured, otherwise returns base64-encoded plaintext
encrypt_sensitive_field_with_aad
Encrypts sensitive data with AAD (Additional Authenticated Data)
extract_ed25519_public_key_from_der
Extract raw 32-byte Ed25519 public key from DER/SPKI encoded format.
extract_public_key_from_der
Extract raw 64-byte key from DER encoded key.
generate_encryption_key
Utility function to generate a new encryption key
generate_uuid
Generate a new UUID.
get_encryption
Gets the global encryption instance
get_evm_default_gas_limit_for_tx
Gets the default gas limit for a given transaction
get_resubmit_timeout_for_speed
Gets the resubmit timeout for a given speed Returns the timeout in milliseconds based on the speed:
get_resubmit_timeout_with_backoff
Calculates the resubmit age with exponential backoff
initialize_redis_connections
Initializes Redis connection pools for both primary and reader endpoints.
is_retriable_error_code
Check if a JSON-RPC error code represents a retriable error.
log_service_info
Logs service information at startup
map_provider_error
Maps provider errors to appropriate JSON-RPC error codes and messages.
mask_url
Masks a URL by showing only the scheme and host, hiding the path and query parameters.
minutes_ms
Converts minutes to milliseconds
recover_public_key
Recover v point from a signature and from the message contents
recover_public_key_from_hash
Recovers the v value from a signature for a pre-hashed message. The hash parameter is already a 32-byte digest, not raw bytes.
sanitize_error_description
Sanitizes provider error descriptions to prevent exposing internal details.
sanitize_url_for_error
Sanitizes a URL for error messages by only showing scheme, host, and port
serialize_option_secret_string
Helper function to serialize optional secrets as encrypted base64 for storage.
serialize_optional_u128
serialize_optional_u128_as_number
serialize_secret_string
Helper function to serialize secrets as encrypted base64 for storage.
serialize_secret_vec
Helper function to serialize secrets as encrypted base64 for storage.
serialize_u128
serialize_u128_as_number
Serialize u128 as number (non-optional)
unsafe_generate_random_private_key
validate_safe_url
Validates an RPC URL against security policies