From 7570cec5ad089f8f2f8d381776f76220d6a7612d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 3 Jan 2023 15:58:09 -0500 Subject: [PATCH 01/30] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..80213f3297 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '34 22 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From 12bafdb050f83c268733432ac5a21da873f3c35d Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Sat, 30 Sep 2023 18:01:07 +0800 Subject: [PATCH 02/30] Keccak256 --- src/Neo/SmartContract/Native/CryptoLib.cs | 27 +++++++++++++++---- .../SmartContract/Native/UT_CryptoLib.cs | 17 +++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 16ec960a27..1c1a10d670 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2015-2022 The Neo Project. -// -// The neo is free software distributed under the MIT software license, +// Copyright (C) 2015-2023 The Neo Project. +// +// The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the -// project or http://www.opensource.org/licenses/mit-license.php +// project or http://www.opensource.org/licenses/mit-license.php // for more details. -// +// // Redistribution and use in source and binary forms with or without // modifications are permitted. @@ -12,6 +12,8 @@ using Neo.Cryptography.ECC; using System; using System.Collections.Generic; +using System.Text; +using Org.BouncyCastle.Crypto.Digests; namespace Neo.SmartContract.Native { @@ -63,6 +65,21 @@ public static byte[] Murmur32(byte[] data, uint seed) return murmur.ComputeHash(data); } + /// + /// Computes the hash value for the specified byte array using the keccak256 algorithm. + /// + /// The input to compute the hash code for. + /// + [ContractMethod(CpuFee = 1 << 15)] + public static byte[] Keccak256(byte[] data) + { + KeccakDigest keccak = new KeccakDigest(256); + keccak.BlockUpdate(data, 0, data.Length); + byte[] result = new byte[keccak.GetDigestSize()]; + keccak.DoFinal(result, 0); + return result; + } + /// /// Verifies that a digital signature is appropriate for the provided key and message using the ECDSA algorithm. /// diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index f6e142500a..9c4a5eb48a 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -4,7 +4,7 @@ using Neo.SmartContract; using Neo.SmartContract.Native; using Neo.VM; -using System.Security.Cryptography; +using Org.BouncyCastle.Utilities.Encoders; namespace Neo.UnitTests.SmartContract.Native { @@ -324,5 +324,20 @@ public void TestBls12381ScalarMul_Compat() BLS12381PointType.G2Proj ); } + + [TestMethod] + public void TestKeccak256() + { + // Arrange + byte[] inputData = "Hello, Keccak!"u8.ToArray(); + string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + } } } From b4f6ed81160a36ea3e5b4a1f20c578ae30a9a3dc Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 30 Sep 2023 05:02:41 -0500 Subject: [PATCH 03/30] Delete .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 76 ------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 80213f3297..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '34 22 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" From 896a790b9bc52931342519cd536ad370eedc424e Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 2 Oct 2023 01:35:36 -0700 Subject: [PATCH 04/30] Update src/Neo/SmartContract/Native/CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 1c1a10d670..c253bea733 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -69,7 +69,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// Computes the hash value for the specified byte array using the keccak256 algorithm. /// /// The input to compute the hash code for. - /// + /// Computed hash [ContractMethod(CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { From c1ee50a31ff2916470733483a502fcfe06f29ce7 Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Mon, 9 Oct 2023 17:54:35 +0800 Subject: [PATCH 05/30] add more keccak256 test cases as required --- .../SmartContract/Native/UT_CryptoLib.cs | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 9c4a5eb48a..4d99b16e32 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -325,19 +325,97 @@ public void TestBls12381ScalarMul_Compat() ); } + /// + /// Keccak256 cases are verified in https://emn178.github.io/online-tools/keccak_256.html + /// [TestMethod] - public void TestKeccak256() + public void TestKeccak256_HelloWorld() { // Arrange - byte[] inputData = "Hello, Keccak!"u8.ToArray(); - string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + byte[] inputData = "Hello, World!"u8.ToArray(); + string expectedHashHex = "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"; // Act byte[] outputData = CryptoLib.Keccak256(inputData); string outputHashHex = Hex.ToHexString(outputData); // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Hello, World!'."); } + [TestMethod] + public void TestKeccak256_Keccak() + { + // Arrange + byte[] inputData = "Keccak"u8.ToArray(); + string expectedHashHex = "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Keccak'."); + } + + [TestMethod] + public void TestKeccak256_Cryptography() + { + // Arrange + byte[] inputData = "Cryptography"u8.ToArray(); + string expectedHashHex = "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Cryptography'."); + } + + [TestMethod] + public void TestKeccak256_Testing123() + { + // Arrange + byte[] inputData = "Testing123"u8.ToArray(); + string expectedHashHex = "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Testing123'."); + } + + [TestMethod] + public void TestKeccak256_LongString() + { + // Arrange + byte[] inputData = "This is a longer string for Keccak256 testing purposes."u8.ToArray(); + string expectedHashHex = "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for the longer string."); + } + + [TestMethod] + public void TestKeccak256_BlankString() + { + // Arrange + byte[] inputData = ""u8.ToArray(); + string expectedHashHex = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); + } + } } From bf57c50443ada2aa0bfaadb0afa493eb190ae81a Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 3 Jan 2023 15:58:09 -0500 Subject: [PATCH 06/30] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..80213f3297 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '34 22 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From c95a6c53571bc10e9998df41b18d3663e3944e1d Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Sat, 30 Sep 2023 18:01:07 +0800 Subject: [PATCH 07/30] Keccak256 --- src/Neo/SmartContract/Native/CryptoLib.cs | 27 +++++++++++++++---- .../SmartContract/Native/UT_CryptoLib.cs | 17 +++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 16ec960a27..1c1a10d670 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2015-2022 The Neo Project. -// -// The neo is free software distributed under the MIT software license, +// Copyright (C) 2015-2023 The Neo Project. +// +// The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the -// project or http://www.opensource.org/licenses/mit-license.php +// project or http://www.opensource.org/licenses/mit-license.php // for more details. -// +// // Redistribution and use in source and binary forms with or without // modifications are permitted. @@ -12,6 +12,8 @@ using Neo.Cryptography.ECC; using System; using System.Collections.Generic; +using System.Text; +using Org.BouncyCastle.Crypto.Digests; namespace Neo.SmartContract.Native { @@ -63,6 +65,21 @@ public static byte[] Murmur32(byte[] data, uint seed) return murmur.ComputeHash(data); } + /// + /// Computes the hash value for the specified byte array using the keccak256 algorithm. + /// + /// The input to compute the hash code for. + /// + [ContractMethod(CpuFee = 1 << 15)] + public static byte[] Keccak256(byte[] data) + { + KeccakDigest keccak = new KeccakDigest(256); + keccak.BlockUpdate(data, 0, data.Length); + byte[] result = new byte[keccak.GetDigestSize()]; + keccak.DoFinal(result, 0); + return result; + } + /// /// Verifies that a digital signature is appropriate for the provided key and message using the ECDSA algorithm. /// diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index f6e142500a..9c4a5eb48a 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -4,7 +4,7 @@ using Neo.SmartContract; using Neo.SmartContract.Native; using Neo.VM; -using System.Security.Cryptography; +using Org.BouncyCastle.Utilities.Encoders; namespace Neo.UnitTests.SmartContract.Native { @@ -324,5 +324,20 @@ public void TestBls12381ScalarMul_Compat() BLS12381PointType.G2Proj ); } + + [TestMethod] + public void TestKeccak256() + { + // Arrange + byte[] inputData = "Hello, Keccak!"u8.ToArray(); + string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + } } } From 3057cc790861fba89124adf7a32f9230a1a7fe30 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 30 Sep 2023 05:02:41 -0500 Subject: [PATCH 08/30] Delete .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 76 ------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 80213f3297..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '34 22 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" From a9308c81dd992dc1d130b9d7593cdf01309cd3d0 Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 2 Oct 2023 01:35:36 -0700 Subject: [PATCH 09/30] Update src/Neo/SmartContract/Native/CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 1c1a10d670..c253bea733 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -69,7 +69,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// Computes the hash value for the specified byte array using the keccak256 algorithm. /// /// The input to compute the hash code for. - /// + /// Computed hash [ContractMethod(CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { From 6ed7e06bf68a61839ecdedb47db282a4296f5604 Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Mon, 9 Oct 2023 17:54:35 +0800 Subject: [PATCH 10/30] add more keccak256 test cases as required --- .../SmartContract/Native/UT_CryptoLib.cs | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 9c4a5eb48a..4d99b16e32 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -325,19 +325,97 @@ public void TestBls12381ScalarMul_Compat() ); } + /// + /// Keccak256 cases are verified in https://emn178.github.io/online-tools/keccak_256.html + /// [TestMethod] - public void TestKeccak256() + public void TestKeccak256_HelloWorld() { // Arrange - byte[] inputData = "Hello, Keccak!"u8.ToArray(); - string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + byte[] inputData = "Hello, World!"u8.ToArray(); + string expectedHashHex = "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"; // Act byte[] outputData = CryptoLib.Keccak256(inputData); string outputHashHex = Hex.ToHexString(outputData); // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Hello, World!'."); } + [TestMethod] + public void TestKeccak256_Keccak() + { + // Arrange + byte[] inputData = "Keccak"u8.ToArray(); + string expectedHashHex = "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Keccak'."); + } + + [TestMethod] + public void TestKeccak256_Cryptography() + { + // Arrange + byte[] inputData = "Cryptography"u8.ToArray(); + string expectedHashHex = "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Cryptography'."); + } + + [TestMethod] + public void TestKeccak256_Testing123() + { + // Arrange + byte[] inputData = "Testing123"u8.ToArray(); + string expectedHashHex = "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Testing123'."); + } + + [TestMethod] + public void TestKeccak256_LongString() + { + // Arrange + byte[] inputData = "This is a longer string for Keccak256 testing purposes."u8.ToArray(); + string expectedHashHex = "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for the longer string."); + } + + [TestMethod] + public void TestKeccak256_BlankString() + { + // Arrange + byte[] inputData = ""u8.ToArray(); + string expectedHashHex = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); + } + } } From a0206756b9372a480159526b91def4e372ed4fa5 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Mon, 6 Nov 2023 13:57:14 +0100 Subject: [PATCH 11/30] HF_Manticore --- src/Neo/Hardfork.cs | 3 ++- src/Neo/SmartContract/Native/CryptoLib.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Neo/Hardfork.cs b/src/Neo/Hardfork.cs index 5a9aef6b5c..25a208219a 100644 --- a/src/Neo/Hardfork.cs +++ b/src/Neo/Hardfork.cs @@ -13,6 +13,7 @@ namespace Neo public enum Hardfork : byte { HF_Aspidochelone, - HF_Basilisk + HF_Basilisk, + HF_Manticore } } diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index c253bea733..01117ad60c 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -70,10 +70,10 @@ public static byte[] Murmur32(byte[] data, uint seed) /// /// The input to compute the hash code for. /// Computed hash - [ContractMethod(CpuFee = 1 << 15)] + [ContractMethod(CpuFee = 1 << 15, ActiveIn = Hardfork.HF_Manticore)] public static byte[] Keccak256(byte[] data) { - KeccakDigest keccak = new KeccakDigest(256); + KeccakDigest keccak = new(256); keccak.BlockUpdate(data, 0, data.Length); byte[] result = new byte[keccak.GetDigestSize()]; keccak.DoFinal(result, 0); From 1e7f74512d11a9d2f2fab8cc07b01b9f2360d6f4 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Mon, 6 Nov 2023 14:00:15 +0100 Subject: [PATCH 12/30] Fix copyright --- src/Neo/Hardfork.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/Hardfork.cs b/src/Neo/Hardfork.cs index 25a208219a..cbba158059 100644 --- a/src/Neo/Hardfork.cs +++ b/src/Neo/Hardfork.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2022 The Neo Project. +// Copyright (C) 2015-2023 The Neo Project. // // The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the From e5f537873e3637d31e95641bef9c768e5492e7c7 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 3 Jan 2023 15:58:09 -0500 Subject: [PATCH 13/30] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..80213f3297 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '34 22 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From edd693f5996385ff5802776a8d3175eb29d1d377 Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Sat, 30 Sep 2023 18:01:07 +0800 Subject: [PATCH 14/30] Keccak256 --- src/Neo/SmartContract/Native/CryptoLib.cs | 27 +++++++++++++++---- .../SmartContract/Native/UT_CryptoLib.cs | 17 +++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 16ec960a27..1c1a10d670 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -1,10 +1,10 @@ -// Copyright (C) 2015-2022 The Neo Project. -// -// The neo is free software distributed under the MIT software license, +// Copyright (C) 2015-2023 The Neo Project. +// +// The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the -// project or http://www.opensource.org/licenses/mit-license.php +// project or http://www.opensource.org/licenses/mit-license.php // for more details. -// +// // Redistribution and use in source and binary forms with or without // modifications are permitted. @@ -12,6 +12,8 @@ using Neo.Cryptography.ECC; using System; using System.Collections.Generic; +using System.Text; +using Org.BouncyCastle.Crypto.Digests; namespace Neo.SmartContract.Native { @@ -63,6 +65,21 @@ public static byte[] Murmur32(byte[] data, uint seed) return murmur.ComputeHash(data); } + /// + /// Computes the hash value for the specified byte array using the keccak256 algorithm. + /// + /// The input to compute the hash code for. + /// + [ContractMethod(CpuFee = 1 << 15)] + public static byte[] Keccak256(byte[] data) + { + KeccakDigest keccak = new KeccakDigest(256); + keccak.BlockUpdate(data, 0, data.Length); + byte[] result = new byte[keccak.GetDigestSize()]; + keccak.DoFinal(result, 0); + return result; + } + /// /// Verifies that a digital signature is appropriate for the provided key and message using the ECDSA algorithm. /// diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index f6e142500a..9c4a5eb48a 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -4,7 +4,7 @@ using Neo.SmartContract; using Neo.SmartContract.Native; using Neo.VM; -using System.Security.Cryptography; +using Org.BouncyCastle.Utilities.Encoders; namespace Neo.UnitTests.SmartContract.Native { @@ -324,5 +324,20 @@ public void TestBls12381ScalarMul_Compat() BLS12381PointType.G2Proj ); } + + [TestMethod] + public void TestKeccak256() + { + // Arrange + byte[] inputData = "Hello, Keccak!"u8.ToArray(); + string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + } } } From cc388bd89ead66873c284083f38100cce8b7afd5 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 30 Sep 2023 05:02:41 -0500 Subject: [PATCH 15/30] Delete .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 76 ------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 80213f3297..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '34 22 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" From f7d8ada512f6f01d14dd7f5035037801b16dac94 Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 2 Oct 2023 01:35:36 -0700 Subject: [PATCH 16/30] Update src/Neo/SmartContract/Native/CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 1c1a10d670..c253bea733 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -69,7 +69,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// Computes the hash value for the specified byte array using the keccak256 algorithm. /// /// The input to compute the hash code for. - /// + /// Computed hash [ContractMethod(CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { From b2aa41cc00763c87fce93ba32361eb7b3074f134 Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Mon, 9 Oct 2023 17:54:35 +0800 Subject: [PATCH 17/30] add more keccak256 test cases as required --- .../SmartContract/Native/UT_CryptoLib.cs | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 9c4a5eb48a..4d99b16e32 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -325,19 +325,97 @@ public void TestBls12381ScalarMul_Compat() ); } + /// + /// Keccak256 cases are verified in https://emn178.github.io/online-tools/keccak_256.html + /// [TestMethod] - public void TestKeccak256() + public void TestKeccak256_HelloWorld() { // Arrange - byte[] inputData = "Hello, Keccak!"u8.ToArray(); - string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + byte[] inputData = "Hello, World!"u8.ToArray(); + string expectedHashHex = "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"; // Act byte[] outputData = CryptoLib.Keccak256(inputData); string outputHashHex = Hex.ToHexString(outputData); // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Hello, World!'."); } + [TestMethod] + public void TestKeccak256_Keccak() + { + // Arrange + byte[] inputData = "Keccak"u8.ToArray(); + string expectedHashHex = "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Keccak'."); + } + + [TestMethod] + public void TestKeccak256_Cryptography() + { + // Arrange + byte[] inputData = "Cryptography"u8.ToArray(); + string expectedHashHex = "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Cryptography'."); + } + + [TestMethod] + public void TestKeccak256_Testing123() + { + // Arrange + byte[] inputData = "Testing123"u8.ToArray(); + string expectedHashHex = "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Testing123'."); + } + + [TestMethod] + public void TestKeccak256_LongString() + { + // Arrange + byte[] inputData = "This is a longer string for Keccak256 testing purposes."u8.ToArray(); + string expectedHashHex = "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for the longer string."); + } + + [TestMethod] + public void TestKeccak256_BlankString() + { + // Arrange + byte[] inputData = ""u8.ToArray(); + string expectedHashHex = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); + } + } } From d9ccc45a8be6cb736f498272562dd1aee705e510 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 3 Jan 2023 15:58:09 -0500 Subject: [PATCH 18/30] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..80213f3297 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '34 22 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From d1363ad668251170cddf6901dfdc9253047b256f Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Sat, 30 Sep 2023 18:01:07 +0800 Subject: [PATCH 19/30] Keccak256 --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- .../SmartContract/Native/UT_CryptoLib.cs | 86 +------------------ 2 files changed, 5 insertions(+), 83 deletions(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index c253bea733..1c1a10d670 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -69,7 +69,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// Computes the hash value for the specified byte array using the keccak256 algorithm. /// /// The input to compute the hash code for. - /// Computed hash + /// [ContractMethod(CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 4d99b16e32..9c4a5eb48a 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -325,97 +325,19 @@ public void TestBls12381ScalarMul_Compat() ); } - /// - /// Keccak256 cases are verified in https://emn178.github.io/online-tools/keccak_256.html - /// [TestMethod] - public void TestKeccak256_HelloWorld() + public void TestKeccak256() { // Arrange - byte[] inputData = "Hello, World!"u8.ToArray(); - string expectedHashHex = "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"; + byte[] inputData = "Hello, Keccak!"u8.ToArray(); + string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; // Act byte[] outputData = CryptoLib.Keccak256(inputData); string outputHashHex = Hex.ToHexString(outputData); // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Hello, World!'."); + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); } - [TestMethod] - public void TestKeccak256_Keccak() - { - // Arrange - byte[] inputData = "Keccak"u8.ToArray(); - string expectedHashHex = "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"; - - // Act - byte[] outputData = CryptoLib.Keccak256(inputData); - string outputHashHex = Hex.ToHexString(outputData); - - // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Keccak'."); - } - - [TestMethod] - public void TestKeccak256_Cryptography() - { - // Arrange - byte[] inputData = "Cryptography"u8.ToArray(); - string expectedHashHex = "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"; - - // Act - byte[] outputData = CryptoLib.Keccak256(inputData); - string outputHashHex = Hex.ToHexString(outputData); - - // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Cryptography'."); - } - - [TestMethod] - public void TestKeccak256_Testing123() - { - // Arrange - byte[] inputData = "Testing123"u8.ToArray(); - string expectedHashHex = "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"; - - // Act - byte[] outputData = CryptoLib.Keccak256(inputData); - string outputHashHex = Hex.ToHexString(outputData); - - // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Testing123'."); - } - - [TestMethod] - public void TestKeccak256_LongString() - { - // Arrange - byte[] inputData = "This is a longer string for Keccak256 testing purposes."u8.ToArray(); - string expectedHashHex = "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"; - - // Act - byte[] outputData = CryptoLib.Keccak256(inputData); - string outputHashHex = Hex.ToHexString(outputData); - - // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for the longer string."); - } - - [TestMethod] - public void TestKeccak256_BlankString() - { - // Arrange - byte[] inputData = ""u8.ToArray(); - string expectedHashHex = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"; - - // Act - byte[] outputData = CryptoLib.Keccak256(inputData); - string outputHashHex = Hex.ToHexString(outputData); - - // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); - } - } } From a23192a57a0e7258763110a31990339857774f1c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 30 Sep 2023 05:02:41 -0500 Subject: [PATCH 20/30] Delete .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 76 ------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 80213f3297..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,76 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '34 22 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" From 200e91f5f9cf7d2a04b749112de735c35bd5673d Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 2 Oct 2023 01:35:36 -0700 Subject: [PATCH 21/30] Update src/Neo/SmartContract/Native/CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 1c1a10d670..c253bea733 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -69,7 +69,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// Computes the hash value for the specified byte array using the keccak256 algorithm. /// /// The input to compute the hash code for. - /// + /// Computed hash [ContractMethod(CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { From 25cdb28c9208e78ad8e5412bc3642e58108e13cb Mon Sep 17 00:00:00 2001 From: Jinghui Liao Date: Mon, 9 Oct 2023 17:54:35 +0800 Subject: [PATCH 22/30] add more keccak256 test cases as required --- .../SmartContract/Native/UT_CryptoLib.cs | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 9c4a5eb48a..4d99b16e32 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -325,19 +325,97 @@ public void TestBls12381ScalarMul_Compat() ); } + /// + /// Keccak256 cases are verified in https://emn178.github.io/online-tools/keccak_256.html + /// [TestMethod] - public void TestKeccak256() + public void TestKeccak256_HelloWorld() { // Arrange - byte[] inputData = "Hello, Keccak!"u8.ToArray(); - string expectedHashHex = "49222c3dd1a2b5cf30a8720050c31844dbc8eca466595b5ce9c11932b7aac985"; + byte[] inputData = "Hello, World!"u8.ToArray(); + string expectedHashHex = "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"; // Act byte[] outputData = CryptoLib.Keccak256(inputData); string outputHashHex = Hex.ToHexString(outputData); // Assert - Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value."); + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Hello, World!'."); } + [TestMethod] + public void TestKeccak256_Keccak() + { + // Arrange + byte[] inputData = "Keccak"u8.ToArray(); + string expectedHashHex = "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Keccak'."); + } + + [TestMethod] + public void TestKeccak256_Cryptography() + { + // Arrange + byte[] inputData = "Cryptography"u8.ToArray(); + string expectedHashHex = "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Cryptography'."); + } + + [TestMethod] + public void TestKeccak256_Testing123() + { + // Arrange + byte[] inputData = "Testing123"u8.ToArray(); + string expectedHashHex = "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for 'Testing123'."); + } + + [TestMethod] + public void TestKeccak256_LongString() + { + // Arrange + byte[] inputData = "This is a longer string for Keccak256 testing purposes."u8.ToArray(); + string expectedHashHex = "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for the longer string."); + } + + [TestMethod] + public void TestKeccak256_BlankString() + { + // Arrange + byte[] inputData = ""u8.ToArray(); + string expectedHashHex = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"; + + // Act + byte[] outputData = CryptoLib.Keccak256(inputData); + string outputHashHex = Hex.ToHexString(outputData); + + // Assert + Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); + } + } } From 3983a3240e07aa38cf0389d3e8ef7a0fee2e4ec2 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Mon, 6 Nov 2023 13:57:14 +0100 Subject: [PATCH 23/30] HF_Manticore --- src/Neo/Hardfork.cs | 3 ++- src/Neo/SmartContract/Native/CryptoLib.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Neo/Hardfork.cs b/src/Neo/Hardfork.cs index 5a9aef6b5c..25a208219a 100644 --- a/src/Neo/Hardfork.cs +++ b/src/Neo/Hardfork.cs @@ -13,6 +13,7 @@ namespace Neo public enum Hardfork : byte { HF_Aspidochelone, - HF_Basilisk + HF_Basilisk, + HF_Manticore } } diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index c253bea733..01117ad60c 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -70,10 +70,10 @@ public static byte[] Murmur32(byte[] data, uint seed) /// /// The input to compute the hash code for. /// Computed hash - [ContractMethod(CpuFee = 1 << 15)] + [ContractMethod(CpuFee = 1 << 15, ActiveIn = Hardfork.HF_Manticore)] public static byte[] Keccak256(byte[] data) { - KeccakDigest keccak = new KeccakDigest(256); + KeccakDigest keccak = new(256); keccak.BlockUpdate(data, 0, data.Length); byte[] result = new byte[keccak.GetDigestSize()]; keccak.DoFinal(result, 0); From d6d6f85fb71923c411122b7feddab2afa3c3572f Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Mon, 6 Nov 2023 14:00:15 +0100 Subject: [PATCH 24/30] Fix copyright --- src/Neo/Hardfork.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/Hardfork.cs b/src/Neo/Hardfork.cs index 25a208219a..cbba158059 100644 --- a/src/Neo/Hardfork.cs +++ b/src/Neo/Hardfork.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2022 The Neo Project. +// Copyright (C) 2015-2023 The Neo Project. // // The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the From 7cac796d56607900dd0ffc4bd61de926bc29b0e0 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Mon, 6 Nov 2023 14:08:34 +0100 Subject: [PATCH 25/30] HF_Manticore --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 01117ad60c..ebe991fb57 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -70,7 +70,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// /// The input to compute the hash code for. /// Computed hash - [ContractMethod(CpuFee = 1 << 15, ActiveIn = Hardfork.HF_Manticore)] + [ContractMethod(Hardfork.HF_Manticore, CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { KeccakDigest keccak = new(256); From 16676ad237d106b3f6dd8da57423067063f133c3 Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 2 Jan 2024 04:58:30 -0800 Subject: [PATCH 26/30] Update CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 0f8e205daf..e4215b77c6 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -1,4 +1,4 @@ -right (C) 2015-2024 The Neo Project. +// Copyright right (C) 2015-2024 The Neo Project. // // CryptoLib.cs file belongs to the neo project and is free // software distributed under the MIT software license, see the From 4171bc053544d53a39e17152a35188bdb5ea6921 Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 2 Jan 2024 04:59:02 -0800 Subject: [PATCH 27/30] Update CryptoLib.cs --- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index e4215b77c6..08d6bfcdeb 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -1,4 +1,4 @@ -// Copyright right (C) 2015-2024 The Neo Project. +// Copyright (C) 2015-2024 The Neo Project. // // CryptoLib.cs file belongs to the neo project and is free // software distributed under the MIT software license, see the From 60a1de12c8b684f8352b807977d5eb6fefcc5eab Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 2 Jan 2024 04:59:24 -0800 Subject: [PATCH 28/30] Update UT_CryptoLib.cs --- tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs index 66712f4320..6f150cca12 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs @@ -427,6 +427,5 @@ public void TestKeccak256_BlankString() // Assert Assert.AreEqual(expectedHashHex, outputHashHex, "Keccak256 hash did not match expected value for blank string."); } - } } From f9c32593aea98230dcb8df9d95c4ef45a0e70f5b Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 2 Jan 2024 05:01:15 -0800 Subject: [PATCH 29/30] Apply suggestions from code review --- src/Neo/Hardfork.cs | 2 +- src/Neo/SmartContract/Native/CryptoLib.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo/Hardfork.cs b/src/Neo/Hardfork.cs index 627d6ff791..9ef6a63c1c 100644 --- a/src/Neo/Hardfork.cs +++ b/src/Neo/Hardfork.cs @@ -15,6 +15,6 @@ public enum Hardfork : byte { HF_Aspidochelone, HF_Basilisk, - HF_Manticore + HF_Cockatrice } } diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index 08d6bfcdeb..ec95f73b91 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -71,7 +71,7 @@ public static byte[] Murmur32(byte[] data, uint seed) /// /// The input to compute the hash code for. /// Computed hash - [ContractMethod(Hardfork.HF_Manticore, CpuFee = 1 << 15)] + [ContractMethod(Hardfork.HF_Cockatrice, CpuFee = 1 << 15)] public static byte[] Keccak256(byte[] data) { KeccakDigest keccak = new(256); From 560d35783e428d31e3681eaa7ee9ed00a8a50d09 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Tue, 2 Jan 2024 14:02:10 +0100 Subject: [PATCH 30/30] clean usings --- src/Neo/SmartContract/Native/CryptoLib.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Neo/SmartContract/Native/CryptoLib.cs b/src/Neo/SmartContract/Native/CryptoLib.cs index ec95f73b91..a7b822e39c 100644 --- a/src/Neo/SmartContract/Native/CryptoLib.cs +++ b/src/Neo/SmartContract/Native/CryptoLib.cs @@ -11,10 +11,9 @@ using Neo.Cryptography; using Neo.Cryptography.ECC; +using Org.BouncyCastle.Crypto.Digests; using System; using System.Collections.Generic; -using System.Text; -using Org.BouncyCastle.Crypto.Digests; namespace Neo.SmartContract.Native {