コード例 #1
0
ファイル: vdf.py プロジェクト: freddiecoleman/chia-blockchain
 def is_valid(
     self,
     constants: ConsensusConstants,
     input_el: ClassgroupElement,
     info: VDFInfo,
     target_vdf_info: Optional[VDFInfo] = None,
 ):
     """
     If target_vdf_info is passed in, it is compared with info.
     """
     if target_vdf_info is not None and info != target_vdf_info:
         tb = traceback.format_stack()
         log.error(f"{tb} INVALID VDF INFO. Have: {info} Expected: {target_vdf_info}")
         return False
     if self.witness_type + 1 > constants.MAX_VDF_WITNESS_SIZE:
         return False
     try:
         disc: int = get_discriminant(info.challenge, constants.DISCRIMINANT_SIZE_BITS)
     except Exception:
         return False
     # TODO: parallelize somehow, this might included multiple mini proofs (n weso)
     # TODO: check for maximum witness type
     return verify_n_wesolowski(
         str(disc),
         input_el.data,
         info.output.data + bytes(self.witness),
         info.number_of_iterations,
         constants.DISCRIMINANT_SIZE_BITS,
         self.witness_type,
     )
コード例 #2
0
def verify_vdf(
    disc: int,
    input_el: bytes100,
    output: bytes,
    number_of_iterations: uint64,
    discriminant_size: int,
    witness_type: uint8,
):

    return verify_n_wesolowski(
        str(disc),
        input_el,
        output,
        number_of_iterations,
        discriminant_size,
        witness_type,
    )
コード例 #3
0
def oldie(disc, a, b, proof, iter, sb, witness, doold):
    if z == 0:
        x = ClassGroup.from_ab_discriminant(int(a), int(b), int(disc))

        return check_proof_of_time_nwesolowski(
            int(disc),
            x,
            proof,
            iter,
            sb,
            witness,
        )

    return verify_n_wesolowski(
        disc,
        a,
        b,
        proof,
        iter,
        sb,
        witness,
    )