Page cover
githubEdit

empty-setChinese Remainder Theorem Applications

Solve systems of congruences

chevron-rightFormula & Implementationhashtag
circle-info

Formula

x ≡ aᵢ (mod nᵢ) for i = 1, 2, ..., k
  • Find x that satisfies all congruences

circle-info

Implementation

def chinese_remainder_theorem(remainders, moduli):
    """
    Solve x ≡ rᵢ (mod mᵢ) for all i
    Returns: x that satisfies all congruences
    """
    total = 0
    product = 1
    
    for modulus in moduli:
        product *= modulus
    
    for remainder, modulus in zip(remainders, moduli):
        p = product // modulus
        total += remainder * p * pow(p, -1, modulus)
    
    return total % product
chevron-rightHash Function Collision Attackshashtag
circle-info
POC
def hash_collision_via_crt(hash_function, target_bits):
    """
    Use CRT to construct messages with specific hash properties
    Applies to MD5, SHA-1, custom hash functions
    """
    # Construct messages that collide on specific bit positions
    # Using CRT to combine constraints
    pass
chevron-rightBreaking Threshold Cryptographyhashtag
circle-info
POC
def threshold_crypto_attack(shares, thresholds):
    """
    Attack threshold schemes using CRT
    When enough shares are compromised
    """
    # Reconstruct secret using CRT from compromised shares
    secret = chinese_remainder_theorem(shares, thresholds)
    return secret

Last updated