// Copyright (c) 2019-2020 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html #include "zcash/util.h" #include #include std::vector convertIntToVectorLE(const uint64_t val_int) { std::vector bytes; for(size_t i = 0; i < 8; i++) { bytes.push_back(val_int >> (i * 8)); } return bytes; } // Convert bytes into boolean vector. (MSB to LSB) std::vector convertBytesVectorToVector(const std::vector& bytes) { std::vector ret; ret.resize(bytes.size() * 8); unsigned char c; for (size_t i = 0; i < bytes.size(); i++) { c = bytes.at(i); for (size_t j = 0; j < 8; j++) { ret.at((i*8)+j) = (c >> (7-j)) & 1; } } return ret; } // Convert boolean vector (big endian) to integer uint64_t convertVectorToInt(const std::vector& v) { if (v.size() > 64) { throw std::length_error ("boolean vector can't be larger than 64 bits"); } uint64_t result = 0; for (size_t i=0; i