Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartContract: catch exception on multisignature contract parsing #3211

Merged
merged 1 commit into from
May 5, 2024

Commits on May 4, 2024

  1. SmartContract: catch exception on multisignature contract parsing

    IsMultiSigContract should return proper true/false result even if some
    garbage is provided as an input. Without this commit an exception is
    possible during IsMultiSigContract execution during subsequent public
    key decoding from compressed form:
    ```
      Failed TestIsMultiSigContract [16 ms]
      Error Message:
       Test method Neo.UnitTests.SmartContract.UT_Helper.TestIsMultiSigContract threw exception:
    System.FormatException: Invalid point encoding 221
      Stack Trace:
          at Neo.Cryptography.ECC.ECPoint.DecodePoint(ReadOnlySpan`1 encoded, ECCurve curve) in /home/anna/Documents/GitProjects/neo-project/neo/src/Neo/Cryptography/ECC/ECPoint.cs:line 98
       at Neo.SmartContract.Helper.IsMultiSigContract(ReadOnlySpan`1 script, Int32& m, Int32& n, List`1 points) in /home/anna/Documents/GitProjects/neo-project/neo/src/Neo/SmartContract/Helper.cs:line 189
       at Neo.SmartContract.Helper.IsMultiSigContract(ReadOnlySpan`1 script) in /home/anna/Documents/GitProjects/neo-project/neo/src/Neo/SmartContract/Helper.cs:line 123
       at Neo.UnitTests.SmartContract.UT_Helper.TestIsMultiSigContract() in /home/anna/Documents/GitProjects/neo-project/neo/tests/Neo.UnitTests/SmartContract/UT_Helper.cs:line 65
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
       at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    ```
    
    Note that this change is compatible wrt the callers' behaviour. We need
    this change to properly handle non-Secp256r1-based witness scripts, ref.
    #3209.
    
    Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
    AnnaShaleva committed May 4, 2024
    Configuration menu
    Copy the full SHA
    c37d503 View commit details
    Browse the repository at this point in the history