From 429cc7827b23c943173affb579448895831d8e43 Mon Sep 17 00:00:00 2001 From: "zilong.dai" <2840478265@qq.com> Date: Thu, 31 Oct 2024 18:46:54 +0800 Subject: [PATCH] limit 1 OP_CHECKZKPVERIFY per script --- src/script/interpreter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 7fe0eb8be01..b13e596936a 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -255,6 +255,7 @@ bool EvalScript(vector >& stack, const CScript& script, un static const valtype vchFalse(0); static const valtype vchZero(0); static const valtype vchTrue(1, 1); + bool zkpOpIsUsed = false; CScript::const_iterator pc = script.begin(); CScript::const_iterator pend = script.end(); @@ -1027,6 +1028,14 @@ bool EvalScript(vector >& stack, const CScript& script, un break; case OP_CHECKZKPVERIFY: { + if (zkpOpIsUsed) + { + return set_error(serror, SCRIPT_ERR_BAD_OPCODE); + }else + { + zkpOpIsUsed = true; + } + // Ensure stack has enough elements for the groth16 proof verification if (stack.size() < 12) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);