Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lean/VerifiedGarbage/Artifacts/EcdsaP521/AArch64.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import VerifiedGarbage.Impl.Ecdsa.P521.AArch64
import VerifiedGarbage.Proof.Ed25519.AArch64.RowAcc
public import VerifiedGarbage.Impl.Ecdh.P256.AArch64
public import VerifiedGarbage.Impl.Ecdh.P521.AArch64
public import VerifiedGarbage.Impl.P256.VerifyRegisters
public import VerifiedGarbage.Impl.Weierstrass.AArch64.Forward
public import VerifiedGarbage.Impl.Weierstrass.AArch64.TCombJ
public import VerifiedGarbage.Proof.EcKey.PublicKey
public import VerifiedGarbage.Proof.Ecdh.AArch64.Peer
Expand Down
2 changes: 0 additions & 2 deletions lean/VerifiedGarbage/Impl/P256/EcdhDouble.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def raw : List Instr :=
f (.sub 576 t1 y2)++Linear.linear41 512 xy2 d++
f (.mul t2 d t2)++f (.mul z2 y2 y2)++Linear.linear38 544 t2 z2

def keep (off : Nat) : Bool := 512≤off && off<608

def code : List Instr := EcdhAllocatedCode.double

def program : Prog isa := .block code
Expand Down
2 changes: 1 addition & 1 deletion lean/VerifiedGarbage/Impl/P256/EcdhJac.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public import VerifiedGarbage.Impl.P256.EcdhDouble
public import VerifiedGarbage.Impl.P256.VerifyAllocated
public import VerifiedGarbage.Impl.Weierstrass.AArch64.TCombJ
public import VerifiedGarbage.Impl.AArch64Weave
import VerifiedGarbage.Impl.P256.VerifyRegisters
import VerifiedGarbage.Impl.Weierstrass.AArch64.Forward

@[expose] public section

Expand Down
5 changes: 0 additions & 5 deletions lean/VerifiedGarbage/Impl/P256/EcdhTable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ def operations (doubling : Bool) :=

def raw (doubling : Bool) : List Instr := (operations doubling).flatMap VerifySparse.op

/-- Retain the point, its cached powers of Z, and the values needed by the next table step. -/
def keep (doubling : Bool) (off : Nat) : Bool :=
(704≤off && off<800) || (5400≤off && off<5464) ||
(if doubling then 864≤off && off<928 else 608≤off && off<672)

def code (doubling : Bool) : List Instr :=
if doubling then EcdhAllocatedCode.dblu else EcdhAllocatedCode.zaddu

Expand Down
5 changes: 3 additions & 2 deletions lean/VerifiedGarbage/Impl/P256/VerifyAllocatedCode.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module
public import VerifiedGarbage.TCB.AArch64.Isa
public import VerifiedGarbage.Impl.AArch64Instrs

/-! Lean-generated output of VerifyRegisters.optimize. These literal instruction
blocks are untrusted input to the checked arithmetic certificates. -/
/-! The field programs of P-256 verification (`VerifyAllocated.raw`) with their
registers allocated. These literal instruction blocks are untrusted input to
the checked arithmetic certificates. -/

@[expose] public section

Expand Down
287 changes: 0 additions & 287 deletions lean/VerifiedGarbage/Impl/P256/VerifyRegisters.lean

This file was deleted.

17 changes: 5 additions & 12 deletions lean/VerifiedGarbage/Impl/P384/EcdhDouble.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ window's doubling `dblJ` with its sums fused into three linear combinations
`y' = 3 d m - 8 y⁴`, for `m = (x + z²)(x - z²)`; and `z' = (y + z)² - z² - y²`.
The other operations are `Ops.op`'s.
The code that runs, `Impl/P384/EcdhAllocatedCode.lean`, is `raw` with its
registers allocated (by `Impl/P256/VerifyRegisters.lean`, which is not
trusted): it keeps its values in the registers `regs` (`x1`–`x17` and
`x21`–`x25`, which ECDH saves on entry), stores only `b`'s coordinates
(`keep`), and spills to `spill`: the slots of the window's entry `E`, the
registers allocated: it keeps its values in the registers `regs` (`x1`–`x17`
and `x21`–`x25`, which ECDH saves on entry), stores only `b`'s coordinates,
and spills to `spillSlots`: the slots of the window's entry `E`, the
addition's temporaries and `tmp`, which hold nothing the window reads after
its doublings. It is checked against `raw` by certificates.
-/
Expand Down Expand Up @@ -45,19 +44,13 @@ def raw (a b : Pt) : List Instr :=
(ops1 a b).flatMap Ops.op ++ Linear.lin b.y K.S.t3 b.y 12 9 ++ (ops2 b).flatMap Ops.op ++
Linear.lin b.x K.S.t3 b.y 4 1 ++ Linear.lin b.y K.S.t1 K.S.t0 3 8

/-- The words of the point at `b`. -/
def keep (b : Pt) (off : Nat) : Bool := [b.x, b.y, b.z].any fun x => x ≤ off && off < x + 48

/-- The registers the allocation may use. -/
/-- The registers the allocated code uses. -/
def regs : List Reg :=
[.x1, .x2, .x3, .x4, .x5, .x6, .x7, .x8, .x9, .x10, .x11, .x12, .x13, .x14, .x15, .x16, .x17,
.x21, .x22, .x23, .x24, .x25]

/-- The slots spills may use. -/
/-- The slots the allocated code spills to. -/
def spillSlots : List Nat :=
[K.E.x, K.E.y, K.E.z, K.S.t0, K.S.t1, K.S.t2, K.S.t3, K.S.t4, K.S.t5, K.M.tmp]

/-- Their words. -/
def spill : List Nat := spillSlots.flatMap fun x => (List.range 6).map (x + 8 * ·)

end VG.Impl.P384.EcdhDouble
2 changes: 1 addition & 1 deletion lean/VerifiedGarbage/Impl/P384/Ops.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public import VerifiedGarbage.Impl.Ecdsa.P384.AArch64.Cfg
# P-384's field operations inline on AArch64

`op` is one field operation (`FOp`) on slots of the working space at `x0`,
in a straight line, for the register allocator (`Impl/P256/VerifyRegisters.lean`):
in a straight line, whose registers are then allocated (`EcdhAllocatedCode.lean`):
a product or square by the cores of `vg_p384_mul_mod_p` and `vg_p384_sqr_mod_p`
(`Impl/Mont/AArch64/P384Mul.lean`, `P384Sqr.lean`, adapted from s2n-bignum's
`bignum_montmul_p384_alt` and `bignum_montsqr_p384_alt`), with the operands
Expand Down
Loading
Loading