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)
def test_dleag(self): coin_settings = {'rpcport': 0, 'walletrpcport': 0, 'walletrpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1} ci = XMRInterface(coin_settings, 'regtest') key = i2b(ci.getNewSecretKey()) proof = ci.proveDLEAG(key) assert(ci.verifyDLEAG(proof))
def test_ed25519(self): privkey = edu.get_secret() pubkey = edu.encodepoint(edf.scalarmult_B(privkey)) privkey_bytes = i2b(privkey) pubkey_test = ed25519_get_pubkey(privkey_bytes) assert(pubkey == pubkey_test)
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)
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)