Skip to content

Commit

Permalink
use go 1.21, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
joeqian10 committed Jul 16, 2024
1 parent 7ea8b0f commit 032a8ab
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 60 deletions.
23 changes: 20 additions & 3 deletions crypto/base64_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package crypto

import (
"github.com/joeqian10/neo3-gogogo/helper"
"github.com/stretchr/testify/assert"
"log"
"testing"

"github.com/stretchr/testify/assert"

"github.com/joeqian10/neo3-gogogo/helper"
)

func TestBase64Encode(t *testing.T) {
Expand All @@ -22,7 +24,7 @@ func TestBase64Decode(t *testing.T) {
}

func TestBase64Decode2(t *testing.T) {
s := "A4uK9iEOz9y8qyJVLvjYz0HG+G+c+atT2GV0HP24M/Br"
s := "U2FsdGVkX1+iX5Ey7GqLND5UFUoV0b7rUJ2eEvHkYqA="
decoded, err := Base64Decode(s)
assert.Nil(t, err)
ss := helper.BytesToHex(decoded)
Expand All @@ -36,3 +38,18 @@ func TestBase64Decode3(t *testing.T) {
ss := string(decoded)
assert.Equal(t, "Transaction has been executed", ss)
}

func TestBase64Decode4(t *testing.T) {
s := "FPHOAtHWr86lTMPb00238i9KzaWhFK17JowKjp28yE2ZYrJNkaYtDc1e05dZaMvZ1w0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD9IQMEbQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfuhtBlhDF/iAa1Gfzmowxg8BULN+6G0GWEMX+IBrUZ/OajDGDwFQs37obQZYQxf4gGtRn85qMMYPAVCzfug="
decoded, err := Base64Decode(s)
assert.Nil(t, err)
log.Println(helper.BytesToHex(decoded))
}

func TestBase64Decode5(t *testing.T) {
s := "TW/Nz+UkOwvhddhFmcl3fCXb3Uw="
decoded, err := Base64Decode(s)
assert.Nil(t, err)
ss := helper.BytesToHex(decoded)
log.Println(ss)
}
8 changes: 5 additions & 3 deletions crypto/helper_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package crypto

import (
"github.com/joeqian10/neo3-gogogo/helper"
"github.com/stretchr/testify/assert"
"log"
"testing"

"github.com/stretchr/testify/assert"

"github.com/joeqian10/neo3-gogogo/helper"
)

func TestAddressToScriptHash(t *testing.T) {
Expand All @@ -26,7 +28,7 @@ func TestScriptHashToAddress(t *testing.T) {
assert.Equal(t, "NdtB8RXRmJ7Nhw1FPTm7E6HoDZGnDw37nf", a)
}

func TestConvert(t *testing.T) {
func TestConvert(t *testing.T) {
bs, err := Base64Decode("4rZTInKT6ZxPKQbVNVOrtKZy34Y=")
assert.Nil(t, err)
u := helper.UInt160FromBytes(bs)
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module github.com/joeqian10/neo3-gogogo

go 1.18
go 1.21

require (
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.1.0
golang.org/x/text v0.4.0
toolchain go1.21.4

Check failure on line 5 in go.mod

View workflow job for this annotation

GitHub Actions / Build

unknown directive: toolchain

require (
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.25.0
golang.org/x/text v0.16.0
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.1.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
83 changes: 73 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,80 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI=
github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo=
github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/ethereum/go-ethereum v1.14.0 h1:xRWC5NlB6g1x7vNy4HDBLuqVNbtLrc7v8S6+Uxim1LU=
github.com/ethereum/go-ethereum v1.14.0/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
5 changes: 3 additions & 2 deletions helper/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package helper
import (
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"log"
"math/big"
"strconv"
"testing"

"github.com/stretchr/testify/assert"
)

func TestBytesToHex(t *testing.T) {
Expand Down Expand Up @@ -138,7 +139,7 @@ func TestBigIntFromNeoBytes(t *testing.T) {
assert.Equal(t, 0, big.NewInt(-200).Cmp(b))
}

func TestUp(t *testing.T) {
func TestUp(t *testing.T) {
bi := ConvertFloat64StringToBigInt(strconv.FormatUint(5698643, 10), 36-8-2)
fmt.Println(bi.String())
}
4 changes: 3 additions & 1 deletion keys/keyPair.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"crypto/rand"
"crypto/sha256"
"fmt"
"math/big"

"golang.org/x/crypto/scrypt"
"golang.org/x/text/unicode/norm"
"math/big"

"github.com/joeqian10/neo3-gogogo/crypto"
"github.com/joeqian10/neo3-gogogo/helper"
Expand Down Expand Up @@ -236,6 +237,7 @@ func VerifyMultiSig(message []byte, signatures [][]byte, pubKeys []crypto.ECPoin
j++
if m-i > n-j {
success = false
break
}
}
return success
Expand Down
13 changes: 4 additions & 9 deletions keys/keyPair_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package keys

import (
"github.com/joeqian10/neo3-gogogo/helper"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/joeqian10/neo3-gogogo/helper"
)

func TestGenerateKeyPair(t *testing.T) {
Expand Down Expand Up @@ -133,10 +135,3 @@ func TestVerifySignature2(t *testing.T) {
actual := VerifySignature(sample, signedData, wrongPubKey)
assert.Equal(t, false, actual)
}

func TestNewKeyPairFromNEP22(t *testing.T) {
nep2Key := "6PYURwh7xSUBA6yEbBsnYCGESd7UNHi3iWHsDweCxwzEH8xPBSphb1z7ss"
pwd := "poly"
_, err := NewKeyPairFromNEP2(nep2Key, pwd, helper.DefaultAddressVersion, N, R, P)
assert.Nil(t, err)
}
Loading

0 comments on commit 032a8ab

Please sign in to comment.