예제 #1
0
def hash_delegate(b2b, dictionary):
    b2b.update(binascii.unhexlify(dictionary['account']))                        # account
    b2b.update(binascii.unhexlify(dictionary['bls_pub']))                        # bls
    b2b.update(binascii.unhexlify(dictionary['ecies_pub']))                      # ecies
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['vote']), 16)))   # rawvote
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['stake']), 16)))  # rawstake
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['vote']), 16)))   # vote
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['stake']), 16)))  # stake
    return b2b
예제 #2
0
def hash_send(b2b, dictionary, sequence, previous):
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 1, True)))                    # type
    b2b.update(qlmdb3.fromaccount(genesis_pub))                                  # origin
    b2b.update(binascii.unhexlify(previous))                                     # previous
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 16)))                         # fee
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(sequence, 4, True)))             # sequence
    b2b.update(binascii.unhexlify(dictionary['account']))                        # destination 
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['amount']), 16))) # amount
    return b2b
예제 #3
0
def hash_micro(b2b, epoch, previous):
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 1, True)))                    # version    
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(epoch, 4, True)))                # epoch number
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4, True)))                    # delegate epoch_num
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(epoch, 4, True)))                # sequence
    b2b.update(binascii.unhexlify(previous))                                     # previous
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(1, 1)))                          # last
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4, True)))                    # numblocks
    for numdel in range(32):
        b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4)))                      # epoch number
        b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4)))                      # sequence
        b2b.update(binascii.unhexlify((qlmdb3.hexstr(0, 32))))                   # tips
    return b2b
예제 #4
0
def hash_startrep(b2b, dictionary):
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(19, 1)))                         # type
    b2b.update(binascii.unhexlify(dictionary['origin']))                         # origin
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 32)))                         # previous
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 16)))                         # fee
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4, True)))                    # sequence
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4)))                          # epoch
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 32)))                         # gov previous
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(int(dictionary['stake']), 16)))  # stake
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(100, 1)))                        # levy percentage
    return b2b
예제 #5
0
def hash_epoch(b2b, epoch, previous, microtip, delegates):
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 1, True)))                    # version
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(epoch, 4, True)))                # epoch number
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4, True)))                    # delegate epoch_num
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 4, True)))                    # sequence
    b2b.update(binascii.unhexlify(previous))                                     # previous
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(epoch, 4, True)))                # tip - epoch
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(epoch, 4, True)))                # tip - sequence
    b2b.update(binascii.unhexlify(microtip))                                     # tip - hash
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 16)))                         # transaction_fee_pool
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 16)))                         # total_supply
    for delegate in delegates:
        b2b = hash_delegate(b2b, delegate)                                       # delegates
    b2b.update(binascii.unhexlify(qlmdb3.hexstr(0, 8)))                          # total rbs
    return b2b
예제 #6
0
directory = 'accounts'
account = {}
if not os.path.exists(directory):
    os.makedirs(directory)

for y in data['accounts']:
    fw = open(directory + '/' + y['info'] + '.json', 'w')
    keydata = bytes.fromhex(y['private'])
    sk = ed25519_blake2b.SigningKey(keydata)

    ################################################################################
    ## GENERATE SEND INFORMATION
    ################################################################################
    h = blake2b(digest_size=32)
    h.update(qlmdb3.fromaccount(y['account']))  # destination
    h.update(binascii.unhexlify(qlmdb3.hexstr(int(y['amount']), 16)))  # amount

    send_hash = binascii.hexlify(h.digest()).decode('ascii')
    hashdata = bytes.fromhex(send_hash)
    sig = sk.sign(hashdata)
    hexSig = sig.hex().upper()

    account['funding_info'] = {
        'account':
        binascii.hexlify(qlmdb3.fromaccount(
            y['account'])).decode('ascii').upper(),
        'amount':
        y['amount'],
        'signature':
        hexSig
    }
예제 #7
0
 ## CHECK AGAINST MASTER LIST
 #######################################################################################
 assert master[user]['amount'] == data['funding_info']['amount'], 'FAIL funding info mismatch'
 assert master[user]['vote'] == data['delegate_info']['vote'], 'FAIL delegate_info vote mismatch'
 assert master[user]['stake'] == data['delegate_info']['stake'], 'FAIL delegate_info stake mismatch'
 assert master[user]['stake'] == data['startrep']['stake'], 'FAIL startrep stake mismatch'
 assert master[user]['stake'] == data['announce']['stake'], 'FAIL announce stake mismatch'
 
 #######################################################################################
 ## GENERATE TRANSACTIONS
 #######################################################################################
 # Verify signature to ensure validity
 y = data['funding_info']
 h = blake2b(digest_size=32)
 h.update(binascii.unhexlify(y['account']))
 h.update(binascii.unhexlify(qlmdb3.hexstr(int(y['amount']), 16)))
 account_hash = binascii.hexlify(h.digest()).decode('ascii')
 
 vkey = ed25519_blake2b.VerifyingKey(bytes.fromhex(y['account']))
 try:
     vkey.verify(bytes.fromhex(y['signature']), bytes.fromhex(account_hash))
 except:
     print("FAIL ACCOUNT: invalid signature by account {}, retry".format(y['account']))
     sys.exit()
 
 # Create send request and sign with genesis prv key
 h = blake2b(digest_size=32)
 h = hash_send(h, y, sequence, previous)
 fin_hash = binascii.hexlify(h.digest()).decode('ascii').upper()
 
 sk = ed25519_blake2b.SigningKey(keydata)