active library

beautiful-deception

How 256 bits pretend to be infinity: A pedagogical exploration of random oracles and computational randomness

Started 2024 Python

Resources & Distribution

Source Code

Package Registries

The Beautiful Deception: How 256 Bits Pretend to be Infinity

Python 3.8+ License: MIT arXiv

How do you store infinity in 256 bits?

A pedagogical exploration of random oracles, pseudorandom functions, and the fundamental deception at the heart of computational cryptography. This repository accompanies the paper “The Beautiful Deception: How 256 Bits Pretend to be Infinity”.

🎯 Overview

This project demonstrates how finite information can simulate infinite randomness for computationally bounded observers. Through elegant Python implementations, we explore:

  • OracleDigest: A true random oracle that fails spectacularly (proving impossibility)
  • LazyDigest: A deterministic function that successfully pretends to be random
  • Mathematical connections: To uncomputable reals, lazy evaluation, and constructive mathematics
  • Philosophical implications: The nature of randomness, entropy, and computational boundedness

πŸ“– The Paper

Read the full paper: The Beautiful Deception: How 256 Bits Pretend to be Infinity

Abstract: This paper explores the fundamental deception at the heart of computational cryptography: using finite information to simulate infinite randomness. We prove why true random oracles are impossible, then show how lazy evaluation creates a beautiful lieβ€”a finite automaton that successfully pretends to be infinite.

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/queelius/beautiful-deception.git
cd beautiful-deception

# Install in development mode
pip install -e .

# Or install with visualization support
pip install -e ".[viz]"

Basic Usage

from random_oracles import LazyDigest, OracleDigest

# Create a deterministic "infinite" digest
lazy = LazyDigest(b"my_seed")
print(lazy[0])      # First byte
print(lazy[10000])  # Ten-thousandth byte (computed on demand)
print(lazy.truncate(32).hex())  # First 32 bytes as hex

# Compare with true random oracle (warning: uses unbounded memory!)
oracle = OracleDigest(b"input")
print(oracle[0])    # Random byte (cached for consistency)

πŸ”¬ Key Concepts

The Impossibility (OracleDigest)

class OracleDigest:
    """A true random oracle - impossible to implement correctly"""
    def __getitem__(self, index):
        if index not in self.cache:
            self.cache[index] = random_byte()  # Unbounded memory!
        return self.cache[index]

Why it fails:

  • πŸ“ˆ Unbounded memory growth
  • πŸ’Ύ Cannot be serialized/saved
  • πŸ”„ Cannot be reproduced
  • 🌐 Cannot be distributed

The Beautiful Deception (LazyDigest)

class LazyDigest:
    """Deterministic infinite digest using 256 bits of entropy"""
    def __getitem__(self, index):
        return hash(seed || index)[0]  # Constant memory!

Why it works:

  • βœ… O(1) memory usage
  • βœ… Fully deterministic and reproducible
  • βœ… Distributeable (just share the seed)
  • βœ… Indistinguishable from random (if P β‰  NP)

πŸ“š Documentation

Core Classes

  • Digest: Base class for cryptographic hash outputs
  • OracleDigest: Simulates random oracle with lazy infinite output
  • LazyDigest: Deterministic infinite digest via hash chaining
  • LazyHexDigest: Hexadecimal representation of lazy digests
  • Oracle: Caches random oracle outputs
  • CryptoHash: Adapter for standard hash functions
  • OracleHash: Approximates random oracle using crypto hash

Running Demonstrations

# Interactive demo
python -m random_oracles.demo

# Show properties and theorems
python -m random_oracles.properties

# Visualize the constructions
python -m random_oracles.visualize

# Explain the algorithms
python -m random_oracles.algorithms

Advanced Constructions

The repository includes several advanced LazyDigest variants:

from random_oracles.extended_lazy import (
    HierarchicalLazyDigest,  # Tree-structured seeding
    RekeyingLazyDigest,       # Forward-secure with periodic rekeying
    SpongeLazyDigest,         # Sponge construction with tunable capacity
    XorMultiHashLazyDigest    # Multiple algorithms XORed for security
)

πŸ§ͺ Testing

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=random_oracles

# Run specific test file
pytest tests/test_digest.py -v

πŸ“Š Performance

OperationOracleDigestLazyDigest
MemoryO(k) for k accessesO(1) constant
Time per accessO(1)O(1)
ReproducibleβŒβœ…
SerializableβŒβœ…
Cycle length∞~2^128

πŸ€” Philosophical Questions

This project explores deep questions:

  1. Is randomness objective or relative to computational power?
  2. Are uncomputable objects (like true random oracles) coherent concepts?
  3. Is cryptography inherently constructivist?
  4. Does P β‰  NP explain the arrow of time?

πŸ“š Background Reading

🀝 Contributing

Contributions are welcome! Areas of interest:

  • Additional LazyDigest constructions
  • Formal verification in Coq/Isabelle
  • Quantum-resistant variants
  • Performance optimizations
  • Educational visualizations

See CONTRIBUTING.md for guidelines.

πŸ“„ License

This project is licensed under the MIT License - see LICENSE for details.

πŸ“¬ Contact

Alexander Towell
Southern Illinois University Edwardsville / Southern Illinois University Carbondale
Email: atowell@siue.edu, lex@metafunctor.com
GitHub: @queelius

πŸ™ Acknowledgments

Thanks to the cryptography community for the foundational work on random oracles and pseudorandom functions that makes this exploration possible.

πŸ“– Citation

If you use this work in your research, please cite:

@article{towell2025beautiful,
  title={The Beautiful Deception: How 256 Bits Pretend to be Infinity},
  author={Towell, Alexander},
  journal={arXiv preprint arXiv:2025.XXXXX},
  year={2025}
}

“We’re not generating randomnessβ€”we’re generating computational hardness and calling it randomness.”

Discussion