AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 18 Bitcoin

refactor(core/rust/crypto: introduce testing harness and zkp support

Public commit record

What the developer wrote

Authored by matejcik

100/100 · Strong
refactor(core/rust/crypto: introduce testing harness and zkp support

moves the test-only `rand` insecure PRNG into a dedicated test-only
module `testutil`

implements `random_buffer` extern "C" export that delegates to the
insecure PRNG
and applies a xor with a masking string <PRNG-Rust-Tests> so that its
presence can be detected within a compiled artifact
(required for secp256-zkp EC arithmetic even for verification because
curve_to_jacobian needs random data for FIH masking)

explicitly runs the test harness and initializes the zkp context before
start (also required by secp256-zkp)

moves the secp256-zkp default error handlers from modtrezorcrypto.c to
the crypto crate, so that they're properly set for any user of crypto,
not just firmware.
(this removes the "raise ValueError" feature for illegal arguments --
that shouldn't matter too much, these are checks on "is the function
called properly", not on validity of user provided input)
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit reorganizes how a test-only random number generator and certain Bitcoin-related cryptographic error handlers are wired up in the Trezor firmware's Rust crypto code. It moves an insecure PRNG used only in unit tests into its own module and exports it under a detectable name so test builds can find it. It also moves default error callbacks for the secp256k1-zkp library from the Python module layer into the core crypto crate so all users of the crate share them. The change removes a Python ValueError raise for illegal library arguments, replacing it with a system error shutdown. There is no direct evidence in the commit of a vulnerability being fixed; it reads as a refactoring to support testing and a new cryptographic feature (zero-knowledge proofs).

Recommended action

Treat as a routine refactoring commit. Reviewers should confirm that the test-only random_buffer symbol is not linked into production firmware builds and that the new system_exit_error path for secp256k1-zkp illegal callbacks does not introduce unexpected denial-of-service behavior for malformed but attacker-supplied inputs. No immediate security patch or incident response is indicated by the supplied materials.

Security signals we found

01

Insecure PRNG is explicitly test-only and relocated to a dedicated testutil module

02

random_buffer extern "C" export is test-only and XORed with a detectable string <PRNG-Rust-Tests>

03

secp256k1-zkp default error/illegal callbacks moved from Python module layer to core crypto crate

04

Illegal-argument callback behavior changed from Python ValueError to system_exit_error shutdown

05

No production randomness path is modified in the diff

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 2/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.