Commit graph

2423 commits

Author SHA1 Message Date
cee0e17455 Aeneas-compat: decompress step_2 negate-then-conditional-assign
Same documented rewrite as FieldElement::sqrt_ratio_i: semantically
identical and still constant-time, but avoids subtle's
ConditionallyNegatable blanket impl, which the verification toolchain
cannot translate. Unblocks extracting decompress for the phase-2 full
point-level lift.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 01:41:55 +02:00
c599cfeb5a Aeneas-compat: single-call sha512_hash3 oracle (sha2-0.10 stack)
Same refactor as the risc0 fork: the three stateful hasher wrappers
collapse into one monomorphic sha512_hash3(r, a, m) -> [u8; 64] whose
signature carries no foreign types; extraction builds with
--no-default-features (the no-std From<InternalError> branch avoids the
boxed dyn-Error source path). Semantically Sha512 over r || a || m.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 22:23:29 +02:00
30f3e9aded Aeneas-compat: rename verify params signature->sig (namespace shadowing)
The extractor's generated Lean would otherwise shadow the signature:: crate
namespace with the parameter binder, turning module paths into invalid field
projections. Pure rename.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 19:48:35 +02:00
ecbf7672e4 Aeneas-compat: check_scalar via explicit ell-compare + from_bytes_mod_order
Replaces from_canonical_bytes (subtle CtOption / black_box machinery the
extractor cannot interpret) with an explicit little-endian comparison of
the scalar bytes against ell, then from_bytes_mod_order (the identity on
canonical input). Value-level semantics identical; the verification path is
variable-time throughout, so the constant-time construction is not required.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 19:48:35 +02:00
0705315b76 Aeneas-compat: monomorphic SHA-512 verify path + extraction-safe idioms
Four pure refactors in ed25519-dalek (semantics identical, extraction only):
- verifying.rs: verify_sha512/recompute_r_sha512 — the exact unrolling of
  raw_verify::<Sha512> (None context, single message slice) with every
  digest-trait call behind monomorphic sha512_* wrappers, and from_hash
  unrolled to from_bytes_mod_order_wide(finalize(h)). The generic
  Digest<OutputSize = U64> machinery (typenum/hybrid-array) defeats the
  extractor's type translation.
- verifying.rs: the R comparison as an explicit byte loop (derived
  PartialEq on CompressedEdwardsY is uninterpretable).
- signature.rs from_bytes: index loops instead of range-slicing +
  copy_from_slice (SliceIndex const-generics wall).
- signature.rs: compressed_from_bytes — an opaque constructor wrapper
  (aggregate construction of an extraction-opaque type crashes the
  translator).

With these, the full verify path extracts cleanly:
  charon --start-from crate::verifying::{verify_sha512,recompute_r_sha512}
  with curve25519_dalek/sha2/digest/ed25519/signature/subtle/zeroize opaque
  and hybrid_array/typenum excluded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 19:48:35 +02:00
d4d9ba525d Aeneas-compat: index-based LE word load in non_adjacent_form
Pure refactor, semantics identical: the read_le_u64_into call (whose
chunks/zip iterators are opaque to the extraction) becomes an explicit
nested index loop, the same shape as the proven from_bytes_wide unpack.
With this the entire vartime_double_base::mul extraction closure is
self-contained: zero external axioms, zero sorries.
2026-07-04 11:39:13 +02:00
0923301c86 Aeneas-compat: make vartime_double_base::mul extraction-clean
Pure refactors (cargo check green under both feature sets), semantics of
mul unchanged:
- dsm_top_index / dsm_loop / dsm_step_p / dsm_step_b helpers: the main
  double-and-add loop becomes a strictly-decreasing while with a
  single-assignment body and parameter-rooted borrows (the original
  loop/break shape with match-updates fails Aeneas' loop fixed point);
- the starting-index scan always returns 255: leading zero NAF digits
  double the identity (a no-op), so the result is unchanged - only the
  variable-time skip is dropped (constant-time behavior improves);
- the downward break-scan (which failed Aeneas' symbolic join) is gone.

With these, Charon+Aeneas extract the complete path - non_adjacent_form,
NafLookupTable5::from/select, the affine basepoint table, the 256-step
dsm_loop, and mul - with zero errors and zero sorries. This opens the
double-scalar-multiplication verification campaign (the EdDSA verify
equation's core).
2026-07-04 11:10:36 +02:00
77d587f4af Aeneas-compat: factor from_bytes_wide through named, closure-free helpers
Pure refactor, semantics identical (cargo check green):
- from_bytes_wide_parts(bytes) -> (Scalar52, Scalar52): the byte-unpack
  loops + the 52-bit lo/hi split, as a named prefix
- split_words_lo / split_words_hi: the two split halves, built with
  Scalar52([...]) struct literals instead of per-index mutation
- from_bytes_wide: parts -> montgomery_mul(lo, R) ->
  montgomery_mul(hi, RR) -> add

Why: the verification side measured that (a) a WP walk whose motives
contain a montgomery_mul call replays its whole body at every kernel
step, and (b) straight-line chains of IndexMut closure back-functions
make kernel defeq exponential in chain depth. Named prefix functions fix
(a); struct-literal construction eliminates the closures and fixes (b).
With this shape the full from_bytes_wide certificate kernel-checks in
77 seconds (was: aborted after 30+ minutes).
2026-07-04 10:23:26 +02:00
87928d7896 Aeneas-compat: mask the bare shift in Scalar52::from_bytes_wide
hi[4] = words[7] >> 20  is the only shift in the function whose result is
stored without a trailing mask/or; at the pinned Aeneas (bf13c42e) a bare
`x >> c` as a full RHS extracts ill-typed (wrapping_shr applied to an i32
with an emitted-but-unsubstituted U32 cast). Masking is a semantic no-op:
words[7] >> 20 < 2^44 < 2^52.  Semantics unchanged; needed to bring
from_bytes_wide (the hash-to-scalar reduction) into verification scope.
2026-07-03 22:40:03 +02:00
64ee8f0ef3 chore: remove upstream CI workflows (not our CI infrastructure) 2026-06-30 17:44:30 +02:00
3df6a2b041 patch: remove ConditionallyNegatable for Aeneas/Charon transpilation
Upstream: betrusted-io/curve25519-dalek v4.1.2
Required for: formal verification via Aeneas bf13c42e + Charon 9dd7f23c
2026-06-30 17:30:36 +02:00
bunnie
16e087ab96 version bump 2026-01-29 19:16:07 +08:00
bunnie
6f0ac06fe0 version bump 2026-01-08 03:08:31 +08:00
bunnie
4c51f72de4 version bump 2025-12-16 02:09:22 +08:00
bunnie
8725c509f2 version bump 2025-10-06 13:42:17 +08:00
bunnie
bef542a781 update pins 2025-05-11 15:44:37 +08:00
bunnie
5fcef86bca update pins 2025-05-11 15:05:40 +08:00
bunnie
c2f866d891 bump version pins 2024-09-23 01:50:44 +08:00
bunnie
7e17771d12 bump pins 2024-06-27 00:25:24 +08:00
bunnie
23c447c7cc update xous pin 2024-06-13 15:47:25 +08:00
bunnie
5a337c5cf7 bump xous rev 2024-05-29 02:08:29 +08:00
bunnie
a3bbd9b680 bump xous pins 2024-05-07 01:01:49 +08:00
bunnie
c8fbc82e2c bump xous version pin 2024-04-01 15:45:13 +08:00
bunnie
468e304624
Merge pull request #4 from betrusted-io/cleanup-hw
Cleanup hw
2024-03-28 04:13:56 -04:00
bunnie
cdd1539ba8 promote illegal opcode to a panic
if the engine25519 hits an illegal opcode, really, that's a
software bug that should be fixed. panic, so that we get
a guru meditation and a bug report.
2024-03-28 10:21:27 +08:00
bunnie
4170979f6a add handlers to check for hardware errors and try to recover 2024-03-28 10:20:53 +08:00
bunnie
c0d9b40d9d add logic to catch suspend/resume and opcode errors
also fix a bug where the engine was not being powered off
on release.

Things to note:

- in case of an opcode error, the system will enter an infinite
loop complaining about the error. Maybe i should promote that to
a panic -- it's a thing that should be fixed and should just never
happen
- in case of a suspend/resume during an operation, this is
detected by the loaded microcode length not matching what we
had written. This is a heuristic, but relies on the assumption
that the microcode length would change when the engine is put
through a clean reboot (i.e., it is unlikely that it matches
what we had previously written).
2024-03-28 10:18:27 +08:00
bunnie
c1b910a779 add features for auto-release of hardware and warning on sw fallback
These features should help the crate work more seamlessly with the
existing API, at perhaps some performance penalty that is still
to be determined.
2024-03-28 09:48:50 +08:00
bunnie
0077595699 add feature flags for auto-release of hw and warnings on sw fallback 2024-03-28 09:48:29 +08:00
bunnie
94a47207d5 add fallback to field operations
this falls back to fiat-crypto primitives if the hw engine
is unavailable.
2024-03-25 13:43:52 +08:00
bunnie
0b052f5f79 make ensure_engine() falliable
this will trigger software fallback
2024-03-25 13:43:38 +08:00
bunnie
275f586b60 add back in bits_le
needed for software fallback
2024-03-25 13:42:58 +08:00
bunnie
63a24a80b6 add sw fallback for montgomery routines 2024-03-25 13:42:31 +08:00
bunnie
077d5a1fba cleanup warning 2024-03-25 13:42:12 +08:00
bunnie
12e406ce05 add fiat-crypto crate for emulation in case hardware is busy 2024-03-25 13:41:40 +08:00
bunnie
f34c6ae4d8 make analysis work better 2024-03-25 13:41:27 +08:00
bunnie
b6ce2f60a9 cleanup warnings, as much as possible. 2024-03-25 08:04:26 +08:00
bunnie
0fc7183a2a
Merge pull request #3 from betrusted-io/v4.1.1
V4.1.1
2024-03-25 07:03:35 +08:00
bunnie
b486cda2a0
Merge branch 'main' into v4.1.1 2024-03-25 06:59:43 +08:00
bunnie
81d5c53ff8
Merge pull request #2 from kotval/update_to_v4
Update to v4 WIP
2024-03-25 06:55:08 +08:00
David Kotval
0a0a972dfa fix: incorrectly prevented to_radix_2w_size_hint on u32e
This function should be able to be enabled by feature
selection.
2024-03-21 16:35:12 -05:00
Boyd Kane
cc3421a22f
Indicate that the rand_core feature is required (#641) 2024-03-16 07:43:25 -06:00
bunnie
4fdd15c3af cleanup warnings 2024-03-11 19:12:17 +08:00
bunnie
80fded7589 add functions to allow low-level access from outside the crate
and also make the internal functions use the same conventions
2024-03-11 18:44:17 +08:00
bunnie
4c58a5166f cleanup to refer to local job primitives 2024-03-11 18:15:19 +08:00
bunnie
ebcc3702d3 cleanup field arithmetic routines to refer to local job primitives 2024-03-11 18:14:57 +08:00
bunnie
e53c5e50a5 cleanup warnings now that engine25519 is trimmed 2024-03-11 18:13:47 +08:00
bunnie
fe0e8a2f7a add common components to run jobs inside the backend 2024-03-11 18:13:19 +08:00
bunnie
96784dbbc4 add zeroize dependency and remove engine25519 dependency
porting this in a manner similar to that used by the sha2 crate,
removing the explicit Xous dependency link.

see PR for discussion of issues
2024-03-11 18:12:15 +08:00
pinkforest(she/her)
858c4ca8ae
Address new nightly clippy unnecessary qualifications (#639) 2024-03-07 16:58:20 -07:00