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]; } }
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]; } }
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; }