Skip to content

Feat(Cryptography): Signed Barrett reduction algorithm#523

Open
atrieu wants to merge 2 commits intoleanprover:mainfrom
atrieu:alix/signed_barrett
Open

Feat(Cryptography): Signed Barrett reduction algorithm#523
atrieu wants to merge 2 commits intoleanprover:mainfrom
atrieu:alix/signed_barrett

Conversation

@atrieu
Copy link
Copy Markdown

@atrieu atrieu commented Apr 27, 2026

This adds a formalisation of the signed variant of the Barrett reduction algorithm which is used in recent crypto schemes such as ML-KEM and ML-DSA.

Comment thread Cslib/Crypto/Algorithms/BarrettReduction/Aux.lean
Comment thread Cslib/Crypto/Algorithms/BarrettReduction/Signed.lean Outdated

end Cslib.Crypto.Algorithms.BarrettReduction.Signed

section MLKEMExample
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is polluting the namespace, but I think moving it to CslibTests/ should be sufficient to avoid. It probably belongs there anyways.

def IsApprox (δ : ℚ) (α : ℚ → ℤ) : Prop :=
∀ (x: ℚ), |(x - α x)| ≤ δ

lemma round_isApprox : IsApprox (1/2) round := by
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and IsApprox are dead code, but I'm guessing you plan to use them later?

public import Mathlib.Data.Rat.Floor
public import Mathlib.Algebra.Order.Field.Rat
public import Mathlib.Algebra.Order.Round
import Mathlib.Tactic
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to import this directly, Cslib.Init should have what you need and import directly otherwise.

public import Mathlib.Algebra.Order.Floor.Defs
public import Mathlib.Data.Int.DivMod
import Mathlib.Tactic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should have a note to upstream most of its contents to mathlib I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants