• About Us
  • Disclaimer
  • Contact Us
  • Privacy Policy
Tuesday, June 9, 2026
mGrowTech
No Result
View All Result
  • Technology And Software
    • Account Based Marketing
    • Channel Marketing
    • Marketing Automation
      • Al, Analytics and Automation
      • Ad Management
  • Digital Marketing
    • Social Media Management
    • Google Marketing
  • Direct Marketing
    • Brand Management
    • Marketing Attribution and Consulting
  • Mobile Marketing
  • Event Management
  • PR Solutions
  • Technology And Software
    • Account Based Marketing
    • Channel Marketing
    • Marketing Automation
      • Al, Analytics and Automation
      • Ad Management
  • Digital Marketing
    • Social Media Management
    • Google Marketing
  • Direct Marketing
    • Brand Management
    • Marketing Attribution and Consulting
  • Mobile Marketing
  • Event Management
  • PR Solutions
No Result
View All Result
mGrowTech
No Result
View All Result
Home Al, Analytics and Automation

A Fresh Take on Function-Based Encryption

Josh by Josh
May 28, 2025
in Al, Analytics and Automation
0
A Fresh Take on Function-Based Encryption

READ ALSO

NVIDIA cuTile Python Tutorial: Building Tiled GPU Kernels for Vector Addition, Matrix Addition, and Matrix Multiplication in Colab

ClawHub Security Signals: A Coding Guide to End-to-End Security Signal Analysis and Verdict Classification on the AI Skills Dataset


  • April 26, 2025
  • Vasilis Vryniotis
  • . No comments

Cryptography often feels like an ancient dark art, full of math-heavy concepts, rigid key sizes, and strict protocols. But what if you could rethink the idea of a “key” entirely? What if the key wasn’t a fixed blob of bits, but a living, breathing function?

VernamVeil is an experimental cipher that explores exactly this idea. The name pays tribute to Gilbert Vernam, one of the minds behind the theory of the One-Time Pad. VernamVeil is written in pure Python (with an optional Numpy dependency for vectorisation) designed for developers curious about cryptography’s inner workings, providing a playful and educational space to build intuition about encryption. The main algorithm is about 200 lines of Python code (excluding documentation, comments and empty lines) with no external dependencies other than standard Python libraries.

It’s important to note from the start: I am an ML scientist with zero understanding of the inner workings of cryptography. I wrote this prototype library as a fun weekend project to explore the domain and learn the basic concepts. As a result, VernamVeil is not intended for production use or protecting real-world sensitive data. It is a learning tool, an experiment rather than a security guarantee. You can find the full code on GitHub.

Why Functions Instead of Keys?

Traditional symmetric ciphers rely on static keys, fixed-length secrets that can, if mishandled or repeated, reveal vulnerabilities. VernamVeil instead uses a function to generate the keystream dynamically: fx(i, seed) -> bytes.

This simple change unlocks several advantages:

  • No obvious repetition: As long as the function and seed are unpredictable, the keystream remains fresh.
  • Mathematical flexibility: You can craft fx functions using creative mathematical expressions, polynomials, or even external data sources.
  • Potentially infinite streams: Inspired by the One-Time Pad, VernamVeil enables keystreams as long as necessary, avoiding reuse across large datasets.

In short, instead of relying on the secrecy of a fixed string, VernamVeil relies on the richness and unpredictability of mathematical behavior. And above all, it’s modular; you can define your own fx which will serve as your very own secret key.

Key Features and Quick Example

VernamVeil introduces a range of ideas to enhance security and teach good cryptographic hygiene:

  • Customizable Key Stream: Use any function that takes an index and a seed to dynamically produce bytes. The function and initial key together are your secret key.
  • Symmetric Process: The same function and seed are used for encryption and decryption.
  • Obfuscation Techniques: Real chunks are padded with random noise, mixed with fake (decoy) chunks, and shuffled based on a seed.
  • Seed Evolution: After each chunk, the seed is refreshed, ensuring small input changes lead to large output differences.
  • Message Authentication: Built-in MAC-based verification to detect tampering.
  • Highly Configurable: Adjust chunk size, padding randomness, decoy rate, and more to experiment with different levels of obfuscation and performance.
  • Vectorisation: Some operations can be optionally vectorised using Numpy. A pure Python fallback is also available.

Here’s a quick example of encrypting and decrypting messages:

import hashlib
from vernamveil import FX, VernamVeil


def keystream_fn(i: int, seed: bytes) -> int:
    # Simple cryptographically safe fx; see repo for more examples
    hasher = hashlib.blake2b(seed)
    hasher.update(i.to_bytes(8, "big"))
    return hasher.digest()

fx = FX(keystream_fn, block_size=64, vectorise=False)


cipher = VernamVeil(fx)
seed = cipher.get_initial_seed()
encrypted, _ = cipher.encode(b"Hello!", seed)
decrypted, _ = cipher.decode(encrypted, seed)

This simple workflow already shows off several core ideas: the evolving seed, the use of a custom fx, and how reversible encryption/decryption are when set up properly.

Under the Hood: How VernamVeil Works

VernamVeil layers several techniques together to create encryption that feels playful but still introduces important cryptographic principles. Let’s walk through the key steps:

1. Splitting and Delimiters

First, the message is divided into chunks of a configurable size (default 32 bytes). Real chunks are padded with random bytes both before and after. Between each chunk, a random delimiter is inserted, but crucially, the delimiter itself is encrypted later on, meaning its boundary-marking role is hidden in the final ciphertext.

This makes it extremely difficult to identify where real data is located.

2. Obfuscation with Fake Chunks and Shuffling

Not all chunks are real. VernamVeil injects fake chunks that contain purely random bytes. Real and fake chunks are then shuffled deterministically, based on a derived shuffle seed.

This has several effects:

  • Attackers cannot easily distinguish real data from decoys.
  • Even if some structural patterns exist, they are deeply buried under obfuscation.

Together with encrypted delimiters, this makes message reconstruction without the correct seed and a strong function extremely difficult in practice.

3. XOR-Based Stream Cipher with Seed Evolution

The obfuscated message is then XOR’ed byte-by-byte with a keystream generated by your custom fx function.

However, there’s a crucial twist: the seed evolves over time. After processing each chunk, the seed is refreshed by hashing the current seed along with the data just encrypted (or decrypted).

This evolution achieves two goals:

  • Avalanche Effect: A one-byte change early in the message snowballs into major changes throughout the output.
  • Backward Secrecy: Backward secrecy is maintained because each seed is evolved by hashing the previous seed with the current plaintext chunk, so knowledge of the current seed does not allow derivation of any previous seeds.

The seed acts like a stateful chain, reventing repeated keystream patterns.

4. Message Authentication (MAC)

Finally, if enabled, VernamVeil adds a simple form of authenticated encryption:

  • A BLAKE2b HMAC of the ciphertext is computed.
  • The resulting tag is appended to the ciphertext.

When decrypting, the MAC tag is checked before decrypting the message. If the tag doesn’t match, decryption fails immediately, protecting against tampering and certain types of attacks like padding oracles.

For more information about the design, characteristics, caveats & best practices, and more technical examples, see the readme file on the repo.

Future Directions and Open Ideas

VernamVeil is an early prototype, and there’s plenty of room for experimentation and improvement. Here are some possible directions for the future:

  • Vectorised Operations: Switching from pure Python bytes to numpy, PyTorch, or TensorFlow arrays could massively accelerate key stream generation, chunk encryption, and random noise creation through vectorisation. Edit: This feature was added after the initial release and increased significantly the performance of the implementation.
  • Threading: A background thread could continuously prepare IO operations, so that encryption is never stalled. Edit: Asynchronous IO was added after the initial release.
  • Console Utility: Add a command-line interface (CLI) to allow users to run VernamVeil directly from the terminal with configurable parameters. Edit: This feature was added after the initial release.
  • Move to a Lower-Level Language: Python was chosen for clarity and ease of experimentation, but moving to a faster language like Rust, C++, or even Go could greatly improve speed and scalability. Edit: I’ve developed an optional C extension for significantly speeding up the hashing operations, after the initial release.
  • Improve Encryption Design: The core encryption model (XOR-based, function-driven) was built for educational clarity, not resilience against advanced attacks. There’s a lot of unexplored territory in designing more robust obfuscation layers, better keystream generators, and more secure authenticated encryption schemes. Edit: I’ve added Synthetic IV Seed Initialisation, switched to encrypt-then-MAC authentication, replaced hashing with HMAC and added strong fx examples and other features, after the initial release.

If you have more ideas or proposals, feel free to open a GitHub Issue. I’d love to brainstorm improvements together! And if you happen to be a cryptography expert, I would deeply appreciate any constructive criticism. VernamVeil was built as a learning exercise by someone outside the cryptography field, so it’s very likely that serious flaws or misconceptions remain. Additionally, due to my limited background in cryptography, some of the techniques I used may unknowingly reinvent existing concepts. In particular, if you recognise familiar patterns or standard practices that I didn’t name correctly or at all, I would be incredibly grateful if you could point them out. Learning the proper terminology and references would help me better understand and improve the project.

Closing Thoughts

VernamVeil doesn’t aim to replace serious cryptographic libraries like AES or ChaCha20. Instead, it’s a playground, a way to learn, tinker, and explore concepts like dynamic key generation, authenticated encryption, seed evolution, and obfuscation without getting lost in extremely dense math.

It shows that cryptography isn’t just about protecting secrets, it’s also about layering unpredictability, breaking assumptions, and thinking creatively about where vulnerabilities might hide.

If you’re curious about how real-world encryption primitives are constructed, or just want to explore math and code in a fun way, VernamVeil is an excellent starting point. I am looking forward to your comments and feedback.



Source_link

Related Posts

NVIDIA cuTile Python Tutorial: Building Tiled GPU Kernels for Vector Addition, Matrix Addition, and Matrix Multiplication in Colab
Al, Analytics and Automation

NVIDIA cuTile Python Tutorial: Building Tiled GPU Kernels for Vector Addition, Matrix Addition, and Matrix Multiplication in Colab

June 9, 2026
ClawHub Security Signals: A Coding Guide to End-to-End Security Signal Analysis and Verdict Classification on the AI Skills Dataset
Al, Analytics and Automation

ClawHub Security Signals: A Coding Guide to End-to-End Security Signal Analysis and Verdict Classification on the AI Skills Dataset

June 8, 2026
Microsoft AI Introduces MAI-Transcribe-1.5: 2.4% WER on Artificial Analysis, Best-in-Class FLEURS Accuracy, and Up to 5x Faster Long-Audio Transcription
Al, Analytics and Automation

Microsoft AI Introduces MAI-Transcribe-1.5: 2.4% WER on Artificial Analysis, Best-in-Class FLEURS Accuracy, and Up to 5x Faster Long-Audio Transcription

June 8, 2026
Building Reflective Prompt Optimization with GEPA: Multi-Component Prompts, Structured Feedback, and Held-Out Validation
Al, Analytics and Automation

Building Reflective Prompt Optimization with GEPA: Multi-Component Prompts, Structured Feedback, and Held-Out Validation

June 7, 2026
Best 21 Low-Code and No-Code AI Tools in 2026
Al, Analytics and Automation

Best 21 Low-Code and No-Code AI Tools in 2026

June 7, 2026
Tod Machover receives George Peabody Medal for contributions to music and technology | MIT News
Al, Analytics and Automation

Tod Machover receives George Peabody Medal for contributions to music and technology | MIT News

June 6, 2026
Next Post
Beyond Gen Z: Meet the Forgotten Power Consumers

Beyond Gen Z: Meet the Forgotten Power Consumers

POPULAR NEWS

Trump ends trade talks with Canada over a digital services tax

Trump ends trade talks with Canada over a digital services tax

June 28, 2025
15 Trending Songs on TikTok in 2025 (+ How to Use Them)

15 Trending Songs on TikTok in 2025 (+ How to Use Them)

June 18, 2025
Communication Effectiveness Skills For Business Leaders

Communication Effectiveness Skills For Business Leaders

June 10, 2025
App Development Cost in Singapore: Pricing Breakdown & Insights

App Development Cost in Singapore: Pricing Breakdown & Insights

June 22, 2025
Comparing the Top 7 Large Language Models LLMs/Systems for Coding in 2025

Comparing the Top 7 Large Language Models LLMs/Systems for Coding in 2025

November 4, 2025

EDITOR'S PICK

How to “Upgrade 1 Lumberyard to Lv. 2” in Demacia Rising in League of Legends

How to “Upgrade 1 Lumberyard to Lv. 2” in Demacia Rising in League of Legends

February 9, 2026
Cost to Build a Trading App Like eToro: Complete Guide

Cost to Build a Trading App Like eToro: Complete Guide

September 19, 2025
Google 2025 PhD Fellowship Program announces recipients

Google 2025 PhD Fellowship Program announces recipients

October 24, 2025

‘Authenticity over optics’: How GE Appliances learned from an accessibility misstep

September 10, 2025

About

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

Follow us

Categories

  • Account Based Marketing
  • Ad Management
  • Al, Analytics and Automation
  • Brand Management
  • Channel Marketing
  • Digital Marketing
  • Direct Marketing
  • Event Management
  • Google Marketing
  • Marketing Attribution and Consulting
  • Marketing Automation
  • Mobile Marketing
  • PR Solutions
  • Social Media Management
  • Technology And Software
  • Uncategorized

Recent Posts

  • Types of Summer Camps That Fill Your Roster
  • 5 Active Directory Misconfigurations That Still Lead to Domain Compromise in 2026
  • NVIDIA cuTile Python Tutorial: Building Tiled GPU Kernels for Vector Addition, Matrix Addition, and Matrix Multiplication in Colab
  • See the top Google Trends searches for the 2026 NBA Finals
  • About Us
  • Disclaimer
  • Contact Us
  • Privacy Policy
No Result
View All Result
  • Technology And Software
    • Account Based Marketing
    • Channel Marketing
    • Marketing Automation
      • Al, Analytics and Automation
      • Ad Management
  • Digital Marketing
    • Social Media Management
    • Google Marketing
  • Direct Marketing
    • Brand Management
    • Marketing Attribution and Consulting
  • Mobile Marketing
  • Event Management
  • PR Solutions