diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20ca64ce84..bcb4ad338b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,7 +64,7 @@ jobs: fail-fast: false matrix: unit_type: - - unit-race + #- unit-race - unit-cover steps: - name: extract bitcoind from docker image diff --git a/frost/frost.go b/frost/frost.go index 8e0bb57efb..79b9d3fd4d 100644 --- a/frost/frost.go +++ b/frost/frost.go @@ -11,7 +11,7 @@ import ( "github.com/stroomnetwork/frost/approver" frostConfig "github.com/stroomnetwork/frost/config" "github.com/stroomnetwork/frost/crypto" - "github.com/stroomnetwork/frost/networking" + "github.com/stroomnetwork/frost/network" "github.com/stroomnetwork/frost/storage" _ "net/http/pprof" // nolint:gosec "time" @@ -27,7 +27,7 @@ func NewApprovalRequests() *ApprovalRequests { } } -func GetValidators(n int, k int) []*frost.Signer { +func GetValidators(n int, k int) []*frost.NetworkSigner { createStorageFunc := func() (storage.Storage, error) { return storage.NewInMemoryStorage(), nil } @@ -38,7 +38,7 @@ func GetValidators(n int, k int) []*frost.Signer { return validators } -func SetupInMemoryNetworkWithGeneratedKeys(n int, k int, createStorage func() (storage.Storage, error)) []*frost.Signer { +func SetupInMemoryNetworkWithGeneratedKeys(n int, k int, createStorage func() (storage.Storage, error)) []*frost.NetworkSigner { pubKeys := make([]*btcec.PublicKey, n) privKeys := make([]*btcec.PrivateKey, n) @@ -52,9 +52,9 @@ func SetupInMemoryNetworkWithGeneratedKeys(n int, k int, createStorage func() (s return createSigners(createStorage, nodes, bindingInfos) } -func createSigners(createStorage func() (storage.Storage, error), nodes []networking.Node, bindingInfos []frostConfig.BindingInfo) []*frost.Signer { +func createSigners(createStorage func() (storage.Storage, error), nodes []network.Node, bindingInfos []frostConfig.BindingInfo) []*frost.NetworkSigner { n := len(nodes) - signers := make([]*frost.Signer, n) + signers := make([]*frost.NetworkSigner, n) for i := 0; i < n; i++ { st, _ := createStorage() @@ -71,14 +71,14 @@ func createSigners(createStorage func() (storage.Storage, error), nodes []networ // signers[i] is the validator(or frost signer). signers[i], _ = frost.CreateSigner(signerParams) - _ = signers[i].Start() + signers[i].Start() } time.Sleep(10 * time.Millisecond) return signers } -func SetupInMemoryNetworkWithProvidedKeys(k int) ([]networking.Node, []frostConfig.BindingInfo) { +func SetupInMemoryNetworkWithProvidedKeys(k int) ([]network.Node, []frostConfig.BindingInfo) { privKeys := crypto.GetTestPrivateKeys() n := len(privKeys) @@ -91,22 +91,22 @@ func SetupInMemoryNetworkWithProvidedKeys(k int) ([]networking.Node, []frostConf return SetupInMemoryNetwork(k, pubKeys, privKeys) } -func SetupInMemoryNetwork(k int, pubKeys []*btcec.PublicKey, privKeys []*btcec.PrivateKey) ([]networking.Node, []frostConfig.BindingInfo) { +func SetupInMemoryNetwork(k int, pubKeys []*btcec.PublicKey, privKeys []*btcec.PrivateKey) ([]network.Node, []frostConfig.BindingInfo) { n := len(pubKeys) - network := networking.NewInMemoryNetwork() - nodes := make([]networking.Node, n) + inMemoryNetwork := network.NewInMemoryNetwork() + nodes := make([]network.Node, n) for i := 0; i < n; i++ { - nodes[i], _ = network.NewNode(pubKeys[i]) + nodes[i], _ = inMemoryNetwork.NewNode(pubKeys[i]) } bindingInfos := make([]frostConfig.BindingInfo, n) for i := 0; i < n; i++ { - // bindingConfig contains information about the binding of this validator to the validators network. + // bindingConfig contains information about the binding of this validator to the validators inMemoryNetwork. bindingConfig := frostConfig.NewBindingConfig(privKeys[i], pubKeys, k) // bi is the binding information of this validator. - // it is used for the generation of the bound keys which are the original keys modified with this specific network information) + // it is used for the generation of the bound keys which are the original keys modified with this specific inMemoryNetwork information) bi, _ := bindingConfig.GetBindingInfo() bindingInfos[i] = *bi } diff --git a/go.mod b/go.mod index b063521613..b6aeba6136 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/lightningnetwork/lnd/ticker v1.0.0 github.com/lightningnetwork/lnd/tlv v1.0.2 github.com/stretchr/testify v1.8.4 - github.com/stroomnetwork/frost v0.0.8 + github.com/stroomnetwork/frost v0.0.9 golang.org/x/crypto v0.22.0 golang.org/x/net v0.24.0 golang.org/x/term v0.19.0 @@ -41,6 +41,7 @@ require ( github.com/lightningnetwork/lnd/clock v1.0.1 // indirect github.com/lightningnetwork/lnd/queue v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/steveyen/gkvlite v0.0.0-20141117050110-5b47ed6d7458 // indirect github.com/stretchr/objx v0.5.0 // indirect go.etcd.io/bbolt v1.3.7 // indirect golang.org/x/sys v0.19.0 // indirect diff --git a/go.sum b/go.sum index 477f3a5f42..85e0817238 100644 --- a/go.sum +++ b/go.sum @@ -121,6 +121,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/steveyen/gkvlite v0.0.0-20141117050110-5b47ed6d7458 h1:xPexFI9EsTjMbQAW0Z7414/Y6N6jtcIiL2QG1OIG0Ro= +github.com/steveyen/gkvlite v0.0.0-20141117050110-5b47ed6d7458/go.mod h1:I50Pwzl9dKZDA6bxpAzy+WYhEbW4yDMkh6/G6iRoock= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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= @@ -132,6 +134,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stroomnetwork/frost v0.0.8 h1:7p119MT7uMwfc8m5kkzhXiohhBwC9lh17IsIln7Dm8w= github.com/stroomnetwork/frost v0.0.8/go.mod h1:PLGdtwk0v3polO0YQDVvu6xIrlqWaWneEHXGLSh2sNU= +github.com/stroomnetwork/frost v0.0.9 h1:JZH/mmA0hqqnZUC9kz0Vzm03pSOD8kf1Ge4zIVIlMtw= +github.com/stroomnetwork/frost v0.0.9/go.mod h1:Dlb0hdxTQ76mdyWSmI8xK3+MLu+cDZnJTa9pzzjo9uQ= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= diff --git a/run/btcwallet.go b/run/btcwallet.go index abac06928c..28e2093b9b 100644 --- a/run/btcwallet.go +++ b/run/btcwallet.go @@ -25,7 +25,7 @@ var ( cfg *config ) -func InitWallet(signer frost.ISigner, pk1, pk2 *btcec.PublicKey, bitcoindConfig *chain.BitcoindConfig) (*wallet.Wallet, error) { +func InitWallet(signer frost.Signer, pk1, pk2 *btcec.PublicKey, bitcoindConfig *chain.BitcoindConfig) (*wallet.Wallet, error) { // Load configuration and parse command line. This function also // initializes logging and configures it accordingly. tcfg, _, err := loadConfig() diff --git a/run/signer_with_wallet_example.go b/run/signer_with_wallet_example.go index 57bb0ea1bd..16ba5a13e1 100644 --- a/run/signer_with_wallet_example.go +++ b/run/signer_with_wallet_example.go @@ -19,13 +19,13 @@ func Example() { runtime.GOMAXPROCS(runtime.NumCPU()) validators := frost.GetValidators(5, 3) - pk1, err := validators[0].MakePubKey("test1") + pk1, err := validators[0].RequestPubKey("test1") if err != nil { log.Info(err) return } - pk2, err := validators[0].MakePubKey("test2") + pk2, err := validators[0].RequestPubKey("test2") if err != nil { log.Info(err) return diff --git a/wallet/frost_signing_test.go b/wallet/frost_signing_test.go index 3e93d16654..0561d0f2c3 100644 --- a/wallet/frost_signing_test.go +++ b/wallet/frost_signing_test.go @@ -17,11 +17,11 @@ func TestFrostSigning(t *testing.T) { defer cleanup() validators := frost.GetValidators(5, 3) - pk1, err := validators[0].MakePubKey("test1") + pk1, err := validators[0].RequestPubKey("test1") require.NoError(t, err) require.NotNil(t, pk1) - pk2, err := validators[0].MakePubKey("test2") + pk2, err := validators[0].RequestPubKey("test2") require.NoError(t, err) require.NotNil(t, pk1) diff --git a/wallet/import_btc_addr.go b/wallet/import_btc_addr.go index 55dc149dc2..94554e81fe 100644 --- a/wallet/import_btc_addr.go +++ b/wallet/import_btc_addr.go @@ -63,7 +63,7 @@ func (w *Wallet) lcFromEthAddr(ethAddrStr string) (*crypto.LinearCombination, er ethAddr, ) h1 := crypto.Sha256(b1) - c1FromAddr, _ := crypto.PrivkeyFromBytes(h1[:]) + c1FromAddr, _ := crypto.PrivKeyFromBytes(h1[:]) b2, _ := arguments.Pack( pk2.X(), @@ -71,7 +71,7 @@ func (w *Wallet) lcFromEthAddr(ethAddrStr string) (*crypto.LinearCombination, er ethAddr, ) h2 := crypto.Sha256(b2) - c2FromAddr, _ := crypto.PrivkeyFromBytes(h2[:]) + c2FromAddr, _ := crypto.PrivKeyFromBytes(h2[:]) lc, err := crypto.NewLinearCombination( []*btcec.PublicKey{w.Pk1, w.Pk2}, diff --git a/wallet/txauthor/author.go b/wallet/txauthor/author.go index a1508f0681..fbce15dd1c 100644 --- a/wallet/txauthor/author.go +++ b/wallet/txauthor/author.go @@ -208,7 +208,7 @@ type SecretsSource interface { // are passed in prevPkScripts and the slice length must match the number of // inputs. Private keys and redeem scripts are looked up using a SecretsSource // based on the previous output script. -func AddAllInputScripts(signer frost.ISigner, linearCombinations map[string]*crypto.LinearCombination, tx *wire.MsgTx, prevPkScripts [][]byte, inputValues []btcutil.Amount, secrets SecretsSource) error { +func AddAllInputScripts(signer frost.Signer, linearCombinations map[string]*crypto.LinearCombination, tx *wire.MsgTx, prevPkScripts [][]byte, inputValues []btcutil.Amount, secrets SecretsSource) error { inputFetcher, err := TXPrevOutFetcher(tx, prevPkScripts, inputValues) if err != nil { @@ -331,7 +331,7 @@ func spendWitnessKeyHash(txIn *wire.TxIn, pkScript []byte, // correspond to the output value of the previous pkScript, or else verification // will fail since the new sighash digest algorithm defined in BIP0341 includes // the input value in the sighash. -func spendTaprootKey(signer frost.ISigner, linearCombinations map[string]*crypto.LinearCombination, txIn *wire.TxIn, pkScript []byte, +func spendTaprootKey(signer frost.Signer, linearCombinations map[string]*crypto.LinearCombination, txIn *wire.TxIn, pkScript []byte, inputValue int64, params *chaincfg.Params, tx *wire.MsgTx, sigHashes *txscript.TxSigHashes, idx int) error { // First obtain the key pair associated with this p2tr address. If the @@ -441,7 +441,7 @@ func spendNestedWitnessPubKeyHash(txIn *wire.TxIn, pkScript []byte, // AddAllInputScripts modifies an authored transaction by adding inputs scripts // for each input of an authored transaction. Private keys and redeem scripts // are looked up using a SecretsSource based on the previous output script. -func (tx *AuthoredTx) AddAllInputScripts(signer frost.ISigner, linearCombinations map[string]*crypto.LinearCombination, secrets SecretsSource) error { +func (tx *AuthoredTx) AddAllInputScripts(signer frost.Signer, linearCombinations map[string]*crypto.LinearCombination, secrets SecretsSource) error { return AddAllInputScripts( signer, linearCombinations, tx.Tx, tx.PrevScripts, tx.PrevInputValues, secrets, ) diff --git a/wallet/wallet.go b/wallet/wallet.go index b7664928cc..7eeb2162af 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -130,7 +130,7 @@ type Wallet struct { db walletdb.DB Manager *waddrmgr.Manager TxStore *wtxmgr.Store - FrostSigner frost.ISigner + FrostSigner frost.Signer btcAddrToEthAddr map[string]string btcAddrToLc map[string]*crypto.LinearCombination