Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: (wasp-cli) use bpi-44 derivation path for wallet seed #3059

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions contracts/wasm/testwasmlib/test/testwasmlib_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ func setupClientCluster(t *testing.T) *wasmclient.WasmClientContext {
templates.WaspConfig = strings.ReplaceAll(templates.WaspConfig, "rocksdb", "mapdb")
env := clustertests.SetupWithChain(t)
templates.WaspConfig = strings.ReplaceAll(templates.WaspConfig, "mapdb", "rocksdb")
seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(mySeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(0))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(mySeed), 0))

// request funds to the wallet that the wasmclient will use
err := env.Clu.RequestFunds(wallet.Address())
Expand Down Expand Up @@ -127,8 +126,7 @@ func setupClientDisposable(t testing.TB) *wasmclient.WasmClientContext {
cfgWaspAPI := cfgWasp["0"].(string)

// we'll use the seed keypair to sign requests
seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(cfgSeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(0))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(cfgSeed), 0))

svc := wasmclient.NewWasmClientService(cfgWaspAPI)
require.True(t, svc.IsHealthy())
Expand Down Expand Up @@ -338,8 +336,7 @@ func setupClientLib(t *testing.T) *wasmclient.WasmClientContext {
ctx := wasmclient.NewWasmClientContext(svc, testwasmlib.ScName)
require.NoError(t, ctx.Err)

seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(mySeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(0))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(mySeed), 0))
ctx.SignRequests(wallet)
require.NoError(t, ctx.Err)
return ctx
Expand Down Expand Up @@ -413,8 +410,7 @@ func testAPIErrorHandling(t *testing.T, ctx *wasmclient.WasmClientContext) {
// fmt.Println("Error: " + ctx.Err.Error())

fmt.Println("check sign with wrong wallet")
seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(mySeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(1))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(mySeed), 1))
ctx.SignRequests(wallet)
f := testwasmlib.ScFuncs.Random(ctx)
f.Func.Post()
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/labstack/echo/v4 v4.11.2
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.30.0
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multiaddr v0.11.0
github.com/pangpanglabs/echoswagger/v2 v2.4.1
Expand All @@ -49,6 +50,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/wasmerio/wasmer-go v1.0.4
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98
go.dedis.ch/kyber/v3 v3.1.0
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.17.1
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUM
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
Expand Down Expand Up @@ -761,6 +762,8 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs=
github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 h1:i7k63xHOX2ntuHrhHewfKro67c834jug2DIk599fqAA=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98/go.mod h1:Knu2XMRWe8SkwTlHc/+ghP+O9DEaZRQQEyTjvLJ5Cck=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
Expand Down
51 changes: 46 additions & 5 deletions packages/cryptolib/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,56 @@ package cryptolib
import (
"crypto/ed25519"
"encoding/binary"
"fmt"

"golang.org/x/crypto/blake2b"
"github.com/minio/blake2b-simd"
"github.com/wollac/iota-crypto-demo/pkg/bip32path"
"github.com/wollac/iota-crypto-demo/pkg/slip10"
"github.com/wollac/iota-crypto-demo/pkg/slip10/eddsa"

hivecrypto "github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/iotaledger/wasp/packages/cryptolib/byteutils"
"github.com/iotaledger/wasp/packages/parameters"
)

// testnet/alphanet uses COIN_TYPE = 1
const TestnetCoinType = uint32(1)

// / IOTA coin type <https://github.com/satoshilabs/slips/blob/master/slip-0044.md>
const IotaCoinType = uint32(4218)

// / Shimmer coin type <https://github.com/satoshilabs/slips/blob/master/slip-0044.md>
const ShimmerCoinType = uint32(4219)

// SubSeed returns a Seed (ed25519 Seed) from a master seed (that has arbitrary length)
func SubSeed(walletSeed []byte, accountIndex uint64, useLegacyDerivation ...bool) Seed {
if len(useLegacyDerivation) > 0 && useLegacyDerivation[0] {
seed := SeedFromBytes(walletSeed)
return legacyDerivation(&seed, accountIndex)
}

coinType := TestnetCoinType // default to the testnet
switch parameters.L1().Protocol.Bech32HRP {
case "iota":
coinType = IotaCoinType
case "smr":
coinType = ShimmerCoinType
}

bip32Path := fmt.Sprintf("m/44'/%d'/%d'/0'/0'", coinType, accountIndex) // this is the same as FF does it (only the account index changes, the ADDRESS_INDEX stays 0)
path, err := bip32path.ParsePath(bip32Path)
if err != nil {
panic(err)
}
key, err := slip10.DeriveKeyFromPath(walletSeed, eddsa.Ed25519(), path)
if err != nil {
panic(err)
}
_, prvKey := key.Key.(eddsa.Seed).Ed25519Key()
return SeedFromBytes(prvKey)
}

// ---
const (
SeedSize = ed25519.SeedSize
)
Expand All @@ -26,14 +69,12 @@ func SeedFromBytes(data []byte) (ret Seed) {
return ret
}

func (seed *Seed) SubSeed(n uint64) Seed {
func legacyDerivation(seed *Seed, index uint64) Seed {
subSeed := make([]byte, SeedSize)

indexBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(indexBytes, n)
binary.LittleEndian.PutUint64(indexBytes, index)
hashOfIndexBytes := blake2b.Sum256(indexBytes)

byteutils.XORBytes(subSeed, seed[:], hashOfIndexBytes[:])

return SeedFromBytes(subSeed)
}
4 changes: 2 additions & 2 deletions packages/solo/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ func (ch *Chain) L1L2Funds(addr iotago.Address) *L1L2AddressAssets {
func (ch *Chain) GetL2FundsFromFaucet(agentID isc.AgentID, baseTokens ...uint64) {
// find a deterministic L1 address that has 0 balance
walletKey, walletAddr := func() (*cryptolib.KeyPair, iotago.Address) {
seed := cryptolib.SeedFromBytes([]byte("GetL2FundsFromFaucet"))
masterSeed := []byte("GetL2FundsFromFaucet")
i := uint64(0)
for {
ss := seed.SubSeed(i)
ss := cryptolib.SubSeed(masterSeed, i)
key, addr := ch.Env.NewKeyPair(&ss)
_, err := ch.Env.GetFundsFromFaucet(addr)
require.NoError(ch.Env.T, err)
Expand Down
2 changes: 1 addition & 1 deletion packages/testutil/testdbhash/TestStorageContract.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x3413c0b12114d471fbef75736eeeefbee2df902370539bbb5d54459f5425384b
0xe2dc176c7b9f293e8a1a82e8cff880a8e33f4c12bad5bb59ee831d48b0665489
6 changes: 2 additions & 4 deletions packages/wasmvm/wasmclient/go/test/wasmclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ func setupClient(t *testing.T) *wasmclient.WasmClientContext {
ctx := wasmclient.NewWasmClientContext(svc, testwasmlib.ScName)
require.NoError(t, ctx.Err)

seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(mySeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(0))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(mySeed), 0))
ctx.SignRequests(wallet)
require.NoError(t, ctx.Err)
return ctx
Expand Down Expand Up @@ -111,8 +110,7 @@ func TestErrorHandling(t *testing.T) {
// fmt.Println("Error: " + ctx.Err.Error())

// sign with wrong wallet
seed := cryptolib.SeedFromBytes(wasmtypes.BytesFromString(mySeed))
wallet := cryptolib.KeyPairFromSeed(seed.SubSeed(1))
wallet := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(wasmtypes.BytesFromString(mySeed), 1))
ctx.SignRequests(wallet)
f := testwasmlib.ScFuncs.Random(ctx)
f.Func.Post()
Expand Down
2 changes: 2 additions & 0 deletions tools/evm/evmemulator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ require (
github.com/miekg/dns v1.1.55 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down Expand Up @@ -183,6 +184,7 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wasmerio/wasmer-go v1.0.4 // indirect
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/kyber/v3 v3.1.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions tools/evm/evmemulator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUM
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
Expand Down Expand Up @@ -731,6 +732,8 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs=
github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 h1:i7k63xHOX2ntuHrhHewfKro67c834jug2DIk599fqAA=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98/go.mod h1:Knu2XMRWe8SkwTlHc/+ghP+O9DEaZRQQEyTjvLJ5Cck=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 2 additions & 0 deletions tools/gascalibration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand All @@ -103,6 +104,7 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/kyber/v3 v3.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions tools/gascalibration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
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=
Expand Down Expand Up @@ -267,6 +269,8 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 h1:i7k63xHOX2ntuHrhHewfKro67c834jug2DIk599fqAA=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98/go.mod h1:Knu2XMRWe8SkwTlHc/+ghP+O9DEaZRQQEyTjvLJ5Cck=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
6 changes: 3 additions & 3 deletions tools/wasp-cli/cli/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ type Wallet struct {

func Load() *Wallet {
seedHex := viper.GetString("wallet.seed")
useLegacyDerivation := viper.GetBool("wallet.useLegacyDerivation")
if seedHex == "" {
log.Fatal("call `init` first")
}

seedBytes, err := iotago.DecodeHex(seedHex)
masterSeed, err := iotago.DecodeHex(seedHex)
log.Check(err)

seed := cryptolib.SeedFromBytes(seedBytes)
kp := cryptolib.KeyPairFromSeed(seed.SubSeed(uint64(AddressIndex)))
kp := cryptolib.KeyPairFromSeed(cryptolib.SubSeed(masterSeed, uint64(AddressIndex), useLegacyDerivation))

return &Wallet{KeyPair: kp, AddressIndex: AddressIndex}
}
Expand Down
2 changes: 2 additions & 0 deletions tools/wasp-cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ require (
github.com/miekg/dns v1.1.55 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down Expand Up @@ -190,6 +191,7 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wasmerio/wasmer-go v1.0.4 // indirect
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/kyber/v3 v3.1.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions tools/wasp-cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUM
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc=
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
Expand Down Expand Up @@ -822,6 +823,8 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs=
github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98 h1:i7k63xHOX2ntuHrhHewfKro67c834jug2DIk599fqAA=
github.com/wollac/iota-crypto-demo v0.0.0-20221117162917-b10619eccb98/go.mod h1:Knu2XMRWe8SkwTlHc/+ghP+O9DEaZRQQEyTjvLJ5Cck=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
Loading