Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
ffi_serialization.hpp
Go to the documentation of this file.
1 #ifndef __LIBFF_FFI_FFI_SERIALIZATION_HPP__
2 #define __LIBFF_FFI_FFI_SERIALIZATION_HPP__
3 
5 
6 namespace libff
7 {
8 
9 namespace ffi
10 {
11 
12 // FFI buffers are expected to be big-endian formatted, and padded on the left
13 // to be the same size as the in-memory bigint representations. Coefficients of
14 // field elements, and affine coordinates of curve points are placed
15 // consecutively in memory (where coefficients appear highest-order first, and
16 // coordinates appear X followed by Y).
17 
18 // TODO: Since use the in-memory object sizes (and enforce that the
19 // passed-in buffer sizes match exactly), the required sizes could
20 // potentially vary based on the platform (depending on the limb types
21 // and number). This could be addressed by explicitly specifying a
22 // serialized size for each object.
23 
24 // TODO: Make the group read operations check the validity of the
25 // curve point.
26 
29 template<typename T>
30 bool object_read_from_buffer(T &object, const void *buffer, size_t buffer_size);
31 
34 template<typename T>
35 bool object_write_to_buffer(const T &object, void *buffer, size_t buffer_size);
36 
39 template<typename FieldT>
40 bool field_element_read(FieldT &f, const void *buffer, size_t buffer_size);
41 
44 template<typename FieldT>
45 bool field_element_write(const FieldT &f, void *buffer, size_t buffer_size);
46 
49 template<typename GroupT>
50 bool group_element_read(GroupT &g, const void *buffer, size_t buffer_size);
51 
54 template<typename GroupT>
56  const GroupT &g, const void *buffer, size_t buffer_size);
57 
58 } // namespace ffi
59 
60 } // namespace libff
61 
62 #include "ffi_serialization.tcc"
63 
64 #endif // __LIBFF_FFI_FFI_SERIALIZATION_HPP__
libff
Definition: ffi.cpp:8
libff::ffi::object_write_to_buffer
bool object_write_to_buffer(const T &object, void *buffer, size_t buffer_size)
libff::ffi::group_element_write
bool group_element_write(const GroupT &g, const void *buffer, size_t buffer_size)
public_params.hpp
libff::ffi::field_element_write
bool field_element_write(const FieldT &f, void *buffer, size_t buffer_size)
ffi_serialization.tcc
libff::ffi::object_read_from_buffer
bool object_read_from_buffer(T &object, const void *buffer, size_t buffer_size)
libff::ffi::group_element_read
bool group_element_read(GroupT &g, const void *buffer, size_t buffer_size)
libff::ffi::field_element_read
bool field_element_read(FieldT &f, const void *buffer, size_t buffer_size)