Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
stream_utils.hpp
Go to the documentation of this file.
1 // Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 //
3 // SPDX-License-Identifier: LGPL-3.0+
4 
5 #ifndef __ZETH_SERIALIZATION_STREAM_UTILS_HPP__
6 #define __ZETH_SERIALIZATION_STREAM_UTILS_HPP__
7 
9 
10 #include <iostream>
11 #include <type_traits>
12 
13 namespace libzeth
14 {
15 
18 template<typename CollectionT>
19 using MemberT =
20  typename std::decay<decltype((*(CollectionT *)nullptr)[0])>::type;
21 
23 template<typename T>
24 typename std::enable_if<std::is_fundamental<T>::value, T>::type read_bytes(
25  std::istream &in_s);
26 
28 template<typename T>
29 typename std::enable_if<std::is_fundamental<T>::value, void>::type read_bytes(
30  T &val, std::istream &in_s);
31 
32 // Write a primitive datatype to a stream as raw bytes.
33 template<typename T>
34 typename std::enable_if<std::is_fundamental<T>::value, void>::type write_bytes(
35  const T &val, std::ostream &out_s);
36 
39 template<
40  typename CollectionT,
41  void(WriterT)(const MemberT<CollectionT> &, std::ostream &)>
43  const CollectionT &collection, const size_t n, std::ostream &out_s);
44 
47 template<
48  typename CollectionT,
49  void(ReaderT)(MemberT<CollectionT> &, std::istream &)>
51  CollectionT &collection, const size_t n, std::istream &in_s);
52 
55 template<
56  typename CollectionT,
57  void(WriterT)(const MemberT<CollectionT> &, std::ostream &)>
58 void collection_write_bytes(const CollectionT &collection, std::ostream &out_s);
59 
62 template<
63  typename CollectionT,
64  void(ReaderT)(MemberT<CollectionT> &, std::istream &)>
65 void collection_read_bytes(CollectionT &points, std::istream &in_s);
66 
67 template<typename T, void(ReaderFn)(T &, std::istream &)>
69  libsnark::sparse_vector<T> &sparse_vector, std::istream &in_s);
70 
71 template<typename T, void(WriterFn)(const T &, std::ostream &)>
73  const libsnark::sparse_vector<T> &sparse_vector, std::ostream &out_s);
74 
75 template<typename T, void(ReaderFn)(T &, std::istream &)>
77  libsnark::accumulation_vector<T> &acc_vector, std::istream &in_s);
78 
79 template<typename T, void(WriterFn)(const T &, std::ostream &)>
81  const libsnark::accumulation_vector<T> &acc_vector, std::ostream &out_s);
82 
83 template<typename kcT>
85  kcT &knowledge_commitment, std::istream &in_s);
86 
87 template<typename kcT>
89  const kcT &knowledge_commitment, std::ostream &out_s);
90 
91 template<typename kcvectorT>
93  kcvectorT &knowledge_commitment, std::istream &in_s);
94 
95 template<typename kcvectorT>
97  const kcvectorT &knowledge_commitment, std::ostream &out_s);
98 
99 } // namespace libzeth
100 
102 
103 #endif // __ZETH_SERIALIZATION_STREAM_UTILS_HPP__
libzeth::MemberT
typename std::decay< decltype((*(CollectionT *) nullptr)[0])>::type MemberT
Definition: stream_utils.hpp:20
test_commands.deploy_test_token.type
type
Definition: deploy_test_token.py:29
libzeth
Definition: binary_operation.hpp:15
libzeth::collection_n_write_bytes
void collection_n_write_bytes(const CollectionT &collection, const size_t n, std::ostream &out_s)
libzeth::accumulation_vector_read_bytes
void accumulation_vector_read_bytes(libsnark::accumulation_vector< T > &acc_vector, std::istream &in_s)
libzeth::read_bytes
std::enable_if< std::is_fundamental< T >::value, T >::type read_bytes(std::istream &in_s)
Read a primitive datatype from a stream as raw bytes.
libzeth::accumulation_vector_write_bytes
void accumulation_vector_write_bytes(const libsnark::accumulation_vector< T > &acc_vector, std::ostream &out_s)
libzeth::knowledge_commitment_vector_write_bytes
void knowledge_commitment_vector_write_bytes(const kcvectorT &knowledge_commitment, std::ostream &out_s)
libzeth::knowledge_commitment_write_bytes
void knowledge_commitment_write_bytes(const kcT &knowledge_commitment, std::ostream &out_s)
libzeth::knowledge_commitment_read_bytes
void knowledge_commitment_read_bytes(kcT &knowledge_commitment, std::istream &in_s)
libzeth::collection_read_bytes
void collection_read_bytes(CollectionT &points, std::istream &in_s)
libzeth::write_bytes
std::enable_if< std::is_fundamental< T >::value, void >::type write_bytes(const T &val, std::ostream &out_s)
libzeth::sparse_vector_read_bytes
void sparse_vector_read_bytes(libsnark::sparse_vector< T > &sparse_vector, std::istream &in_s)
stream_utils.tcc
libzeth::collection_n_read_bytes_n
void collection_n_read_bytes_n(CollectionT &collection, const size_t n, std::istream &in_s)
libzeth::collection_write_bytes
void collection_write_bytes(const CollectionT &collection, std::ostream &out_s)
libzeth::sparse_vector_write_bytes
void sparse_vector_write_bytes(const libsnark::sparse_vector< T > &sparse_vector, std::ostream &out_s)
libzeth::knowledge_commitment_vector_read_bytes
void knowledge_commitment_vector_read_bytes(kcvectorT &knowledge_commitment, std::istream &in_s)
include_libsnark.hpp