alice
alice copied to clipboard
How to modify example code to use ECDSA (CGGMP) ?
Hi I want to use ECDSA(especially CGGMP) by modifying example code.
First I have handled DKG part of ECDSA(CGGMP).
So I did modified import "tss/dkg" to "tss/ecdsa/cggmp/dkg in these files: dkg/config.go, dkg/main.go, dkg/service.go, utils/utils.go, main.go
And added "sid" to function NewService in dkg/service.go
func NewService(config *DKGConfig, pm types.PeerManager) (*service, error) {
s := &service{
config: config,
pm: pm,
done: make(chan struct{}),
}
sid := make([]byte, 1)
d, err := dkg.NewDKG(utils.GetCurve(), pm, sid, config.Threshold, config.Rank, s)
if err != nil {
log.Warn("Cannot create a new DKG", "config", config, "err", err)
return nil, err
}
s.dkg = d
return s, nil
}
Then each participant of 3-3 dkg didn't proceed after "successfully connect to peer" twice while running.
So I want to ask you how to use ECDSA(CGGMP) in a better(correct) way.
Thank you in advance!
By the way, above example code can make results if I run 2 of 2 dkg by modifying input configs.
Both of participants printed "Dkg done" and the outputs are:
id-10001-output.yaml
share: "31052753871736976167367317859512765276470989393721063383654803743066679453480"
pubkey:
x: "25162917454634828525931633151091237546031943092514853666542491015960663317625"
"y": "101256400736787412054306611223984329509651679357502392081040131003103006022268"
bks:
id-10001:
x: "110089849653815658980153180871419064956426392606623089146496719192121591356393"
rank: 0
id-10002:
x: "112501917392551893599354948290685384227906645237236634177329431429194935346366"
rank: 0
rid:
- 81
- 161
- 219
- 79
- 6
- 25
- 226
- 93
- 85
- 62
- 54
- 170
- 72
- 225
- 240
- 80
- 66
- 96
- 190
- 85
- 101
- 145
- 72
- 120
- 246
- 38
- 158
- 172
- 131
- 164
- 87
- 109
id-10002-output.yamle
share: "31052753871736976167367317859512765276470989393721063383654803743066679453480"
pubkey:
x: "25162917454634828525931633151091237546031943092514853666542491015960663317625"
"y": "101256400736787412054306611223984329509651679357502392081040131003103006022268"
bks:
id-10001:
x: "110089849653815658980153180871419064956426392606623089146496719192121591356393"
rank: 0
id-10002:
x: "112501917392551893599354948290685384227906645237236634177329431429194935346366"
rank: 0
rid:
- 81
- 161
- 219
- 79
- 6
- 25
- 226
- 93
- 85
- 62
- 54
- 170
- 72
- 225
- 240
- 80
- 66
- 96
- 190
- 85
- 101
- 145
- 72
- 120
- 246
- 38
- 158
- 172
- 131
- 164
- 87
- 109
Is this result correct?
@Hoodie-Kang May I ask if you have run through cggmp?
Hi @CodeLion66 , yes still using CGGMP. But so far only the 2 of 2 DKG works
@cychuang0924 @alanchchen Is there any new progress on this?
@Hoodie-Kang @alanchchen I may have found the reason, but I used msg at dkg_main_echo.go the package for prevents duplicate messages from being sent. I changed the code to the following program to restore it. I'm not sure if it's a bug, but it would be best if the official could provide an example of cggmp// Avoid duplicate messages from the same peer should be handled in the caller
@alanchchen @cychuang0924 The cggmp signature test script cannot run smoothly. Do you need to make any modifications. I generated fragments using dkg_test.go, but it was passed to the sign_test.go, I couldn't run through the test. Did I make a mistake? Could you please help me take a look? Thank you very much
@Hoodie-Kang @alanchchen I may have found the reason, but I used msg at dkg_main_echo.go the package for prevents duplicate messages from being sent. I changed the code to the following program to restore it. I'm not sure if it's a bug, but it would be best if the official could provide an example of cggmp// Avoid duplicate messages from the same peer should be handled in the caller
We're figuring out this issue. Sorry for the late reply.
@alanchchen @cychuang0924 @Jud According to the implementation of the signer example in gg18, a problem arises. Since each peer is independent, each peer will have its own allPed, In the zero knowledge proof, there will be "NFO [08-14 | 10:32:01.273 | sign/round_1. go: 219] round1Handler round1Handler=" the verification is failure ". It is not possible to define allPed first and then use the for loop to sign like in the sign_test. go example. May I ask how to solve this problem? If you have time to reply, thank you very much!
@CodeLion66 @Hoodie-Kang Hope #276 help. We've also fixed some issues in the last few days. Please try again to see if the problems exist.
oh I'll check it
Thank you
Hi @alanchchen, I tried the example The 3 of 3 (the original example node-1,2,3) DKG worked immediately and printed results. Awesome! But 2 of 3 DKG with modified input config (only threshold 3-> 2) doesn't work, only 1 or 2 node of 3 print results correctly.
I have no idea. can you help us more ?
+edit) oh sometimes it works, sometimes print "cannot close the stream" error once or twice in one node.
DEBUG[08-31|16:31:16.870|node/pm.go:115] Sent message peer=/ip4/127.0.0.1/tcp/10002/p2p/QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5
WARN [08-31|16:31:16.871|node/pm.go:111] Cannot close the stream err="stream reset"
Hi @alanchchen, I tried the example The 3 of 3 (the original example node-1,2,3) DKG worked immediately and printed results. Awesome! But 2 of 3 DKG with modified input config (only threshold 3-> 2) doesn't work, only 1 or 2 node of 3 print results correctly.
I have no idea. can you help us more ?
+edit) oh sometimes it works, sometimes print "cannot close the stream" error once or twice in one node.
DEBUG[08-31|16:31:16.870|node/pm.go:115] Sent message peer=/ip4/127.0.0.1/tcp/10002/p2p/QmUmf4xxZYPS8vXzz2uAAaNpogxEugYpmPDnnu9saon4c5 WARN [08-31|16:31:16.871|node/pm.go:111] Cannot close the stream err="stream reset"
@Hoodie-Kang I've subimitted a new commit: https://github.com/getamis/alice/pull/276/commits/6583f25eff05b1ff85154507c57c9bcba1b019cd, which may solve your problem.
The example only demonstrates the simplest case.
In real case, you may implement your own PeerManager
and handle peer connections by yourself.
I checked the commit, but it pended after print the 2 of 3 DKG results while accepting signal input from my keyboard. Can you explain the usage of signal things? I think it must have some "stop" functionality from the signal
BTW, thank you for your quick answer!
I checked the commit, but it pended after print the 2 of 3 DKG results while accepting signal input from my keyboard. Can you explain the usage of signal things? I think it must have some "stop" functionality from the signal
BTW, thank you for your quick answer!
The signal stuff is just to keep the process running. After pressing ctrl+C, the process will terminate. Make sure your processes complete before pressing ctrl+C.
oh I see. But I want to ask you why you want to keep the process running. Is it for waiting other peers' processes also done "completely"?
oh I see. But I want to ask you why you want to keep the process running. Is it for waiting other peers' processes also done "completely"?
We didn't do any error recovery in this example. Just make sure the process does send and receive all necessary messages before it exits.
In real case, you might have to handle such errors by yourself (e.g., connection lost, unexpected crash, etc)