Skip to content

Commit

Permalink
Merge pull request #112 from Zilliqa/111_update_dependencies
Browse files Browse the repository at this point in the history
#111: update dependencies
  • Loading branch information
rrw-zilliqa authored Jan 11, 2023
2 parents 2ff222c + 44a849f commit d457f1b
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Emacs backups.
*~
\#*
.\#*

.idea/
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.15.8-alpine
LABEL maintainer="Ren xiaohuo <lulu@zilliqa.com>"
FROM golang:1.19.4-alpine
LABEL maintainer="Richard Watts <richard@zilliqa.com>"
WORKDIR /app
COPY ./ .
RUN apk add build-base
RUN go test -c -o ./test github.com/Zilliqa/gozilliqa-sdk/provider
RUN CI=true go tool test2json -t ./test -test.v
RUN CI=true go tool test2json -t ./test -test.v
13 changes: 7 additions & 6 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/Zilliqa/gozilliqa-sdk/crypto"
"github.com/Zilliqa/gozilliqa-sdk/keytools"
"github.com/Zilliqa/gozilliqa-sdk/util"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/tyler-smith/go-bip39"
)

Expand Down Expand Up @@ -59,23 +59,24 @@ func newHDAccount(mnemonic string, path DerivationPath) (*Account, error) {
if err != nil {
return nil, err
}
acc44H, err := masterKey.Child(hdkeychain.HardenedKeyStart + canonical(path[0]))
// todo: replace this with Derive() so as to avoid Issue172.
acc44H, err := masterKey.DeriveNonStandard(hdkeychain.HardenedKeyStart + canonical(path[0]))
if err != nil {
return nil, err
}
acc44H313H, err := acc44H.Child(hdkeychain.HardenedKeyStart + canonical(path[1]))
acc44H313H, err := acc44H.DeriveNonStandard(hdkeychain.HardenedKeyStart + canonical(path[1]))
if err != nil {
return nil, err
}
acc44H313H0H, err := acc44H313H.Child(hdkeychain.HardenedKeyStart + canonical(path[2]))
acc44H313H0H, err := acc44H313H.DeriveNonStandard(hdkeychain.HardenedKeyStart + canonical(path[2]))
if err != nil {
return nil, err
}
acc44H313H0H0, err := acc44H313H0H.Child(canonical(path[3]))
acc44H313H0H0, err := acc44H313H0H.DeriveNonStandard(canonical(path[3]))
if err != nil {
return nil, err
}
acc44H60H0H00, err := acc44H313H0H0.Child(canonical(path[4]))
acc44H60H0H00, err := acc44H313H0H0.DeriveNonStandard(canonical(path[4]))
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions account/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestSendTransaction(t *testing.T) {
wallet := NewWallet()
wallet.AddByPrivateKey("e19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930")
provider := provider2.NewProvider("https://dev-api.zilliqa.com/")
fmt.Println("address: ", wallet.DefaultAccount.Address)

gasPrice, err := provider.GetMinimumGasPrice()
assert.Nil(t, err, err)
Expand Down
35 changes: 23 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
module github.com/Zilliqa/gozilliqa-sdk

require (
github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/ethereum/go-ethereum v1.9.15
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.1
github.com/gorilla/websocket v1.4.1
github.com/stretchr/testify v1.5.1
github.com/tyler-smith/go-bip39 v1.0.2
github.com/btcsuite/btcd v0.23.0
github.com/btcsuite/btcd/btcec/v2 v2.2.0
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/ethereum/go-ethereum v1.10.26
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/stretchr/testify v1.8.1
github.com/tyler-smith/go-bip39 v1.1.0
github.com/ybbus/jsonrpc v2.1.2+incompatible
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/sync v0.0.0-20190423024810-112230192c58
google.golang.org/protobuf v1.23.0
github.com/ybbus/jsonrpc/v3 v3.1.1
golang.org/x/crypto v0.4.0
golang.org/x/sync v0.1.0
google.golang.org/protobuf v1.26.0
)

go 1.13
require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

go 1.19
68 changes: 68 additions & 0 deletions go.sum

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions keytools/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ package keytools

import (
"crypto/rand"
"math/big"

"github.com/Zilliqa/gozilliqa-sdk/util"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
)

var (
Expand All @@ -33,11 +32,12 @@ type PrivateKey [32]byte
func GeneratePrivateKey() (PrivateKey, error) {
var bytes [32]byte
for {
privk, err := btcec.NewPrivateKey(Secp256k1)
privk, err := btcec.NewPrivateKey()
if err == nil {
pvkInt := privk.D
if pvkInt.Cmp(big.NewInt(0)) == 1 && pvkInt.Cmp(Secp256k1.N) == -1 {
privk.D.FillBytes(bytes[:])
pvkInt := privk.Key
// Check that the resulting key is > 0 (check for less than N removed because the representation is mod N now)
if !pvkInt.IsZero() {
privk.Key.PutBytes(&bytes)
break
}
}
Expand Down
14 changes: 7 additions & 7 deletions multisig/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"fmt"
"github.com/Zilliqa/gozilliqa-sdk/keytools"
"github.com/Zilliqa/gozilliqa-sdk/util"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"math/big"
)

Expand All @@ -36,19 +36,19 @@ func AggregatedPubKey(pubKeys [][]byte) ([]byte, error) {
return nil, errors.New("empty public key list")
}
var aggregatedPubKey *btcec.PublicKey
key, err := btcec.ParsePubKey(pubKeys[0], keytools.Secp256k1)
key, err := btcec.ParsePubKey(pubKeys[0])
if err != nil {
return nil, err
}
aggregatedPubKey = key
for i := 1; i < len(pubKeys); i++ {
puk, err1 := btcec.ParsePubKey(pubKeys[i], keytools.Secp256k1)
puk, err1 := btcec.ParsePubKey(pubKeys[i])
if err1 != nil {
return nil, err1
}
x, y := keytools.Secp256k1.Add(aggregatedPubKey.X, aggregatedPubKey.Y, puk.X, puk.Y)
x, y := keytools.Secp256k1.Add(aggregatedPubKey.X(), aggregatedPubKey.Y(), puk.X(), puk.Y())
pubKeyBytes := util.Marshal(keytools.Secp256k1, x, y, true)
pubKey, err2 := btcec.ParsePubKey(pubKeyBytes, keytools.Secp256k1)
pubKey, err2 := btcec.ParsePubKey(pubKeyBytes)
if err2 != nil {
return nil, err2
}
Expand Down Expand Up @@ -82,13 +82,13 @@ func MultiVerify(publicKey []byte, msg []byte, r []byte, s []byte) bool {
return false
}

puk, err := btcec.ParsePubKey(publicKey, keytools.Secp256k1)
puk, err := btcec.ParsePubKey(publicKey)

if err != nil {
panic("parse public key error")
}

pkx, pky := puk.X, puk.Y
pkx, pky := puk.X(), puk.Y()

lx, ly := keytools.Secp256k1.ScalarMult(pkx, pky, r)
rx, ry := keytools.Secp256k1.ScalarBaseMult(s)
Expand Down
3 changes: 3 additions & 0 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
)

func TestStateProver_VerifyStateProof(t *testing.T) {
if true {
t.Skip("Skipping verifier test, since this depends on an old environment")
}
core.SkipIfCI(t)
p := provider.NewProvider("https://mpt42-api.dev.z7a.xyz")
sp := &StateProver{RpcClient: p}
Expand Down
6 changes: 3 additions & 3 deletions schnorr/schnorr.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"math/big"

"github.com/Zilliqa/gozilliqa-sdk/keytools"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
)

var bintZero = big.NewInt(0)
Expand Down Expand Up @@ -100,13 +100,13 @@ func Verify(publicKey []byte, msg []byte, r []byte, s []byte) bool {
return false
}

puk, err := btcec.ParsePubKey(publicKey, keytools.Secp256k1)
puk, err := btcec.ParsePubKey(publicKey)

if err != nil {
panic("parse public key error")
}

pkx, pky := puk.X, puk.Y
pkx, pky := puk.X(), puk.Y()

lx, ly := keytools.Secp256k1.ScalarMult(pkx, pky, r)
rx, ry := keytools.Secp256k1.ScalarBaseMult(s)
Expand Down
3 changes: 2 additions & 1 deletion transaction/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func TestTransaction_TrackTx(t *testing.T) {
Status: 0,
}

tx.Confirm("846cda64971e259b1739bf15710758803abcf5754507af5af3f779777cd1b0b0", 1000, 3, provider)
tx.Confirm("87d6ec83cdfa057bc4717f41099122fcca5c4acfb5156180d2d47a12dce43200", 1000, 3, provider)
// tx.Confirm("846cda64971e259b1739bf15710758803abcf5754507af5af3f779777cd1b0b0", 1000, 3, provider)
assert.True(t, tx.Status == core.Confirmed)
}

Expand Down
6 changes: 6 additions & 0 deletions verifier/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func TestVerify2(t *testing.T) {
if os.Getenv("CI") != "" {
t.Skip("Skipping testing in CI environment")
}
if true {
t.Skip("Skipping verifier test, since this depends on an old environment")
}

p := provider.NewProvider("https://junhao-874ed66-api.dev.z7a.xyz")
initDsComm, _ := p.GetCurrentDSComm()
Expand Down Expand Up @@ -123,6 +126,9 @@ func TestVerify(t *testing.T) {
if os.Getenv("CI") != "" {
t.Skip("Skipping testing in CI environment")
}
if true {
t.Skip("Skipping verifier test, since this depends on an old environment")
}
p := provider.NewProvider("https://kaus-poly-merged3-api.dev.z7a.xyz")
verifier := &Verifier{NumOfDsGuard: 9}
dsComm := list.New()
Expand Down

0 comments on commit d457f1b

Please sign in to comment.