def factor_signatures(hash_value1, signature1, hash_value2, signature2):
    """
    Given two hashes and their signatures that used the same random nonce `k`,
    return the signer's private key. That's why randomness is important, folks.
    """
    r1, s1 = signature1
    r2, s2 = signature2
    assert r1 == r2 # Did they really reuse the nonce?
    r = int(r1)
    return (s2 * hash_value1 - s1 * hash_value2) / (r * (s1 - s2))