Skip to content

Commit

Permalink
Merge pull request #3301 from nspcc-dev/keccak256
Browse files Browse the repository at this point in the history
interop: add keccak256 implementation
  • Loading branch information
AnnaShaleva committed Mar 23, 2024
2 parents fa1c07e + c090628 commit 37d7a3a
Show file tree
Hide file tree
Showing 36 changed files with 143 additions and 46 deletions.
2 changes: 1 addition & 1 deletion examples/engine/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/engine/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/events/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/events/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/iterator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/iterator/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/nft-d/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/nft-d/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/nft-nd-nns/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/nspcc-dev/neo-go v0.102.1-0.20231020181554-d89c8801d689
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
github.com/stretchr/testify v1.8.4
)

Expand Down
4 changes: 2 additions & 2 deletions examples/nft-nd-nns/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/neo-go v0.102.1-0.20231020181554-d89c8801d689 h1:WnEdGAQwaW0C8wnNnQZ+rM/JfFKZDSTOqwm8cS0TOdk=
github.com/nspcc-dev/neo-go v0.102.1-0.20231020181554-d89c8801d689/go.mod h1:x+wmcYqpZYJwLp1l/pHZrqNp3RSWlkMymWGDij3/OPo=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 h1:jhuN8Ldqz7WApvUJRFY0bjRXE1R3iCkboMX5QVZhHVk=
github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09fZo+KYi4=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11 h1:QOc8ZRN5DXlAeRPh5QG9u8rMLgoeRNiZF5/vL7QupWg=
Expand Down
2 changes: 1 addition & 1 deletion examples/nft-nd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/nft-nd/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/oracle/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/oracle/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/runtime/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/runtime/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/storage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/storage/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/timer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/timer/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/token/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/token/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion examples/zkp/cubic_circuit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/nspcc-dev/go-ordered-json v0.0.0-20231123160306-3374ff1e7a3c // indirect
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c // indirect
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 // indirect
github.com/nspcc-dev/rfc6979 v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/zkp/cubic_circuit/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ github.com/nspcc-dev/go-ordered-json v0.0.0-20231123160306-3374ff1e7a3c/go.mod h
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/neo-go v0.103.1 h1:BfRBceHUu8jSc1KQy7CzmQ/pa+xzAmgcyteGf0/IGgM=
github.com/nspcc-dev/neo-go v0.103.1/go.mod h1:MD7MPiyshUwrE5n1/LzxeandbItaa/iLW/bJb6gNs/U=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 h1:jhuN8Ldqz7WApvUJRFY0bjRXE1R3iCkboMX5QVZhHVk=
github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09fZo+KYi4=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11 h1:QOc8ZRN5DXlAeRPh5QG9u8rMLgoeRNiZF5/vL7QupWg=
Expand Down
2 changes: 1 addition & 1 deletion examples/zkp/xor_compat/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/zkp/xor

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions examples/zkp/xor_compat/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/mr-tron/base58 v1.2.0
github.com/nspcc-dev/dbft v0.0.0-20230515113611-25db6ba61d5c
github.com/nspcc-dev/go-ordered-json v0.0.0-20240301084351-0246b013f8b2
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11
github.com/nspcc-dev/rfc6979 v0.2.1
github.com/pierrec/lz4 v2.6.1+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ github.com/nspcc-dev/go-ordered-json v0.0.0-20240301084351-0246b013f8b2 h1:mD9hU
github.com/nspcc-dev/go-ordered-json v0.0.0-20240301084351-0246b013f8b2/go.mod h1:U5VfmPNM88P4RORFb6KSUVBdJBDhlqggJZYGXGPxOcc=
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 h1:jhuN8Ldqz7WApvUJRFY0bjRXE1R3iCkboMX5QVZhHVk=
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0/go.mod h1:DRIr0Ic1s+6QgdqmNFNLIqMqd7lNMJfYwkczlm1hDtM=
github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09fZo+KYi4=
Expand Down
2 changes: 1 addition & 1 deletion internal/contracts/oracle_contract/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/internal/examples/oracle

go 1.20

require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7
4 changes: 2 additions & 2 deletions internal/contracts/oracle_contract/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c h1:0IEfyqW25ugbxVI04l8nB1elDe3g5I7QARU2i1LZkWw=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322134659-72484a33eb4c/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7 h1:wULMfaNToxlinz9cYWyZA4kAy6CTUBtJ1yFHjCSgs10=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20240322141543-1840c057bdd7/go.mod h1:/vrbWSHc7YS1KSYhVOyyeucXW/e+1DkVBOgnBEXUCeY=
1 change: 1 addition & 0 deletions pkg/compiler/native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func TestNativeHelpersCompile(t *testing.T) {
{"bls12381Add", []string{"crypto.Bls12381Point{}", "crypto.Bls12381Point{}"}},
{"bls12381Mul", []string{"crypto.Bls12381Point{}", "[]byte{1, 2, 3}", "true"}},
{"bls12381Pairing", []string{"crypto.Bls12381Point{}", "crypto.Bls12381Point{}"}},
{"keccak256", []string{"[]byte{1, 2, 3}"}},
})
runNativeTestCases(t, cs.Std.ContractMD, "std", []nativeTestCase{
{"serialize", []string{"[]byte{1, 2, 3}"}},
Expand Down
19 changes: 19 additions & 0 deletions pkg/core/native/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/twmb/murmur3"
"golang.org/x/crypto/sha3"
)

// Crypto represents CryptoLib contract.
Expand Down Expand Up @@ -101,6 +102,10 @@ func newCrypto() *Crypto {
md = newMethodAndPrice(c.bls12381Pairing, 1<<23, callflag.NoneFlag)
c.AddMethod(md, desc)

desc = newDescriptor("keccak256", smartcontract.ByteArrayType,
manifest.NewParameter("data", smartcontract.ByteArrayType))
md = newMethodAndPrice(c.keccak256, 1<<15, callflag.NoneFlag)
c.AddMethod(md, desc)
return c
}

Expand Down Expand Up @@ -285,6 +290,20 @@ func (c *Crypto) bls12381Pairing(_ *interop.Context, args []stackitem.Item) stac
return stackitem.NewInterop(p)
}

func (c *Crypto) keccak256(_ *interop.Context, args []stackitem.Item) stackitem.Item {
bs, err := args[0].TryBytes()
if err != nil {
panic(err)
}

digest := sha3.NewLegacyKeccak256()
_, err = digest.Write(bs)
if err != nil {
panic(err)
}
return stackitem.NewByteArray(digest.Sum(nil))
}

// Metadata implements the Contract interface.
func (c *Crypto) Metadata() *interop.ContractMD {
return &c.ContractMD
Expand Down
52 changes: 52 additions & 0 deletions pkg/core/native/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,58 @@ func TestSha256(t *testing.T) {
})
}

// TestKeccak256_Compat is a C# node compatibility test with data taken from https://github.com/Jim8y/neo/blob/560d35783e428d31e3681eaa7ee9ed00a8a50d09/tests/Neo.UnitTests/SmartContract/Native/UT_CryptoLib.cs#L340
func TestKeccak256_Compat(t *testing.T) {
c := newCrypto()
ic := &interop.Context{VM: vm.New()}

t.Run("good", func(t *testing.T) {
testCases := []struct {
name string
input []byte
expectedHash string
}{
{"good", []byte{1, 0}, "628bf3596747d233f1e6533345700066bf458fa48daedaf04a7be6c392902476"},
{"hello world", []byte("Hello, World!"), "acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f"},
{"keccak", []byte("Keccak"), "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"},
{"cryptography", []byte("Cryptography"), "53d49d225dd2cfe77d8c5e2112bcc9efe77bea1c7aa5e5ede5798a36e99e2d29"},
{"testing123", []byte("Testing123"), "3f82db7b16b0818a1c6b2c6152e265f682d5ebcf497c9aad776ad38bc39cb6ca"},
{"long string", []byte("This is a longer string for Keccak256 testing purposes."), "24115e5c2359f85f6840b42acd2f7ea47bc239583e576d766fa173bf711bdd2f"},
{"blank string", []byte(""), "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := c.keccak256(ic, []stackitem.Item{stackitem.NewByteArray(tc.input)}).Value().([]byte)
outputHashHex := hex.EncodeToString(result)
require.Equal(t, tc.expectedHash, outputHashHex)
})
}
})
t.Run("errors", func(t *testing.T) {
errCases := []struct {
name string
item stackitem.Item
}{
{
name: "Null item",
item: stackitem.Null{},
},
{
name: "not a byte array",
item: stackitem.NewArray([]stackitem.Item{stackitem.NewBool(true)}),
},
}

for _, tc := range errCases {
t.Run(tc.name, func(t *testing.T) {
require.Panics(t, func() {
_ = c.keccak256(ic, []stackitem.Item{tc.item})
}, "keccak256 should panic with incorrect argument types")
})
}
})
}

func TestRIPEMD160(t *testing.T) {
c := newCrypto()
ic := &interop.Context{VM: vm.New()}
Expand Down
19 changes: 19 additions & 0 deletions pkg/core/native/native_test/cryptolib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ func TestCryptolib_TestBls12381Add_Compat(t *testing.T) {
hex.EncodeToString(arr[:]))
}

func TestKeccak256_Compat(t *testing.T) {
c := newCryptolibClient(t)

in := []byte("Keccak")

expected := "868c016b666c7d3698636ee1bd023f3f065621514ab61bf26f062c175fdbe7f2"

script := io.NewBufBinWriter()
emit.AppCall(script.BinWriter, c.Hash, "keccak256", callflag.All, in)
stack, err := c.TestInvokeScript(t, script.Bytes(), c.Signers)

require.NoError(t, err)
require.Equal(t, 1, stack.Len())
itm := stack.Pop().Item()
require.Equal(t, stackitem.ByteArrayT, itm.Type())
actual := hex.EncodeToString(itm.Value().([]byte))
require.Equal(t, expected, actual)
}

func TestCryptolib_TestBls12381Mul_Compat(t *testing.T) {
c := newCryptolibClient(t)

Expand Down
6 changes: 6 additions & 0 deletions pkg/interop/native/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ func Bls12381Mul(x Bls12381Point, mul []byte, neg bool) Bls12381Point {
func Bls12381Pairing(g1, g2 Bls12381Point) Bls12381Point {
return neogointernal.CallWithToken(Hash, "bls12381Pairing", int(contract.NoneFlag), g1, g2).(Bls12381Point)
}

// Keccak256 calls `keccak256` method of native CryptoLib contract and
// computes Keccak256 hash of b.
func Keccak256(b []byte) interop.Hash256 {
return neogointernal.CallWithToken(Hash, "keccak256", int(contract.NoneFlag), b).(interop.Hash256)
}
2 changes: 1 addition & 1 deletion pkg/services/rpcsrv/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const (
faultedTxHashLE = "82279bfe9bada282ca0f8cb8e0bb124b921af36f00c69a518320322c6f4fef60"
faultedTxBlock uint32 = 23
invokescriptContractAVM = "VwIADBQBDAMOBQYMDQIODw0DDgcJAAAAAErZMCQE2zBwaEH4J+yMqiYEEUAMFA0PAwIJAAIBAwcDBAUCAQAOBgwJStkwJATbMHFpQfgn7IyqJgQSQBNA"
block20StateRootLE = "c62594479ffdfd24dfa27f862313858c0dc197cc7289aa91b78617b1d47c8d98"
block20StateRootLE = "637aac452ef781dee7ac5e898a1edf4d3c5b6420288ea5232dad620f39d2152a"
)

var (
Expand Down

0 comments on commit 37d7a3a

Please sign in to comment.