コード例 #1
0
def pair_check_multiple(sig: G2Point, pubs: Sequence[G1Point],
                        msgs: Sequence[Message]) -> bool:
    size = len(pubs)
    if size == 0:
        raise Exception("empty pubkey vector")
    if len(msgs) == 0:
        raise Exception("empty message vector")
    if size != len(msgs):
        raise Exception("size of public keys and messages should be equal")
    f = pairing(sig, neg(G1), final_exponentiate=False)
    for i in range(size):
        f *= pairing(hash_to_g2(msgs[i]), pubs[i], final_exponentiate=False)
    return final_exponentiate(f) == TARGET
コード例 #2
0
ファイル: bls.py プロジェクト: vardan10/py-evm
def verify(m: bytes, pub: int, sig: bytes) -> bool:
    final_exponentiation = final_exponentiate(
        pairing(FQP_point_to_FQ2_point(decompress_G2(sig)), G1, False) *
        pairing(FQP_point_to_FQ2_point(hash_to_G2(m)), neg(decompress_G1(pub)),
                False))
    return final_exponentiation == FQ12.one()
コード例 #3
0
def pair_check(sig: G2Point, msg: Message, pub: G1Point) -> bool:
    f = pairing(sig, neg(G1), final_exponentiate=False) * pairing(
        hash_to_g2(msg), pub, final_exponentiate=False)
    return final_exponentiate(f) == TARGET
コード例 #4
0
 def neg(self) -> "WrappedCurvePoint":
     return self.__class__(neg(self.py_ecc_object))
コード例 #5
0
def verify(m, pub, sig):
    final_exponentiation = final_exponentiate(
        pairing(decompress_G2(sig), G1, False) *
        pairing(hash_to_G2(m), neg(decompress_G1(pub)), False))
    return final_exponentiation == FQ12.one()
コード例 #6
0
        equality_test.encrypt(check_keys[x], identifier, 3) for x in range(n)
    ]
    listG1 = []

    for x in range(n):
        listG1.append(checks[x]['g1_mul_prp_add_ident_hash'])

    for x in range(n):
        listG1.append(checks[x]['r_x_mul'])

    listG1.append(checks[0]['hash_ident'])

    # Invert points
    for x in range(len(listG1)):
        if x >= (len(listG1) // 2):
            listG1[x] = fast_pairing.neg(listG1[x])

    listG1 = list(map(fast_pairing.normalize, listG1))
    g1points_x, g1points_y = split_g1_points(listG1)
    tx_hash = contract_instance.transact({
        'from': web3.eth.accounts[0],
        'gas': 4000000
    }).test_equality(g1points_x, g1points_y)

    while web3.eth.getTransaction(tx_hash)['blockNumber'] is None:
        time.sleep(1)
    transaction_addr = web3.eth.getTransaction(tx_hash)['hash']
    gas_used = gas_usage(transaction_addr.hex(), web3)
    verbose_print(n, " ,", gas_used, "  actual gas used")
    gas_used_maxed = max_gas_usage(transaction_addr.hex(), web3)
    print(n, " ,", gas_used_maxed)