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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 9 additions & 7 deletions .agents/skills/adding-a-primitive/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ instructions in an ISA model) go in their own PR before either.
new implementation is a new element of its interface's list, and its
callers follow.
The emitter writes each function's dispatcher, `<name>_auto` (in
`crate::arch::dispatch::<module>`), which
tries its implementations in the order `Dispatch.lean` ranks their
suffixes on the target (a suffix of several parts by the rank of each
part's): a variant with a suffix it does not rank yet fails the
emitter, so rank it there, best first (`VG.Rust.Rank`). Extra
features or a `vendor` it is chosen only with go in its registration
(`Registration.extra`, `Registration.vendor`).
`crate::arch::dispatch::<module>`), which tries its implementations (the
artifacts of its `Api`, all in one registration file) in the order that
file lists them: so list them best first, and put a new variant in its
interface's list where it ranks, which orders its callers' instances
too (those of a caller of several interfaces by the first list, then the
next). One the dispatcher would never choose (it needs every feature of
one before it, or more) fails the emitter. Extra features or a `vendor`
it is chosen only with go in its registration (`Registration.extra`,
`Registration.vendor`).
Registration files (`Artifacts/`) are reviewed by hand, so they only
bind: no theorems, no tactic proofs beyond the defaults (not even a
`(by decide)` argument), no definitions but those of its artifacts, and
Expand Down
12 changes: 7 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ own changes are rebuilt either way, on top of the restored build.
So does each table of functions' (`<table>_auto()`, in
`crate::arch::dispatch::fn_tables`, `Rust.tableDispatcher`), which
returns the best of the tables of its interface and data.
Which is best is not trusted: `lean/VerifiedGarbage/Dispatch.lean` ranks
the suffixes of each target, and the emitter fails on a suffix it does
not rank. A choice that only some algorithms' implementations need is
their registration's (`Registration.extra` features, and its `vendor`
for a choice by compilation target), never the ranking's.
Which is best is not trusted: the dispatcher tries a function's
implementations in the order its registration file lists them (a
generic caller's in the order of its callees' variants, best first in
`Proof/Variants/<Iface>/<Target>.lean`), and the emitter fails on one
it would never choose. A choice that only some algorithms'
implementations need is their registration's (`Registration.extra`
features, and its `vendor` for a choice by compilation target).
A variant is chosen by the CPU's features; only when no feature tells
apart the CPUs it is faster on may the choice also depend on the
compilation target (`vg_poly1305_update_neon`, faster on Apple's cores and
Expand Down
6 changes: 3 additions & 3 deletions crates/verified-garbage-asm-aarch64/src/dispatch/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
///
/// Contract: `VG.Spec.Aes.expandKeyContract`. Constant time: only the pointers and `key_len` may affect timing, not the key.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_expand_key_aes` if the CPU supports its features (`VG_AES_EXPAND_KEY_AES_FEATURES`); or else `vg_aes_expand_key`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_expand_key_aes` if the CPU supports its features (`VG_AES_EXPAND_KEY_AES_FEATURES`); or else `vg_aes_expand_key`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -56,7 +56,7 @@ pub unsafe fn vg_aes_expand_key_auto(_dit: verified_garbage_cpu::Dit<'_>, key: *
///
/// Contract: `VG.Spec.Aes.encryptBlocksContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_encrypt_blocks_aes` if the CPU supports its features (`VG_AES_ENCRYPT_BLOCKS_AES_FEATURES`); or else `vg_aes_encrypt_blocks`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_encrypt_blocks_aes` if the CPU supports its features (`VG_AES_ENCRYPT_BLOCKS_AES_FEATURES`); or else `vg_aes_encrypt_blocks`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -107,7 +107,7 @@ pub unsafe fn vg_aes_encrypt_blocks_auto(_dit: verified_garbage_cpu::Dit<'_>, sc
///
/// Contract: `VG.Spec.Aes.decryptBlocksContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_decrypt_blocks_aes` if the CPU supports its features (`VG_AES_DECRYPT_BLOCKS_AES_FEATURES`); or else `vg_aes_decrypt_blocks`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_decrypt_blocks_aes` if the CPU supports its features (`VG_AES_DECRYPT_BLOCKS_AES_FEATURES`); or else `vg_aes_decrypt_blocks`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down
4 changes: 2 additions & 2 deletions crates/verified-garbage-asm-aarch64/src/dispatch/aes_cbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
///
/// Contract: `VG.Spec.Cbc.aesEncryptContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cbc_encrypt_aes` if the CPU supports its features (`VG_AES_CBC_ENCRYPT_AES_FEATURES`); or else `vg_aes_cbc_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cbc_encrypt_aes` if the CPU supports its features (`VG_AES_CBC_ENCRYPT_AES_FEATURES`); or else `vg_aes_cbc_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -58,7 +58,7 @@ pub unsafe fn vg_aes_cbc_encrypt_auto(_dit: verified_garbage_cpu::Dit<'_>, sched
///
/// Contract: `VG.Spec.Cbc.aesDecryptContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cbc_decrypt_aes_sha3` if the CPU supports its features (`VG_AES_CBC_DECRYPT_AES_SHA3_FEATURES`); `vg_aes_cbc_decrypt_aes` if the CPU supports its features (`VG_AES_CBC_DECRYPT_AES_FEATURES`); or else `vg_aes_cbc_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cbc_decrypt_aes_sha3` if the CPU supports its features (`VG_AES_CBC_DECRYPT_AES_SHA3_FEATURES`); `vg_aes_cbc_decrypt_aes` if the CPU supports its features (`VG_AES_CBC_DECRYPT_AES_FEATURES`); or else `vg_aes_cbc_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down
4 changes: 2 additions & 2 deletions crates/verified-garbage-asm-aarch64/src/dispatch/aes_ccm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
///
/// Contract: `VG.Spec.Ccm.sealContract`. Constant time: only the pointers, `rounds`, the lengths and `tag_len` may affect timing, not the key schedule, the nonce, the associated data or the payload.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ccm_seal_aes` if the CPU supports its features (`VG_AES_CCM_SEAL_AES_FEATURES`); or else `vg_aes_ccm_seal`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_ccm_seal_aes` if the CPU supports its features (`VG_AES_CCM_SEAL_AES_FEATURES`); or else `vg_aes_ccm_seal`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -60,7 +60,7 @@ pub unsafe fn vg_aes_ccm_seal_auto(_dit: verified_garbage_cpu::Dit<'_>, schedule
///
/// Contract: `VG.Spec.Ccm.openContract`. Constant time but for the result: only the pointers, `rounds`, the lengths, `tag_len` and whether the function returns 1 or 0 may affect timing, not the key schedule, the nonce, the associated data, the data or the tag.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_ccm_open_aes` if the CPU supports its features (`VG_AES_CCM_OPEN_AES_FEATURES`); or else `vg_aes_ccm_open`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_ccm_open_aes` if the CPU supports its features (`VG_AES_CCM_OPEN_AES_FEATURES`); or else `vg_aes_ccm_open`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down
8 changes: 4 additions & 4 deletions crates/verified-garbage-asm-aarch64/src/dispatch/aes_cfb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
///
/// Contract: `VG.Spec.Cfb.aesEncryptContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb128_encrypt_aes` if the CPU supports its features (`VG_AES_CFB128_ENCRYPT_AES_FEATURES`); or else `vg_aes_cfb128_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb128_encrypt_aes` if the CPU supports its features (`VG_AES_CFB128_ENCRYPT_AES_FEATURES`); or else `vg_aes_cfb128_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -58,7 +58,7 @@ pub unsafe fn vg_aes_cfb128_encrypt_auto(_dit: verified_garbage_cpu::Dit<'_>, sc
///
/// Contract: `VG.Spec.Cfb.aesDecryptContract`. Constant time: only the pointers, `rounds` and `n` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb128_decrypt_aes` if the CPU supports its features (`VG_AES_CFB128_DECRYPT_AES_FEATURES`); or else `vg_aes_cfb128_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb128_decrypt_aes` if the CPU supports its features (`VG_AES_CFB128_DECRYPT_AES_FEATURES`); or else `vg_aes_cfb128_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -110,7 +110,7 @@ pub unsafe fn vg_aes_cfb128_decrypt_auto(_dit: verified_garbage_cpu::Dit<'_>, sc
///
/// Contract: `VG.Spec.Cfb.aesEncryptFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb128_encrypt_final_aes` if the CPU supports its features (`VG_AES_CFB128_ENCRYPT_FINAL_AES_FEATURES`); or else `vg_aes_cfb128_encrypt_final`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb128_encrypt_final_aes` if the CPU supports its features (`VG_AES_CFB128_ENCRYPT_FINAL_AES_FEATURES`); or else `vg_aes_cfb128_encrypt_final`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -162,7 +162,7 @@ pub unsafe fn vg_aes_cfb128_encrypt_final_auto(_dit: verified_garbage_cpu::Dit<'
///
/// Contract: `VG.Spec.Cfb.aesDecryptFinalContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the chaining value or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb128_decrypt_final_aes` if the CPU supports its features (`VG_AES_CFB128_DECRYPT_FINAL_AES_FEATURES`); or else `vg_aes_cfb128_decrypt_final`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb128_decrypt_final_aes` if the CPU supports its features (`VG_AES_CFB128_DECRYPT_FINAL_AES_FEATURES`); or else `vg_aes_cfb128_decrypt_final`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down
4 changes: 2 additions & 2 deletions crates/verified-garbage-asm-aarch64/src/dispatch/aes_cfb8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
///
/// Contract: `VG.Spec.Cfb8.aesEncryptContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the input block or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb8_encrypt_aes` if the CPU supports its features (`VG_AES_CFB8_ENCRYPT_AES_FEATURES`); or else `vg_aes_cfb8_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb8_encrypt_aes` if the CPU supports its features (`VG_AES_CFB8_ENCRYPT_AES_FEATURES`); or else `vg_aes_cfb8_encrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down Expand Up @@ -58,7 +58,7 @@ pub unsafe fn vg_aes_cfb8_encrypt_auto(_dit: verified_garbage_cpu::Dit<'_>, sche
///
/// Contract: `VG.Spec.Cfb8.aesDecryptContract`. Constant time: only the pointers, `rounds` and `len` may affect timing, not the key schedule, the input block or the data.
///
/// It runs the first of these implementations that applies, which `VG.Dispatch.ranking` orders (`VG.Rust.Rank`): `vg_aes_cfb8_decrypt_aes` if the CPU supports its features (`VG_AES_CFB8_DECRYPT_AES_FEATURES`); or else `vg_aes_cfb8_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
/// It runs the first of these implementations that applies, in the order its registration file lists them: `vg_aes_cfb8_decrypt_aes` if the CPU supports its features (`VG_AES_CFB8_DECRYPT_AES_FEATURES`); or else `vg_aes_cfb8_decrypt`, which needs no CPU feature. It chooses on its first call, and calls the one it chose from then on without choosing again. Each has this documentation but for its stack (whose requirements here are the largest) and what it writes.
///
/// # Safety
///
Expand Down
Loading
Loading