inkfish/proof_of_time.py
def check_proof_of_time_nwesolowski(discriminant, x, proof_blob,
                                    iterations, int_size_bits):
    """
    Recursive verification function for nested wesolowski. The proof blob
    includes the output of the VDF, along with the proof. The following
    table gives an example of the recursive calls for a depth of 3.

    x   |  proof_blob
    ---------------------------------------------
    x   |  y3, proof3, y2, proof2, y1, proof1
    y1  |  y3, proof3, y2, proof2
    y2  |  y3, proof3
    """
    int_size = (int_size_bits + 16) >> 4
    result_bytes = proof_blob[: (2 * int_size)]
    proof_bytes = proof_blob[(2 * int_size):]

    proof = deserialize_proof(proof_bytes, discriminant)

    y = ClassGroup.from_bytes(result_bytes, discriminant)
    try:
        if len(proof) == 1:
            return proof_wesolowski.verify_proof(x, y, proof[-1], iterations)
        else:
            assert(len(proof) % 2 == 1 and len(proof) > 2)
            _, _, w = proof_wesolowski.approximate_parameters(iterations)

            iterations_1 = (iterations * w) // (w + 1)
            iterations_2 = iterations - iterations_1

            ver_outer = proof_wesolowski.verify_proof(x, proof[-2],
                                                      proof[-1], iterations_1)

            return ver_outer and check_proof_of_time_nwesolowski(discriminant, proof[-2],
                                                                 serialize_proof([y] + proof[:-2]),
                                                                 iterations_2, int_size_bits)

    except Exception:
        return False

    Recursive verification function for nested wesolowski. The proof blob
    includes the output of the VDF, along with the proof. The following
    table gives an example of the recursive calls for a depth of 3.

    x   |  proof_blob
    ---------------------------------------------
    x   |  y3, proof3, y2, proof2, y1, proof1
    y1  |  y3, proof3, y2, proof2
    y2  |  y3, proof3
    
Recursive verification function for nested wesolowski. The proof blob
includes the output of the VDF, along with the proof. The following
table gives an example of the recursive calls for a depth of 3.




Recursive verification function for nested wesolowski . The proof blob includes the output of the VDF along with the proof . The following table gives an example of the recursive calls for a depth of 3 .
def check_proof_of_time_nwesolowski(discriminant, x, proof_blob,
                                    iterations, int_size_bits):
    int_size = (int_size_bits + 16) >> 4
    result_bytes = proof_blob[: (2 * int_size)]
    proof_bytes = proof_blob[(2 * int_size):]
    proof = deserialize_proof(proof_bytes, discriminant)
    y = ClassGroup.from_bytes(result_bytes, discriminant)
    try:
        if len(proof) == 1:
            return proof_wesolowski.verify_proof(x, y, proof[-1], iterations)
        else:
            assert(len(proof) % 2 == 1 and len(proof) > 2)
            _, _, w = proof_wesolowski.approximate_parameters(iterations)
            iterations_1 = (iterations * w) // (w + 1)
            iterations_2 = iterations - iterations_1
            ver_outer = proof_wesolowski.verify_proof(x, proof[-2],
                                                      proof[-1], iterations_1)
            return ver_outer and check_proof_of_time_nwesolowski(discriminant, proof[-2],
                                                                 serialize_proof([y] + proof[:-2]),
                                                                 iterations_2, int_size_bits)
    except Exception:
        return False
def check_proof_of_time_nwesolowski ( discriminant , x , proof_blob , iterations , int_size_bits ) : int_size = ( int_size_bits + 16 ) >> 4 result_bytes = proof_blob [ : ( 2 * int_size ) ] proof_bytes = proof_blob [ ( 2 * int_size ) : ] proof = deserialize_proof ( proof_bytes , discriminant ) y = ClassGroup . from_bytes ( result_bytes , discriminant ) try : if len ( proof ) == 1 : return proof_wesolowski . verify_proof ( x , y , proof [ - 1 ] , iterations ) else : assert ( len ( proof ) % 2 == 1 and len ( proof ) > 2 ) _ , _ , w = proof_wesolowski . approximate_parameters ( iterations ) iterations_1 = ( iterations * w ) // ( w + 1 ) iterations_2 = iterations - iterations_1 ver_outer = proof_wesolowski . verify_proof ( x , proof [ - 2 ] , proof [ - 1 ] , iterations_1 ) return ver_outer and check_proof_of_time_nwesolowski ( discriminant , proof [ - 2 ] , serialize_proof ( [ y ] + proof [ : - 2 ] ) , iterations_2 , int_size_bits ) except Exception : return False
Recursive verification function for nested wesolowski.
Recursive verification function for nested wesolowski .
"""
    Recursive verification function for nested wesolowski. The proof blob
    includes the output of the VDF, along with the proof. The following
    table gives an example of the recursive calls for a depth of 3.

    x   |  proof_blob
    ---------------------------------------------
    x   |  y3, proof3, y2, proof2, y1, proof1
    y1  |  y3, proof3, y2, proof2
    y2  |  y3, proof3
    """
discriminant
x
proof_blob
iterations
int_size_bits