zkSNARK: Foundations of circuit design and verification logic.
This commit is contained in:
29
src/zcash/circuit/utils.tcc
Normal file
29
src/zcash/circuit/utils.tcc
Normal file
@@ -0,0 +1,29 @@
|
||||
std::vector<bool> uint256_to_bool_vector(uint256 input) {
|
||||
std::vector<unsigned char> input_v(input.begin(), input.end());
|
||||
std::vector<bool> output_bv(256, 0);
|
||||
libzerocash::convertBytesVectorToVector(
|
||||
input_v,
|
||||
output_bv
|
||||
);
|
||||
|
||||
return output_bv;
|
||||
}
|
||||
|
||||
std::vector<bool> uint64_to_bool_vector(uint64_t input) {
|
||||
std::vector<unsigned char> num_bv(8, 0);
|
||||
libzerocash::convertIntToBytesVector(input, num_bv);
|
||||
std::vector<bool> num_v(64, 0);
|
||||
libzerocash::convertBytesVectorToVector(num_bv, num_v);
|
||||
|
||||
return num_v;
|
||||
}
|
||||
|
||||
void insert_uint256(std::vector<bool>& into, uint256 from) {
|
||||
std::vector<bool> blob = uint256_to_bool_vector(from);
|
||||
into.insert(into.end(), blob.begin(), blob.end());
|
||||
}
|
||||
|
||||
void insert_uint64(std::vector<bool>& into, uint64_t from) {
|
||||
std::vector<bool> num = uint64_to_bool_vector(from);
|
||||
into.insert(into.end(), num.begin(), num.end());
|
||||
}
|
||||
Reference in New Issue
Block a user