1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Byte comparison with the early exit removed, in one place.
//!
//! # Why this is a module rather than a local helper
//!
//! Two verifiers in this crate compare a caller-supplied expected key against
//! the key an artifact carries, and both must do it without the comparison
//! itself revealing *how far* the two agreed. Written locally in each, that is
//! two copies of a primitive whose value is a property no test observes — and
//! two copies of a rule are guarded by neither, because nothing makes them
//! fail together when one drifts.
//!
//! So there is exactly one implementation, and it is `pub(crate)` so no
//! consumer depends on it as API.
//!
//! # ⚠️ What this is NOT
//!
//! **This is early-exit removal, not a constant-time guarantee, and the
//! function is named for what it does rather than for what would be nicer to
//! claim.** The length check is a branch; a subject value's length is already
//! observable from the artifact's size; and nothing here forbids the optimiser
//! reintroducing a branch inside the loop. A real constant-time claim needs a
//! primitive that can forbid that, which this crate does not depend on.
//!
//! This caveat is carried verbatim in substance from the delegation verifier's
//! copy, **because the version before it overclaimed a related property and was
//! wrong**. Merging two copies into one is exactly the moment such a caveat
//! gets dropped as boilerplate, so it is restated rather than summarised.
//!
//! Private key material is never compared here. Every caller compares *public*
//! values whose comparison result must not leak a prefix.
/// Compare two byte slices without returning early on the first differing
/// byte.
///
/// Returns `false` immediately when the lengths differ — a length is not
/// secret in any caller here, since every one of them compares fixed-width
/// keys, and a length mismatch means the caller passed the wrong kind of
/// thing. Otherwise every byte of both inputs is read and accumulated, so the
/// work done does not depend on *where* they first differ.
///
/// See the module docs for the limits of that claim.
pub