@@ -27,13 +27,14 @@ template <typename Func>
27
27
void addZirgenLift (Module& module, const std::string name, const std::string path, Func func) {
28
28
auto circuit = getInterfaceZirgen (module.getModule ().getContext (), path);
29
29
for (size_t po2 = 14 ; po2 < 19 ; ++po2) {
30
+ size_t totalCycles = 1 << po2;
30
31
module.addFunc <3 >(name + " _" + std::to_string (po2),
31
32
{gbuf (recursion::kOutSize ), ioparg (), ioparg ()},
32
33
[&](Buffer out, ReadIopVal rootIop, ReadIopVal zirgenSeal) {
33
34
DigestVal root = rootIop.readDigests (1 )[0 ];
34
35
VerifyInfo info = zirgen::verify::verify (zirgenSeal, po2, *circuit);
35
36
llvm::ArrayRef inStream (info.out );
36
- DigestVal outData = func (inStream);
37
+ DigestVal outData = func (inStream, totalCycles );
37
38
std::vector<Val> outStream;
38
39
writeSha (outData, outStream);
39
40
doExtern (" write" , " " , 0 , outStream);
@@ -57,9 +58,15 @@ int main(int argc, char* argv[]) {
57
58
llvm::cl::ParseCommandLineOptions (argc, argv, " keccak predicates" );
58
59
59
60
Module module;
60
- addZirgenLift (module, " keccak_lift" , keccakIR.getValue (), [](llvm::ArrayRef<Val>& inStream) {
61
- return readSha (inStream);
62
- });
61
+ addZirgenLift (module,
62
+ " keccak_lift" ,
63
+ keccakIR.getValue (),
64
+ [](llvm::ArrayRef<Val>& inStream, size_t expectedTotalCycles) {
65
+ auto sha = readSha (inStream);
66
+ Val totalCycles = readVal (inStream);
67
+ eq (totalCycles, expectedTotalCycles);
68
+ return sha;
69
+ });
63
70
64
71
module.optimize ();
65
72
module.getModule ().walk ([&](mlir::func::FuncOp func) { zirgen::emitRecursion (outputDir, func); });
0 commit comments