Skip to content

Commit

Permalink
limit 1 OP_CHECKZKPVERIFY per script
Browse files Browse the repository at this point in the history
  • Loading branch information
zilong-dai committed Oct 31, 2024
1 parent c04c56c commit 429cc78
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ bool EvalScript(vector<vector<unsigned char> >& 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();
Expand Down Expand Up @@ -1027,6 +1028,14 @@ bool EvalScript(vector<vector<unsigned char> >& 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);
Expand Down

0 comments on commit 429cc78

Please sign in to comment.