示例#1
0
def test_decode_pub():
    key = random_privkey()
    ans = pubkey(key)
    ret = decode_pubkey(gen_pub_key(key))
    assert ans == ret

    key = random_privkey()
    ans = pubkey(key)
    ret = decode_pubkey(gen_pub_key(key))
    assert ans == ret
示例#2
0
def test_sign():
    msg = 'test'
    priv = ecdsa.random_privkey()
    pub = ecdsa.pubkey(priv)
    sig = ecdsa.sign(priv, msg)
    assert ecdsa.verify(pub, sig, msg)
    ecdsa.proof()
示例#3
0
def test_recover():
    msg = 'test'
    mhash = hashlib.sha256(msg.encode()).digest()
    priv = ecdsa.random_privkey()
    pub = ecdsa.pubkey(priv)
    sig = ecdsa.sign(priv, msg)
    assert ecdsa.verify(pub, sig, msg)
    res = ecdsa.recover_via_msg(sig, msg)
    vrs = sig[0].value, sig[1].value, sig[2].value
    ans = bitcoin.ecdsa_raw_recover(mhash, vrs)
    assert (pub.value[0].value, pub.value[1].value) == ans
    assert pub == res
示例#4
0
def gen_pub_key(key: CF) -> str:
    return encode_pubkey(pubkey(key))
示例#5
0
def gen_address_from_priv(key) -> str:
    return gen_address(pubkey(key))
示例#6
0
def gen_address_from_priv(priv: CF) -> str:
    return gen_address(pubkey(priv))
示例#7
0
文件: public.py 项目: jin10086/klefki
def gen_pub_key(key: CF):
    return checksum(to_bytes(pubkey(key)))