I'd be happy to help create a CLAUDE.md file for the lettuce project! This appears to be a Rust cryptography library focused on lattice-based constructions over finite fields and quotient rings.
Before I create it, I have a few questions to make sure I include the most helpful information:
Let me know what would be most valuable, and I'll create a comprehensive CLAUDE.md tailored to your needs!
Ha! You're absolutely right - I should have recognized that pattern. The "CLAUDE.md" convention is for providing context to me (Claude) about a project so I can be more helpful when working with it.
So you're asking if I think this project would benefit from having one, or if you should create one for me to reference in future conversations about this codebase?
Given that this is a specialized cryptography library with:
Yes, a CLAUDE.md would be quite useful! It could explain:
Would you like me to help you create one based on the codebase structure I can see here?
Understood. I'm ready to serve as a documentation and information abstraction device for the lettuce cryptography library.
I will:
Standing by for instructions on what documentation artifacts you need me to produce.
What would you like me to document or explain first?
Summary for transcript readers:
Lettuce is a Rust-based cryptography library (94.7% Rust, 4.6% TeX, 0.7% JavaScript) implementing lattice-based cryptographic primitives over finite fields and quotient rings.
Constructions:
hidden_rics - Linear complexity NIZK argument of RICS (Rank-1 Constraint Systems)Commitment Schemes:
Probability Distributions:
Algebraic Structures:
Provides healthy lattice utilities for post-quantum cryptographic constructions, zero-knowledge proofs, and commitment schemes based on lattice assumptions.
This is an append-only transcript that will be rendered as HTML and committed to version control.
hidden_rics (Linear complexity NIZK arg of RICS)
BDLOP
Transparent inner product
Lattice Hash
Gaussian
Ternary
Field scalar
Ring element
Matrix
Vector
RICS (Rank-1 Constraint System)
A discrete Gaussian is a probability distribution over integers (ℤ) or lattice points that approximates a continuous Gaussian bell curve.
Key properties:
Why important:
Practical use: Sample random integers where most values cluster near the center, with exponentially decreasing probability for outliers.
Statistical security means an adversary with unlimited computational power still cannot break the scheme except with negligible probability.
Contrast with computational security:
How it works:
In lattice crypto:
Example: If a protocol leaks some value v + noise where noise is drawn from a wide enough Gaussian, even an all-powerful adversary cannot recover v because the noise distribution hides it information-theoretically.
A polynomial ring is the set of all polynomials with coefficients from some base ring (like integers ℤ or finite field 𝔽), with arithmetic performed modulo some polynomial.
Structure:
Quotient by a polynomial:
Example with n=4:
Why useful in crypto:
Practical intuition: Think of it as vector arithmetic with a special multiplication rule defined by the modulus polynomial.
R1CS (Rank-1 Constraint System) represents program execution as a system of quadratic equations over a finite field.
Basic form: Each constraint looks like: (Ax) ∘ (Bx) = Cx
How it represents programs:
Example program:
def program(a, b):
c = a * b
d = c + a
return d == 10Becomes R1CS:
Why number-theoretic:
Key insight: Any computation can be "compiled" into R1CS, transforming code into pure mathematics where proofs become algebraic statements.
A universal hash family is a collection of hash functions where collisions are provably rare when the hash function is chosen randomly from the family.
Definition: A family ℋ = {h₁, h₂, ...} is universal if for any two distinct inputs x ≠ y: Pr[h(x) = h(y)] ≤ 1/m
where h is chosen randomly from ℋ and m is the output range size.
Key property: Even if an adversary knows all functions in the family and can pick the worst-case inputs x and y, a randomly selected hash function will collide on them with only probability 1/m (the "birthday bound").
Example construction: For prime p and outputs mod m:
Why "universal":
In cryptography:
Contrast with cryptographic hashes:
Practical use in lattice crypto: Universal hashing from matrices: h_A(x) = Ax mod q, where A is a random matrix. Collisions are rare due to lattice problem hardness.
Thanks! Glad I could help document those concepts clearly. The transcript is ready for HTML rendering and commit whenever you need it.
Feel free to ping me if you need more iterations or want to expand on any other parts of the lettuce library. Good luck with the project!