Skip to content

Feature/quasidifferential implementation - #515

Merged
peacker merged 25 commits into
developfrom
feature/quasidifferential-implementation
Oct 24, 2026
Merged

peacker merged 25 commits into
developfrom
feature/quasidifferential-implementation

Conversation

@michelag99

Copy link
Copy Markdown
Collaborator

Constraints of SMT quasidifferential model are implemented on the main components: Sbox, XOR, LinearLayer, Permutation, Rotate, MixColumn, CipherOutput, Constant, AND, OR, MODADD, MODSUB, NOT, SHIFT.
This functions are implemented:

  • find_one_xor_quasidifferential_trail
  • find_one_xor_quasidifferential_trail_with_fixed_weight
  • find_lowest_weight_xor_quasidifferential_trail
  • find_all_xor_quasidifferential_trails_with_fixed_weight
  • compute_trail_sign(solution)

@michelag99
michelag99 requested a review from peacker September 3, 2026 14:45
@peacker
peacker requested a review from shrawant September 4, 2026 07:08
@michelag99
michelag99 force-pushed the feature/quasidifferential-implementation branch from 0886dbc to f0bcc31 Compare September 10, 2026 14:56
@michelag99
michelag99 force-pushed the feature/quasidifferential-implementation branch from 2acf857 to 8aa95cb Compare September 15, 2026 09:37
@sonarqubecloud

Copy link
Copy Markdown

shrawant and others added 14 commits September 30, 2026 15:33
… masks

The model now works out each S-box's input and output difference from the values
the caller already fixed, so the S-box leaves out every transition that disagrees
with them. This reduces the size of the generated model enormously. An S-box the
characteristic does not decide keeps its whole table, so searching is unaffected.

Collect key masks from every input carrying key material. remove_key_schedule()
names the round keys key_0_2, key_1_2 and so on, so looking only for an input
named exactly key found none of them and left nothing to cancel in the
key-averaged probability.

Add boundary_masks(), returning the fixed_masks list that sets the input and
output masks to zero. It covers every component the final round emits, since
pinning only one leaves the other free and inflates the trail count.

Add tests for the derived differences, the reduced S-box constraints, and the
agreement between the key-averaged probability and the differential model.
…y condition

boundary_masks was including key-schedule outputs, because a round-key output has
the same component type as a round output. Filter on the description instead, and
raise when the cipher has no plaintext input.

Give find_one_xor_quasidifferential_trail_with_fixed_weight a fixed_masks
argument, so it can express the input and output masks being zero, and route the
mask assertions through one _apply_fixed_masks helper.

test_compute_trail_sign depended on solver order; it now sets the boundary, which
makes the weight-13 trail unique.
…fferences_and_key_inputs

Fix/quasidifferential sbox differences and key inputs
The four find_* methods now take fixed_masks, routed through the existing
_apply_fixed_masks helper. Without it they can only return trails whose input or
output mask is non-zero, and those are not trails of the characteristic.
…asks_on_find_methods

Add fixed_masks to the remaining find_* methods
Add the INPUT sections missing from the quasidifferential model, its
utils and component methods, and cite Beyne & Rijmen as [BR2022].
Join signatures and calls that fit in 120 columns, drop superfluous
blank lines, fix the license header, and wrap docstrings and comments
at 100 columns with one-line summaries. No behaviour change.
…l-docs

Change: document SMT quasidifferential model
…e get_ prefix removal from develop (#527)

The merge of develop into feature/quasidifferential-implementation brought in
d336256, which renamed Cipher.get_all_components() to all_components(). The
quasidifferential SMT model and its unit tests still called the old name,
breaking 44 pytest cases and the module's doctests.
…ebner timeout

The fixture ran AlgebraicTests on 2-round Speck32/64 with a 1 s timeout, so the
alarm fired in every round. PolyBoRi only honours the interrupt at sparse
signal checks, sometimes minutes later, which made test_save_as_image randomly
exceed the 1000 s per-test timeout on the x86_64 runner (also seen on develop,
where it passed on retry). Use 1-round Speck8/16, whose Groebner basis completes
in well under a second, so the report is built without interrupting PolyBoRi.
…fix-removal

Fix: use all_components() in the SMT quasidifferential model after the get_ prefix removal (#527)
…y_masks_by_default

Fix: default fixed_masks to the boundary in estimate_fixed_key_probab…
peacker
peacker previously approved these changes Oct 23, 2026
… cognitive complexity

SonarCloud (python:S3776) flagged _difference_bit_map in the SMT quasidifferential
model with a Cognitive Complexity of 19 against the 15 allowed. Move the nested
SHIFT handling into a _shift_bit_map static helper, bringing it down to 10. The
behaviour is unchanged.
test_save_as_latex_table, test_save_as_dataframe and test_save_as_json all
exported into the default ./test_reports and each ended with clean_reports(),
which deletes that folder. Run in parallel by xdist, one test could delete the
folder while another was still writing into it (seen on the x86_64 runner as
'OSError: Cannot save file into a non-existent directory' in
test_save_as_dataframe). Export and clean into a per-test tmp_path folder
instead, as test_save_as_image already does.
…ognitive-complexity

Refactor: reduce the cognitive complexity of _difference_bit_map (SonarCloud S3776)
@sonarqubecloud

Copy link
Copy Markdown

@peacker
peacker merged commit 03321a1 into develop Oct 24, 2026
14 checks passed
@peacker
peacker deleted the feature/quasidifferential-implementation branch October 24, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants