예제 #1
0
import sys
import chilkat
import fun

glob = chilkat.CkGlobal()
success = glob.UnlockBundle("Anything")

#"keystore.jks"
keystore = input("Keystore: ")

#"password"
password = input("Haslo: ")

jks = chilkat.CkJavaKeyStore()
success = jks.LoadFile(password, keystore)
if (success != True):
    print(jks.lastErrorText())
    sys.exit()

#"0"
index = int(input("Indeks: "))
secretKey = jks.getSecretKey("password", index, "base64")

#ccNumber = fun.text_to_bits(open('text1.txt','r+').read())

rodzaj = input("Rodzaj: ")
q = int(input("Ilosc: "))
M = [input("Wiadaomosć {}: ".format(i + 1)) for i in range(q)]

if (rodzaj == "cbc"):
    for m in M:
예제 #2
0
import ecdsa
import base64
from Crypto.Hash import keccak
import chilkat
import json
# import sawtooth_rest_api.exceptions as errors

# Unlock chilkat library
chilkat.CkGlobal().UnlockBundle("Anything for 30-day trial")


def generate_keys_pair():
    """
    :return: tuple of serialized secp256k1 elliptic curve private and public keys in Pkcs1 DER format in base64 encode
    """
    fortuna = chilkat.CkPrng()
    entropy = fortuna.getEntropy(32,"base64")
    fortuna.AddEntropy(entropy,"base64")
    ecc = chilkat.CkEcc()
    priv_key = ecc.GenEccKey("secp256k1", fortuna)
    pub_key = priv_key.GetPublicKey()
    return priv_key.getPkcs1ENC('base64'), pub_key.getEncoded(True, 'base64')


def eth_address_from_pub_key(pkcs1_DER_base64_pub_key):
    """
    :param pkcs1_DER_base64_pub_key: secp256k1 elliptic curve public key in Pkcs1 DER format in base64 encode
    :return: ethereum standart address - hex encoded the last 20 bytes of keccak 256 hash of public key
    """
    try:
        ecdsa_pub_key = ecdsa.VerifyingKey.from_der(base64.b64decode(pkcs1_DER_base64_pub_key))