Ejemplo n.º 1
0
def additional_python_methods():
    private_key = PrivateKey.from_seed(b'123')
    s1 = private_key.sign(b'message')
    s2 = private_key.sign_prepend(b'message')
    assert s1.get_insecure_sig().verify([Util.hash256(b'message')],
                                        [private_key.get_public_key()])
    assert s2.get_insecure_sig().verify([
        Util.hash256(private_key.get_public_key().serialize() +
                     Util.hash256(b'message'))
    ], [private_key.get_public_key()])
    s1_b = Signature.from_insecure_sig(s1.get_insecure_sig())
    s2_b = PrependSignature.from_insecure_sig(s2.get_insecure_sig())
    assert s1 == s1_b and s2 == s2_b

    s3 = private_key.sign_insecure_prehashed(Util.hash256(b'456'))
    assert s3.verify([Util.hash256(b'456')], [private_key.get_public_key()])

    esk = ExtendedPrivateKey.from_seed(b'789')
    epk = esk.get_public_key()
    s3 = private_key.sign(b'message3')
    s4 = private_key.sign_insecure(b'message3')

    assert bytes(private_key) == private_key.serialize()
    assert deepcopy(private_key) == private_key
    assert deepcopy(s1) == s1
    assert deepcopy(s2) == s2
    assert deepcopy(s3) == s3
    assert deepcopy(s4) == s4
    assert deepcopy(
        private_key.get_public_key()) == private_key.get_public_key()
    assert deepcopy(esk) == esk
    assert deepcopy(epk) == epk
    assert deepcopy(esk.get_chain_code()) == esk.get_chain_code()
Ejemplo n.º 2
0
def additional_python_methods():
    private_key = PrivateKey.from_seed(b'123')
    s1 = private_key.sign(b'message')
    s2 = private_key.sign_prepend(b'message')
    assert s1.get_insecure_sig().verify([Util.hash256(b'message')],
                                        [private_key.get_public_key()])
    assert s2.get_insecure_sig().verify([
        Util.hash256(private_key.get_public_key().serialize() +
                     Util.hash256(b'message'))
    ], [private_key.get_public_key()])
    s1_b = Signature.from_insecure_sig(s1.get_insecure_sig())
    s2_b = PrependSignature.from_insecure_sig(s2.get_insecure_sig())
    assert s1 == s1_b and s2 == s2_b

    s3 = private_key.sign_insecure_prehashed(Util.hash256(b'456'))
    assert s3.verify([Util.hash256(b'456')], [private_key.get_public_key()])