diff --git a/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java b/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java index f96946c39..029a93848 100644 --- a/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java +++ b/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java @@ -5,13 +5,33 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +/** + * The CompositeLFSR class represents a composite implementation of + * Linear Feedback Shift Registers (LFSRs) for cryptographic purposes. + * + *
+ * This abstract class manages a collection of LFSR instances and + * provides a mechanism for irregular clocking based on the + * majority bit among the registers. It implements the BaseLFSR + * interface, requiring subclasses to define specific LFSR behaviors. + *
+ */ public abstract class CompositeLFSR implements BaseLFSR { protected final List+ * This method determines the majority bit across all registers and + * clocks each register based on its clock bit. If a register's + * clock bit matches the majority bit, it is clocked (shifted). + * The method also computes and returns the XOR of the last bits + * of all registers. + *
+ * + * @return the XOR value of the last bits of all registers. */ @Override public boolean clock() { @@ -26,6 +46,18 @@ public abstract class CompositeLFSR implements BaseLFSR { return result; } + /** + * Calculates the majority bit among all registers. + * + *+ * This private method counts the number of true and false clock bits + * across all LFSR registers. It returns true if the count of true + * bits is greater than or equal to the count of false bits; otherwise, + * it returns false. + *
+ * + * @return true if the majority clock bits are true; false otherwise. + */ private boolean getMajorityBit() { Map