Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
sha256_constraint.test.cpp
Go to the documentation of this file.
2#include "acir_format.hpp"
5
7
8#include <gtest/gtest.h>
9#include <vector>
10
11namespace acir_format::tests {
13
14class Sha256Tests : public ::testing::Test {
15 protected:
17};
18
19TEST_F(Sha256Tests, TestSha256Compression)
20{
21
23 for (size_t i = 0; i < 16; ++i) {
24 inputs[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i + 1));
25 }
27 for (size_t i = 0; i < 8; ++i) {
28 hash_values[i] = WitnessOrConstant<bb::fr>::from_index(static_cast<uint32_t>(i + 17));
29 }
30 Sha256Compression sha256_compression{
31 .inputs = inputs,
32 .hash_values = hash_values,
33 .result = { 25, 26, 27, 28, 29, 30, 31, 32 },
34 };
35
36 AcirFormat constraint_system{
37 .varnum = 34,
38 .num_acir_opcodes = 1,
39 .public_inputs = {},
40 .sha256_compression = { sha256_compression },
41 .original_opcode_indices = create_empty_original_opcode_indices(),
42 };
43 mock_opcode_indices(constraint_system);
44
45 WitnessVector witness{ 0,
46 0,
47 1,
48 2,
49 3,
50 4,
51 5,
52 6,
53 7,
54 8,
55 9,
56 10,
57 11,
58 12,
59 13,
60 14,
61 15,
62 0,
63 1,
64 2,
65 3,
66 4,
67 5,
68 6,
69 7,
70 static_cast<uint32_t>(3349900789),
71 1645852969,
72 static_cast<uint32_t>(3630270619),
73 1004429770,
74 739824817,
75 static_cast<uint32_t>(3544323979),
76 557795688,
77 static_cast<uint32_t>(3481642555) };
78
79 AcirProgram program{ constraint_system, witness };
80 auto builder = create_circuit(program);
81 EXPECT_TRUE(CircuitChecker::check(builder));
82}
83} // namespace acir_format::tests
acir_format::AcirFormatOriginalOpcodeIndices create_empty_original_opcode_indices()
void mock_opcode_indices(acir_format::AcirFormat &constraint_system)
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
AluTraceBuilder builder
Definition alu.test.cpp:123
bb::stdlib::secp256k1< Builder > curve_ct
UltraCircuitBuilder create_circuit(AcirProgram &program, const ProgramMetadata &metadata)
Specialization for creating an Ultra circuit from an acir program.
bb::SlabVector< bb::fr > WitnessVector
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
TEST_F(IPATest, ChallengesAreZero)
Definition ipa.test.cpp:123
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::array< WitnessOrConstant< bb::fr >, 16 > inputs
static WitnessOrConstant from_index(uint32_t index)