Beispiel #1
0
def account_create_operation(creator: str, fee: Amount, name: str, owner: str,
                             active: str, posting: str, memo, json_meta,
                             additional_owner_accounts,
                             additional_active_accounts,
                             additional_posting_accounts,
                             additional_owner_keys, additional_active_keys,
                             additional_posting_keys):
    creation_fee = str(fee)

    owner_pubkey = owner if type(owner) is PublicKey else PublicKey(owner)
    active_pubkey = active if type(active) is PublicKey else PublicKey(active)
    posting_pubkey = posting if type(posting) is PublicKey else PublicKey(
        posting)
    memo_pubkey = memo if type(memo) is PublicKey else PublicKey(memo)

    owner_key_authority = [[str(owner_pubkey), 1]]
    active_key_authority = [[str(active_pubkey), 1]]
    posting_key_authority = [[str(posting_pubkey), 1]]
    owner_accounts_authority = []
    active_accounts_authority = []
    posting_accounts_authority = []

    for k in additional_owner_keys:
        owner_key_authority.append([k, 1])
    for k in additional_active_keys:
        active_key_authority.append([k, 1])
    for k in additional_posting_keys:
        posting_key_authority.append([k, 1])

    for k in additional_owner_accounts:
        owner_accounts_authority.append([k, 1])
    for k in additional_active_accounts:
        active_accounts_authority.append([k, 1])
    for k in additional_posting_accounts:
        posting_accounts_authority.append([k, 1])
    return operations.AccountCreate(
        **{
            'fee': creation_fee,
            'creator': creator,
            'new_account_name': name,
            'owner': {
                'account_auths': owner_accounts_authority,
                'key_auths': owner_key_authority,
                'weight_threshold': 1
            },
            'active': {
                'account_auths': active_accounts_authority,
                'key_auths': active_key_authority,
                'weight_threshold': 1
            },
            'posting': {
                'account_auths': posting_accounts_authority,
                'key_auths': posting_key_authority,
                'weight_threshold': 1
            },
            'memo_key': str(memo_pubkey),
            'json_metadata': json_meta
        })
Beispiel #2
0
    def load(self):
        curr_pub = None
        curr_index = -1

        ps = packet_stream(self._keyring)
        while 1:
            pkt = ps.read()

            if pkt is None:
                break

            elif isinstance(pkt, public_key_packet):
                curr_index = curr_index + 1
                curr_pub = PublicKey(pkt)
                self._pubkey.append(curr_pub)
                #self._keyid[curr_pub.keyid()] = (curr_pub, curr_index)

            elif isinstance(pkt, userid_packet):
                if curr_pub is None:
                    self._spurious.append(pkt)
                else:
                    curr_pub.add_userid(pkt)
                    self._userid[pkt.userid()] = (curr_pub, curr_index)

            elif isinstance(pkt, signature_packet):
                if curr_pub is None:
                    self._spurious.append(pkt)
                else:
                    curr_pub.add_signature(pkt)

            else:
                self._spurious.append(pkt)

        ps.close()
Beispiel #3
0
    def __init__(self, cert):
        # c = OpenSSL.crypto
        # st_cert = open("Citi.cer", 'rt').read()
        # cert = c.load_certificate(c.FILETYPE_PEM, st_cert)

        self.logger = get_audit_logger()

        self.cert = cert
        self.config_obj = GetCertConfig()
        self.valid_obj = CertValidity(cert)
        self.revocation_obj = Revocation()
        self.trust_store_obj = TrustStore(cert)

        self.usage_obj = Usage()
        self.pubkey_obj = PublicKey(cert)
        self.ext_dict = get_extension(cert)
Beispiel #4
0
 print("p = ", p)
 print("q = ", q, "\n")
 n = p * q
 print("Por lo tanto el módulo será:\n")
 print("n = ", n, "\n")
 print("Ahora, se calcula el valor de la función phi(n):\n")
 phi_n = (p - 1) * (q - 1)
 print("Phi(n) = ", phi_n, "\n")
 print("Se escoje un exponente de cifrado:\n")
 e = RSAProcesses.encrypt_exponent(phi_n)
 print("e = ", e, "\n")
 print("A continuación se calcula el exponente de descifrado:\n")
 d = RSAProcesses.decrypt_exponent(e, phi_n)
 print("d = ", d, "\n")
 print("Finalmente se crean las claves pública y privada.\n")
 public_key = PublicKey.PublicKey(n, e)
 print("Clave pública: (", public_key.module, " ,", public_key.exponent,
       ")")
 private_key = PrivateKey.PrivateKey(n, d)
 print("Clave privada: (", private_key.module, " ,", private_key.exponent,
       ")")
 print("\n-------------------\n")
 print("Ahora se va a transmitir el mensaje. \n")
 string_array = list(
     input(
         "Escriba la cadena de caracteres que representa el mensaje a transmitir: "
     ))
 c = []
 string_array.reverse()
 for i in range(0, len(string_array)):
     c.append(
Beispiel #5
0
from PrivateKey import *
from PublicKey import *

p = 47
q = 71
private_key = PrivateKey(p, q)
public, private = private_key.create()

public_key = PublicKey(public[0], public[1])
ciphered = public_key.encrypt("Hello, World!")
print(ciphered)
dechiphered = private_key.decrypt(ciphered)
print(dechiphered)
Beispiel #6
0
 def __init__(self, keyfile, rel):
     self.pkey = PublicKey.PublicKey(self.read_keyfile(keyfile))
     self.rel = rel
     self.num = self.get_num()