-
Notifications
You must be signed in to change notification settings - Fork 586
/
Copy pathhash_io.hpp
64 lines (51 loc) · 2.14 KB
/
hash_io.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
*****************************************************************************
* @author This file is part of libsnark, developed by SCIPR Lab
* and contributors (see AUTHORS).
* @copyright MIT license (see LICENSE file)
*****************************************************************************/
#ifndef HASH_IO_HPP_
#define HASH_IO_HPP_
#include <cstddef>
#include <vector>
#include <libsnark/gadgetlib1/gadgets/basic_gadgets.hpp>
namespace libsnark {
template<typename FieldT>
class digest_variable : public gadget<FieldT> {
public:
size_t digest_size;
pb_variable_array<FieldT> bits;
digest_variable<FieldT>(protoboard<FieldT> &pb,
const size_t digest_size,
const std::string &annotation_prefix);
digest_variable<FieldT>(protoboard<FieldT> &pb,
const size_t digest_size,
const pb_variable_array<FieldT> &partial_bits,
const pb_variable<FieldT> &padding,
const std::string &annotation_prefix);
void generate_r1cs_constraints();
void generate_r1cs_witness(const libff::bit_vector& contents);
libff::bit_vector get_digest() const;
};
template<typename FieldT>
class block_variable : public gadget<FieldT> {
public:
size_t block_size;
pb_variable_array<FieldT> bits;
block_variable(protoboard<FieldT> &pb,
const size_t block_size,
const std::string &annotation_prefix);
block_variable(protoboard<FieldT> &pb,
const std::vector<pb_variable_array<FieldT> > &parts,
const std::string &annotation_prefix);
block_variable(protoboard<FieldT> &pb,
const digest_variable<FieldT> &left,
const digest_variable<FieldT> &right,
const std::string &annotation_prefix);
void generate_r1cs_constraints();
void generate_r1cs_witness(const libff::bit_vector& contents);
libff::bit_vector get_block() const;
};
} // libsnark
#include <libsnark/gadgetlib1/gadgets/hashes/hash_io.tcc>
#endif // HASH_IO_HPP_