Skip to content

Bug in Computation of the Correlation Immunity of Boolean Functions #36294

@yhxnf

Description

@yhxnf

Steps To Reproduce

from sage.crypto.boolean_function import random_boolean_function, BooleanFunction
f = [False, False, True, False, False, True, False, False]
f = BooleanFunction(f)
print(f.walsh_hadamard_transform())
# -> (4, 0, 0, 4, 0, -4, 4, 0)
print(f.correlation_immunity())
# -> -1 but should be 1

Expected Behavior

The correlation immunity of the function f is 1 (which is clear given the Walsh-Hadamard transform) and hence the output should be 1.

Actual Behavior

The output is -1.

Additional Information

The commit linked below changed for 0 < i < len(W): to for i in range(len(W)): and hence i can take the value 0 which is not intended. It should be for i in range(1, len(W)):. This leads to the erroneous behavior described above.

95c38c6#diff-79ed08903fd2a57deee843a7ce70bfdad767504bab0f8cb31c4460295ac0230eL833

Environment

- **OS**:Ubuntu 23.04
- **Sage Version**: 10.0

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions