Skip to content

chore: Add a mockall implementation of the Crypto trait#9120

Merged
eichhorl merged 8 commits intomasterfrom
eichhorl/crypto-mock
Mar 3, 2026
Merged

chore: Add a mockall implementation of the Crypto trait#9120
eichhorl merged 8 commits intomasterfrom
eichhorl/crypto-mock

Conversation

@eichhorl
Copy link
Copy Markdown
Contributor

@eichhorl eichhorl commented Mar 2, 2026

I want to be able to simulate certain crypto failures in some unit tests for NiDKG improvements. This is difficult to do because (until now) there was no complete crypto mock.

A similar IDKG test used a custom implementation of the Crypto trait that would pass through to a real crypto implementation, except for sign_basic where it returns an error. This would work as well, however it isn't very scalable or customizable.

Claude Opus 4.6 instead came up with this PR, which uses mockall to create a MockCrypto struct. Supposedly this works for all traits except the ones containing lifetime parameters (tECDSA, tSchnorr, vetkd protocol traits). Those traits are instead stubbed with unimplemented. If needed they may be implemented in a custom way, similar to the removed CryptoWrapperFailingBasicSigning.

@github-actions github-actions Bot added the chore label Mar 2, 2026
@eichhorl eichhorl changed the title chore: crypto mock chore: Add a mockall implementation for the Crypto trait Mar 2, 2026
@eichhorl eichhorl marked this pull request as ready for review March 2, 2026 15:06
@eichhorl eichhorl requested review from a team as code owners March 2, 2026 15:06
@eichhorl eichhorl requested review from fspreiss March 2, 2026 15:06
@eichhorl eichhorl changed the title chore: Add a mockall implementation for the Crypto trait chore: Add a mockall implementation of the Crypto trait Mar 3, 2026
@eichhorl eichhorl requested a review from a team as a code owner March 3, 2026 08:25
Comment thread rs/interfaces/mocks/src/crypto.rs Outdated
@eichhorl eichhorl enabled auto-merge March 3, 2026 09:39
@eichhorl eichhorl added this pull request to the merge queue Mar 3, 2026
Merged via the queue into master with commit f542d60 Mar 3, 2026
39 checks passed
@eichhorl eichhorl deleted the eichhorl/crypto-mock branch March 3, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants