Beispiel #1
0
    def test_ecdsa_otves(self):
        coin_settings = {
            'rpcport': 0,
            'rpcauth': 'none',
            'blocks_confirmed': 1,
            'conf_target': 1
        }
        ci = BTCInterface(coin_settings, 'regtest')
        vk_sign = i2b(ci.getNewSecretKey())
        vk_encrypt = i2b(ci.getNewSecretKey())

        pk_sign = ci.getPubkey(vk_sign)
        pk_encrypt = ci.getPubkey(vk_encrypt)
        sign_hash = secrets.token_bytes(32)

        cipher_text = ecdsaotves_enc_sign(vk_sign, pk_encrypt, sign_hash)

        assert (ecdsaotves_enc_verify(pk_sign, pk_encrypt, sign_hash,
                                      cipher_text))

        sig = ecdsaotves_dec_sig(vk_encrypt, cipher_text)

        assert (ci.verifySig(pk_sign, sign_hash, sig))

        recovered_key = ecdsaotves_rec_enc_key(pk_encrypt, cipher_text, sig)

        assert (vk_encrypt == recovered_key)
Beispiel #2
0
    def test_sign_compact(self):
        coin_settings = {'rpcport': 0, 'rpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1}
        ci = BTCInterface(coin_settings, 'regtest')

        vk = i2b(ci.getNewSecretKey())
        pk = ci.getPubkey(vk)
        sig = ci.signCompact(vk, 'test signing message')
        assert(len(sig) == 64)
        ci.verifyCompact(pk, 'test signing message', sig)
Beispiel #3
0
    def test_sign(self):
        coin_settings = {'rpcport': 0, 'rpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1}
        ci = BTCInterface(coin_settings, 'regtest')

        vk = i2b(ci.getNewSecretKey())
        pk = ci.getPubkey(vk)

        message = 'test signing message'
        message_hash = hashlib.sha256(bytes(message, 'utf-8')).digest()
        eck = PrivateKey(vk)
        sig = eck.sign(message.encode('utf-8'))

        ci.verifySig(pk, message_hash, sig)