function decrypt($encryptedText, $key)
{
    $secretKey = hextobin(md5($key));
    $initVector = pack("C*", 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf);
    $encryptedText = hextobin($encryptedText);
    $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
    mcrypt_generic_init($openMode, $secretKey, $initVector);
    $decryptedText = mdecrypt_generic($openMode, $encryptedText);
    $decryptedText = rtrim($decryptedText, "");
    mcrypt_generic_deinit($openMode);
    return $decryptedText;
}
Esempio n. 2
0
 function encrypt($plainText, $key)
 {
     $secretKey = hextobin(md5($key));
     $initVector = pack("C*", 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf);
     $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
     $blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc');
     $plainPad = $this->pkcs5_pad($plainText, $blockSize);
     if (mcrypt_generic_init($openMode, $secretKey, $initVector) != -1) {
         $encryptedText = mcrypt_generic($openMode, $plainPad);
         mcrypt_generic_deinit($openMode);
     }
     return bin2hex($encryptedText);
 }
Esempio n. 3
0
function decrypt($encryptedText, $key)
{
    $secretKey = hextobin(md5($key));
    $initVector = pack("C*", 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf);
    $encryptedText = hextobin($encryptedText);
    /* Open module, and create IV */
    $openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
    mcrypt_generic_init($openMode, $secretKey, $initVector);
    $decryptedText = mdecrypt_generic($openMode, $encryptedText);
    // Drop nulls from end of string
    $decryptedText = rtrim($decryptedText, "");
    // Returns "Decrypted string: some text here"
    mcrypt_generic_deinit($openMode);
    return $decryptedText;
}
Esempio n. 4
0
 for ($i = 0; $i < sizeof($tx_array); $i++) {
     //print "{$tx_array[$i]['type']} === ".ParseData::findType('send_dc')."\n";
     // пропускаем все ненужные тр-ии
     if ($tx_array[$i]['type'] != ParseData::findType('send_dc')) {
         continue;
     }
     $tx_array[$i]['comment'] = bin2hex($tx_array[$i]['comment']);
     // сравнение данных из таблы my_dc_transactions с тем, что в блоке
     if ($tx_array[$i]['user_id'] === $row['type_id'] && $tx_array[$i]['currency_id'] === $row['currency_id'] && (double) $tx_array[$i]['amount'] === (double) $row['amount'] && $tx_array[$i]['to_user_id'] === $row['to_user_id']) {
         //print 'OK===============';
         // расшифруем коммент
         if ($row['comment_status'] == 'encrypted') {
             $rsa = new Crypt_RSA();
             $rsa->loadKey($private_key, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
             $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
             $decrypted_comment = $rsa->decrypt(hextobin($row['comment']));
             //echo '$private_key='.$private_key."\n";
             //echo 'comment='.$row['comment']."\n";
             //echo '$decrypted_comment='.$decrypted_comment."\n";
             unset($rsa);
             // запишем расшифрованный коммент, чтобы потом можно было найти перевод в ручном режиме
             $decrypted_comment = filter_var($decrypted_comment, FILTER_SANITIZE_STRING);
             $decrypted_comment = str_replace(array('\'', '"'), '', $decrypted_comment);
             $decrypted_comment = $db->escape($decrypted_comment);
             $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tUPDATE `" . DB_PREFIX . $MY_PREFIX . "my_dc_transactions`\n\t\t\t\t\t\tSET  `comment` = '{$decrypted_comment}',\n\t\t\t\t\t\t\t\t`comment_status` = 'decrypted'\n\t\t\t\t\t\tWHERE `id` = {$row['id']}\n\t\t\t\t\t\t");
         } else {
             $decrypted_comment = $row['comment'];
         }
         // возможно, что чуть раньше было reduction, а это значит, что все тр-ии,
         // которые мы ещё не обработали и которые были До блока с reduction нужно принимать с учетом reduction
         // т.к. средства на нашем счете уже урезались, а  вот те, что после reduction - остались в том виде, в котором пришли
Esempio n. 5
0
do {
    // 1 - это админские тр-ии, 0 - юзерские
    $new_data['high_rate'] = binary_dec(string_shift($binary_data, 1));
    list(, $new_data['tx_hash']) = unpack("H*", string_shift($binary_data, 16));
    // тр-ий нету
    if (!$new_data['tx_hash']) {
        debug_print('!$new_data[tx_hash]', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        exit;
    }
    // проверим, нет ли у нас такой тр-ии
    $exists = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`hash`)\n\t\t\tFROM `" . DB_PREFIX . "log_transactions`\n\t\t\tWHERE `hash` = 0x{$new_data['tx_hash']}\n\t\t\t", 'fetch_one');
    if ($exists) {
        debug_print('!exists! continue', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        continue;
    }
    $need_tx .= hextobin($new_data['tx_hash']);
} while ($binary_data);
if (!$need_tx) {
    exit;
}
// получился список нужных нам тр-ий, теперь его пошлем тому ноду, у которого они есть
$data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT `host`,\n\t\t\t\t\t\t `node_public_key`\n\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\tWHERE `user_id` = {$new_data['user_id']}\n\t\t\t", 'fetch_array');
debug_print($data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
$host = $data['host'];
$node_public_key = $data['node_public_key'];
debug_print($new_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
// шифруем данные. ключ $key будем использовать для расшифровки ответа
$encrypted_data = encrypt_data($need_tx, $node_public_key, $db, $my_key);
// user_id получателя (нужно для пулов)
$encrypted_data = dec_binary($new_data['user_id'], 5) . $encrypted_data;
debug_print('$encrypted_data=' . bin2hex($encrypted_data), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
Esempio n. 6
0
         $format = $erej["format"];
         // create proper superhashlist field if needed
         list($superhash, $hlisty) = superList($hlist, $format);
         $kvery = "SELECT plaintext FROM " . $formattables[$format] . " WHERE hashlist IN ({$hlisty}) AND plaintext IS NOT NULL";
         $kv = mysqli_query_wrapper($dblink, $kvery);
         if (mysqli_num_rows($kv) > 0) {
             $wlist = "Wordlist_" . $hlist . "_" . date("Y-m-d_H-i-s", $cas) . ".txt";
             echo "Opening wordlist for writing...<br>";
             $fx = fopen("files/" . $wlist, "w");
             $p = 0;
             while ($erej = mysqli_fetch_array($kv, MYSQLI_ASSOC)) {
                 $plain = $erej["plaintext"];
                 if (strlen($plain) >= 8 && substr($plain, 0, 5) == "\$HEX[" && substr($plain, strlen($plain) - 1, 1) == "]") {
                     // strip $HEX[]
                     $nplain = "";
                     $plain = hextobin(substr($plain, 5, strlen($plain) - 6));
                 }
                 fwrite($fx, $plain . "\n");
                 $p++;
             }
             fclose($fx);
             echo "Written {$p} words.<br>";
             insertFile("files/" . $wlist);
         } else {
             echo "Nothing cracked.";
         }
     }
     break;
 case "export":
     // export cracked hashes to a file
     $hlist = intval($_GET["hashlist"]);
        main_unlock();
        exit;
    }
    debug_print($max_other_currencies_votes, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    $total_count_currencies = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`id`)\n\t\t\tFROM `" . DB_PREFIX . "currency`\n\t\t\t", 'fetch_one');
    foreach ($max_other_currencies_votes as $currency_id => $count_and_votes) {
        $new_max_other_currencies[$currency_id] = get_max_vote($count_and_votes, 0, $total_count_currencies, 10);
    }
    if (get_community_users($db)) {
        $my_prefix = $testBlock->user_id . '_';
    } else {
        $my_prefix = '';
    }
    $node_private_key = get_node_private_key($db, $my_prefix);
    $json_data = json_encode($new_max_other_currencies);
    // подписываем нашим нод-ключем данные транзакции
    $data_for_sign = ParseData::findType('new_max_other_currencies') . ",{$time},{$my_user_id},{$json_data}";
    $rsa = new Crypt_RSA();
    $rsa->loadKey($node_private_key);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $signature = $rsa->sign($data_for_sign);
    debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса в табле 'pct'
    $data = dec_binary(ParseData::findType('new_max_other_currencies'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($json_data) . ParseData::encode_length_plus_data($signature);
    $hash = ParseData::dsha256($data);
    insert_tx($data, $db);
    $new_tx_data['data'] = $data;
    $new_tx_data['hash'] = hextobin(md5($data));
    tx_parser($new_tx_data, true);
}
main_unlock();
Esempio n. 8
0
main_lock();
$my_user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `user_id`\n\t\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_table`\n\t\t\t\t\t", 'fetch_one');
$node_private_key = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `private_key`\n\t\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_node_keys`\n\t\t\t\t\tWHERE `block_id` = (SELECT max(`block_id`) FROM `" . DB_PREFIX . MY_PREFIX . "my_node_keys` )\n\t\t\t\t\t", 'fetch_one');
if (!$my_user_id || !$node_private_key) {
    main_unlock();
    exit;
}
require_once ABSPATH . 'phpseclib/Math/BigInteger.php';
require_once ABSPATH . 'phpseclib/Crypt/Random.php';
require_once ABSPATH . 'phpseclib/Crypt/Hash.php';
require_once ABSPATH . 'phpseclib/Crypt/RSA.php';
$rsa = new Crypt_RSA();
extract($rsa->createKey(1024));
$publickey = clear_public_key($publickey);
$db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tINSERT INTO  `" . DB_PREFIX . MY_PREFIX . "my_node_keys` (\n\t\t\t\t`public_key`,\n\t\t\t\t`private_key`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t0x{$publickey},\n\t\t\t\t'{$privatekey}'\n\t\t\t)");
$time = time();
// подписываем нашим нод-ключем данные транзакции
$data_for_sign = ParseData::findType('change_node_key') . ",{$time},{$my_user_id},{$publickey}";
$rsa = new Crypt_RSA();
$rsa->loadKey($node_private_key);
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$signature = $rsa->sign($data_for_sign);
print '$node_private_key=' . $node_private_key . "\n";
print '$data_for_sign=' . $data_for_sign . "\n";
print 'strlen($signature)=' . strlen($signature) . "\n";
print 'strlen($publickey)=' . strlen($publickey) . "\n";
// создаем новую транзакцию
$bin_public_key = hextobin($publickey);
$data = dec_binary(ParseData::findType('change_node_key'), 1) . dec_binary($time, 4) . encode_length(strlen($my_user_id)) . $my_user_id . encode_length(strlen($bin_public_key)) . $bin_public_key . encode_length(strlen($signature)) . $signature;
insert_tx($data, $db);
main_unlock();
Esempio n. 9
0
         		if (check_change_key($my_user_id) > 0)
         			$_SESSION['key_changed'] = 1;
         		else
         			$_SESSION['key_changed'] = 0;*/
         print json_encode(array('result' => 1));
         exit;
     }
 }
 // если дошли досюда, значит ни один ключ не подошел и даем возможность войти в ограниченном режиме
 $rsa = new Crypt_RSA();
 $key = array();
 $key['e'] = new Math_BigInteger($_POST['e'], 16);
 $key['n'] = new Math_BigInteger($_POST['n'], 16);
 $rsa->setPublicKey($key, CRYPT_RSA_PUBLIC_FORMAT_RAW);
 $PublicKey = clear_public_key($rsa->getPublicKey());
 $PublicKey_bin = hextobin($PublicKey);
 debug_print('>$PublicKey=' . $PublicKey, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
 $user_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `user_id`\n\t\t\t\tFROM `" . DB_PREFIX . "users`\n\t\t\t\tWHERE `public_key_0` = 0x{$PublicKey}\n\t\t\t\t", 'fetch_one');
 if ($user_id) {
     $for_sign = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `data`\n\t\t\t\tFROM `" . DB_PREFIX . "authorization`\n\t\t\t\tWHERE `hash` = 0x{$hash}\n\t\t\t\t", 'fetch_one');
     $error = ParseData::checkSign($PublicKey_bin, $for_sign, $sign, true);
     if (!$error) {
         // если юзер смог подписать наш хэш, значит у него актуальный праймари ключ
         session_start();
         $_SESSION['user_id'] = $user_id;
         $_SESSION['public_key'] = get_user_public_key2($user_id);
         // возможно в табле my_keys старые данные, но если эта табла есть, то нужно добавить туда ключ
         if (in_array("{$user_id}_my_keys", $tables_array)) {
             $cur_block_id = get_block_id($db);
             $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tINSERT INTO `" . DB_PREFIX . $user_id . "_my_keys` (\n\t\t\t\t\t`public_key`,\n\t\t\t\t\t`status`,\n\t\t\t\t\t`block_id`\n\t\t\t\t)\n\t\t\t\tVALUES (\n\t\t\t\t\t0x{$PublicKey},\n\t\t\t\t\t'approved',\n\t\t\t\t\t{$cur_block_id}\n\t\t\t\t)");
             unset($_SESSION['restricted']);
Esempio n. 10
0
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . $bin_signatures;
        break;
    case 'change_key_request':
        $to_user_id = $_REQUEST['to_user_id'];
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($to_user_id) . $bin_signatures;
        break;
    case 'admin_change_primary_key':
        $for_user_id = $_REQUEST['for_user_id'];
        $new_public_key = hextobin($_REQUEST['new_public_key']);
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($for_user_id) . ParseData::encode_length_plus_data($new_public_key) . $bin_signatures;
        break;
    case 'change_arbitrator_list':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['arbitration_trust_list']) . $bin_signatures;
        break;
    case 'money_back_request':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['order_id']) . ParseData::encode_length_plus_data(hextobin($_REQUEST['arbitrator_enc_text'][0])) . ParseData::encode_length_plus_data(hextobin($_REQUEST['arbitrator_enc_text'][1])) . ParseData::encode_length_plus_data(hextobin($_REQUEST['arbitrator_enc_text'][2])) . ParseData::encode_length_plus_data(hextobin($_REQUEST['arbitrator_enc_text'][3])) . ParseData::encode_length_plus_data(hextobin($_REQUEST['arbitrator_enc_text'][4])) . ParseData::encode_length_plus_data(hextobin($_REQUEST['seller_enc_text'])) . $bin_signatures;
        break;
    case 'change_seller_hold_back':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['arbitration_days_refund']) . ParseData::encode_length_plus_data($_REQUEST['hold_back_pct']) . $bin_signatures;
        break;
    case 'money_back':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['order_id']) . ParseData::encode_length_plus_data($_REQUEST['amount']) . $bin_signatures;
        break;
    case 'change_arbitrator_conditions':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['conditions']) . ParseData::encode_length_plus_data($_REQUEST['url']) . $bin_signatures;
        break;
    case 'change_money_back_time':
        $data = dec_binary($type, 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($user_id) . ParseData::encode_length_plus_data($_REQUEST['order_id']) . ParseData::encode_length_plus_data($_REQUEST['days']) . $bin_signatures;
        break;
}
$hash = md5($data);
Esempio n. 11
0
if (!empty($data['parent_id']) && !check_input_data($data['parent_id'], 'int')) {
    die('error parent_id');
}
if ($_REQUEST['type'] !== 'dc_transactions' && $_REQUEST['type'] !== 'arbitrator' && $_REQUEST['type'] !== 'seller' && $_REQUEST['type'] !== 'cash_requests' && $_REQUEST['type'] !== 'comments') {
    die('error type');
}
define('MY_PREFIX', get_my_prefix($db));
// == если мы майнер и это dc_transactions, то сюда прислан зашифрованный коммент, который можно расшифровать только нод-кдючем
$miner_id = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `miner_id`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `user_id` = {$_SESSION['user_id']}\n\t\tLIMIT 1\n\t\t", 'fetch_one');
if ($miner_id > 0 && ($_REQUEST['type'] == 'dc_transactions' || $_REQUEST['type'] == 'arbitrator' || $_REQUEST['type'] == 'seller')) {
    $node_private_key = get_node_private_key($db, MY_PREFIX);
    // расшифруем коммент
    $rsa = new Crypt_RSA();
    $rsa->loadKey($node_private_key, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $_REQUEST['comment'] = $rsa->decrypt(hextobin($_REQUEST['comment']));
    unset($rsa);
}
// ==
// $_REQUEST['comment'] - может содержать зловред
$comment = filter_var($_REQUEST['comment'], FILTER_SANITIZE_STRING);
$comment = str_ireplace(array('\'', '"'), '', $comment);
$comment = $db->escape($comment);
if ($comment) {
    $id = intval($_REQUEST['id']);
    $type = filter_var($_REQUEST['type'], FILTER_SANITIZE_STRING);
    $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "SET NAMES UTF8");
    if ($type == 'arbitrator' || $type == 'seller') {
        $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tUPDATE `" . DB_PREFIX . MY_PREFIX . "my_comments`\n\t\t\t\tSET `comment`='{$comment}',\n\t\t\t\t\t   `comment_status` = 'decrypted'\n\t\t\t\tWHERE `id` = {$id} AND\n\t\t\t\t\t\t\t`type` = '{$type}'\n\t\t\t\t");
    } else {
        $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tUPDATE `" . DB_PREFIX . MY_PREFIX . "my_{$type}`\n\t\t\t\tSET `comment`='{$comment}',\n\t\t\t\t\t   `comment_status` = 'decrypted'\n\t\t\t\tWHERE `id` = {$id}\n\t\t\t\t");
function decrypt($encrypted_text)
{
    /*	global $encryption_iv,$encryption_key;
    	$encrypted_text =trim(chop(base64_decode(hextobin($encrypted_text))));
    	$decrypted_text = mcrypt_cfb (MCRYPT_TWOFISH, $encryption_key, $encrypted_text, MCRYPT_DECRYPT, $encryption_iv);
    	return trim(chop($decrypted_text));
    	*/
    $encryption_key = "@#MCX%@CADas";
    $iv_size = mcrypt_get_iv_size(MCRYPT_XTEA, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    return $crypttext = trim(mcrypt_decrypt(MCRYPT_XTEA, $encryption_key, hextobin($encrypted_text), MCRYPT_MODE_ECB, $iv));
}
 private function createKeyUsingIVAndPassphrase($iv, $passphrase)
 {
     function hextobin($hexstr)
     {
         $n = strlen($hexstr);
         $sbin = "";
         $i = 0;
         while ($i < $n) {
             $a = substr($hexstr, $i, 2);
             $c = pack("H*", $a);
             if ($i == 0) {
                 $sbin = $c;
             } else {
                 $sbin .= $c;
             }
             $i += 2;
         }
         return $sbin;
     }
     $aes_key = $iv . hextobin("00000000000000000000000000000000");
     $iterations = 8192;
     for ($i = 0; $i < $iterations; $i++) {
         $hash = hash_init("sha256");
         hash_update($hash, $aes_key);
         hash_update($hash, $passphrase);
         $aes_key = hash_final($hash, true);
     }
     return $aes_key;
 }
Esempio n. 14
0
//print $reduction_pct."\n";
//print $reduction_type."\n";
//print $reduction_currency_id."\n";
if (isset($reduction_currency_id) && isset($reduction_pct)) {
    if (get_community_users($db)) {
        $my_prefix = $testBlock->user_id . '_';
    } else {
        $my_prefix = '';
    }
    $node_private_key = get_node_private_key($db, $my_prefix);
    print $my_prefix . "\n";
    // подписываем нашим нод-ключем данные транзакции
    $data_for_sign = ParseData::findType('new_reduction') . ",{$time},{$my_user_id},{$reduction_currency_id},{$reduction_pct},{$reduction_type}";
    $rsa = new Crypt_RSA();
    $rsa->loadKey($node_private_key);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $signature = $rsa->sign($data_for_sign);
    debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    print $data_for_sign;
    print $node_private_key;
    // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса и статусы банкнот
    $reduction_tx_data = dec_binary(ParseData::findType('new_reduction'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($reduction_currency_id) . ParseData::encode_length_plus_data($reduction_pct) . ParseData::encode_length_plus_data($reduction_type) . ParseData::encode_length_plus_data($signature);
    insert_tx($reduction_tx_data, $db);
    // и не закрывая main_lock переводим нашу тр-ию в verified=1, откатив все несовместимые тр-ии
    // таким образом у нас будут в блоке только актуальные голоса.
    // а если придет другой блок и станет verified=0, то эта тр-ия просто удалится.
    $new_tx_data['data'] = $reduction_tx_data;
    $new_tx_data['hash'] = hextobin(md5($reduction_tx_data));
    tx_parser($new_tx_data, true);
}
main_unlock();