bnb-chain / tss-lib

Threshold Signature Scheme, for ECDSA and EDDSA
MIT License
800 stars 272 forks source link

Add new node with resharing #226

Closed UncleAndy closed 1 year ago

UncleAndy commented 1 year ago

Hi, all!

I try use resharing after add new node to cluster (was 3 nodes and I try add 1). But I get some errors every time.

Last error I getting: panic: PrepareForSigning: len(ks) <= i (3 <= 3)

I try many different methods, but not success. :(((

Can you describe how I need initialize new node for success resharing? Need I run resharing for all nodes when I want add new one?

0xLyon commented 1 year ago

Hi there, can you clarify what you mean with "resharing"? Please kindly also share more of your log output so we can get a better idea of what the issue might be.

UncleAndy commented 1 year ago

This is modeling application for local check cases. Main case iwth init nodes, sign and check worked fine. But when I try add one more node and do resharing, I getting error.

This is log:

2023/02/23 11:00:31 Reshard...
Run reshard for node node1
Run reshard for node node2
Run reshard for node node3
Run reshard for node node4
2023/02/23 11:00:31 Wait for Reshard...
panic: PrepareForSigning: len(ks) <= i (3 <= 3)

goroutine 1380 [running]:
github.com/bnb-chain/tss-lib/ecdsa/signing.PrepareForSigning({0xa9e068?, 0xd23260?}, 0x3, 0x3, 0xc00037eee0, {0xc0001c0420, 0x3, 0x0?}, {0xc0001c0480, 0x3, ...})
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/ecdsa/signing/prepare.go:28 +0x425
github.com/bnb-chain/tss-lib/ecdsa/resharing.(*round1).Start(0xc00000e088)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/ecdsa/resharing/round_1_old_step_1.go:50 +0x52b
github.com/bnb-chain/tss-lib/tss.BaseStart({0xa9fde0?, 0xc000352000}, {0x817770, 0xf}, {0x0, 0x0, 0x20?})
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/tss/party.go:139 +0x350
github.com/bnb-chain/tss-lib/ecdsa/resharing.(*LocalParty).Start(0x1f?)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/ecdsa/resharing/local_party.go:106 +0x37
main.(*Node).ReShard.func1()
        /home/andy/projects/tss/node.go:103 +0x26
created by main.(*Node).ReShard
        /home/andy/projects/tss/node.go:102 +0x74
make: *** [Makefile:7: run] Ошибка 2
0xLyon commented 1 year ago

Can you ensure that when adding your new node to the current peers, that the new one has unique values set for "uniqueKey" and "id". If you see the steps for Setup here - https://github.com/bnb-chain/tss-lib#setup, you can see that during the initial setup a LocalParty requires each participating node/peer to have a partyID which is generated by tss.NewPartyID call.

UncleAndy commented 1 year ago

Can you ensure that when adding your new node to the current peers, that the new one has unique values set for "uniqueKey" and "id".

Yes. I print "moniker - id (key)" from PartyID and I getting:

2023/02/24 18:23:33 Reshard prepare...
Run reshard prepare for node node1 - 5577006791947779410 (8674665223082153551)
Run reshard prepare for node node2 - 6129484611666145821 (4037200794235010051)
Run reshard prepare for node node3 - 3916589616287113937 (6334824724549167320)
Run reshard prepare for node node4 - 605394647632969758 (1443635317331776148)
UncleAndy commented 1 year ago

Hm. I detect new interest problem...

I nothing changed in nodes set. Before I do all nodes init, check public keys generated, sign test data and check it using public key. All worked fine.

After this I try do "Resharing" for all nodes and I get this error:

send msg to node3: Type: binance.tsslib.ecdsa.resharing.DGRound1Message, From: {0,node2}, To: [{1,node3} {2,node1}]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x6fb5cc]

goroutine 129 [running]:
github.com/bnb-chain/tss-lib/crypto.(*ECPoint).X(...)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/crypto/ecpoint.go:50
github.com/bnb-chain/tss-lib/crypto/paillier.GenerateXs(0xd, 0xc0003d9500?, 0xc00013c020, 0x0)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/crypto/paillier/paillier.go:258 +0x8c
github.com/bnb-chain/tss-lib/crypto/paillier.(*PrivateKey).Proof(0xc00000c168, 0x4cbc25?, 0xc0000b99d8?)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/crypto/paillier/paillier.go:200 +0x8b
github.com/bnb-chain/tss-lib/ecdsa/resharing.(*round2).Start(0xc00050e1d0)
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/ecdsa/resharing/round_2_new_step_1.go:73 +0x8c5
github.com/bnb-chain/tss-lib/tss.BaseUpdate({0xa9d640, 0xc00062c600}, {0xa9cf70, 0xc000112900}, {0x81554e, 0xf})
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/tss/party.go:168 +0x56d
github.com/bnb-chain/tss-lib/ecdsa/resharing.(*LocalParty).Update(0xa996c0?, {0xa9cf70?, 0xc000112900?})
        /home/andy/projects/tss/vendor/github.com/bnb-chain/tss-lib/ecdsa/resharing/local_party.go:110 +0x45
main.sendMSG({0x7f7da36bd8b8?, 0xc000112900}, 0xc000026200)
        /home/andy/projects/tss/transport.go:115 +0x199
main.(*LocalTransport).Run.func1()
        /home/andy/projects/tss/transport.go:78 +0x3c5
created by main.(*LocalTransport).Run
        /home/andy/projects/tss/transport.go:45 +0x56
make: *** [Makefile:7: run] Ошибка 2

In /home/andy/projects/tss/transport.go:115 I have code for Update when recaive message in transport: ok, err := node.Party.Update(pMsg). Party here is resharing.Party.

0xLyon commented 1 year ago

Hi there, apologies for the delay in getting back to you on this. Can you kindly advise if you are still having this issue mentioned here?