Skip to content

Commit

Permalink
unique check auth sig validity
Browse files Browse the repository at this point in the history
  • Loading branch information
ak88 committed Sep 4, 2024
1 parent bf78353 commit 6380314
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public bool IsWellFormed(Transaction transaction, IReleaseSpec releaseSpec, out
&& ValidateWithError(Validate1559GasFields(transaction, releaseSpec), TxErrorMessages.InvalidMaxPriorityFeePerGas, ref error)
&& ValidateWithError(Validate3860Rules(transaction, releaseSpec), TxErrorMessages.ContractSizeTooBig, ref error)
&& Validate4844Fields(transaction, ref error)
&& ValidateAuthorityList(transaction, releaseSpec, ref error);
&& ValidateAuthorityList(transaction, ref error);
}

private static bool Validate3860Rules(Transaction transaction, IReleaseSpec releaseSpec) =>
Expand Down Expand Up @@ -163,6 +163,23 @@ private bool ValidateSignature(Signature signature, IReleaseSpec spec)
return true;
}

private bool ValidateAuthoritySignature(Signature signature)
{
if (signature is null)
{
return false;
}

UInt256 sValue = new(signature.SAsSpan, isBigEndian: true);

if (sValue >= Secp256K1Curve.HalfNPlusOne)
{
return false;
}

return signature.RecoveryId is 0 or 1;
}

private static bool Validate4844Fields(Transaction transaction, ref string? error)
{
// Execution-payload version verification
Expand Down Expand Up @@ -306,7 +323,7 @@ private static bool Validate4844Fields(Transaction transaction, ref string? erro
return true;
}

private bool ValidateAuthorityList(Transaction tx, IReleaseSpec releaseSpec, ref string error)
private bool ValidateAuthorityList(Transaction tx, ref string error)
{
if (tx.Type != TxType.SetCode)
{
Expand All @@ -321,7 +338,7 @@ private bool ValidateAuthorityList(Transaction tx, IReleaseSpec releaseSpec, ref
error = TxErrorMessages.MissingAuthorizationList;
return false;
}
else if (tx.AuthorizationList.Any(a => !ValidateSignature(a.AuthoritySignature, releaseSpec)))
else if (tx.AuthorizationList.Any(a => !ValidateAuthoritySignature(a.AuthoritySignature)))
{
error = TxErrorMessages.InvalidAuthoritySignature;
return false;
Expand Down

0 comments on commit 6380314

Please sign in to comment.