Ejemplo n.º 1
0
	bool NativeStorageStream::readBuffer(binary_type& buffer) {
		if (!stream_) {
			return false;
		}
		int_type current_pos = current();
		if (current_pos < 0) {
			return false;
		}
		int_type total_size = size();
		if (total_size < 0 || current_pos < total_size) {
			return false;
		}
		size_type result_size = total_size - current_pos;
		if (!result_size) {
			buffer.clear();
			return true;
		}
		buffer.resize(result_size);
		ULONG io_size = 0;
		if (FAILED(stream_->Read(&buffer[0], result_size, &io_size))) {
			KTL_ERROR(
				KTL_ERROR_SECTION,
				SPRIG_KRKR_TJS_W("ファイル読込に失敗しました"),
				sprig::krkr::internal_error
				);
			return false;
		}
		return true;
	}
Ejemplo n.º 2
0
void binary_type::prepend(const binary_type& prior)
{
    shift_right(prior.size());
    data_chunk prior_blocks = prior.blocks();
    for (size_type i = 0; i < prior_blocks.size(); i++)
    {
        blocks_[i] = blocks_[i] | prior_blocks[i];
    }
}
Ejemplo n.º 3
0
void binary_type::append(const binary_type& post)
{
    const size_type block_offset = size() / bits_per_block;
    const size_type offset = size() % bits_per_block;

    // overkill for byte alignment
    binary_type duplicate(post.size(), post.blocks());
    duplicate.shift_right(offset);

    resize(size() + post.size());
    data_chunk post_shift_blocks = duplicate.blocks();
    for (size_type i = 0; i < post_shift_blocks.size(); i++)
    {
        blocks_[block_offset + i] = blocks_[block_offset + i] | post_shift_blocks[i];
    }
}
Ejemplo n.º 4
0
	bool NativeStorageStream::readBuffer(binary_type& buffer, size_type size) {
		if (!stream_) {
			return false;
		}
		if (!size) {
			buffer.clear();
			return true;
		}
		buffer.resize(size);
		ULONG io_size = 0;
		if (FAILED(stream_->Read(&buffer[0], size, &io_size))) {
			KTL_ERROR(
				KTL_ERROR_SECTION,
				SPRIG_KRKR_TJS_W("ファイル読込に失敗しました"),
				sprig::krkr::internal_error
				);
			return false;
		}
		return true;
	}
Ejemplo n.º 5
0
stealth_address::stealth_address(const binary_type& prefix,
    const ec_point& scan_pubkey, const pubkey_list& spend_pubkeys,
    uint8_t signatures, bool testnet)
{
    // Guard against uncompressed pubkey or junk data.
    if (scan_pubkey.size() != compressed_pubkey_size)
        return;

    // Guard against uncompressed pubkey or junk data.
    for (const auto& spend_pubkey: spend_pubkeys)
        if (spend_pubkey.size() != compressed_pubkey_size)
            return;

    // Apply 'reuse'.
    auto spend_points = spend_pubkeys;
    if (spend_points.empty())
        spend_points.push_back(scan_pubkey);

    // Guard against too many keys.
    auto spend_pubkeys_size = spend_points.size();
    if (spend_pubkeys_size > max_spend_key_count)
        return;

    // Guard against prefix too long.
    auto prefix_number_bits = static_cast<uint8_t>(prefix.size());
    if (prefix_number_bits > max_prefix_bits)
        return;

    // Coerce signatures to a valid range.
    if (signatures == 0 || signatures > spend_pubkeys_size)
        signatures_ = static_cast<uint8_t>(spend_pubkeys_size);
    else
        signatures_ = signatures;

    prefix_ = prefix;
    testnet_ = testnet;
    scan_pubkey_ = scan_pubkey;
    spend_pubkeys_ = spend_points;
    valid_ = true;
}