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

lkg init #5

Open
wants to merge 6 commits into
base: j-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions node/pkg/tss/implementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package tss

import (
"context"
crand "crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"errors"
"fmt"
"math/big"
"math/rand"
"net"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -493,6 +497,29 @@ func TestBadInputs(t *testing.T) {
})
}

func createX509Cert(dnsName string) *x509.Certificate {
// using random serial number
var serialNumberLimit = new(big.Int).Lsh(big.NewInt(1), 128)

serialNumber, err := crand.Int(crand.Reader, serialNumberLimit)
if err != nil {
panic(err)
}

tmpl := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{Organization: []string{"tsscomm"}},
SignatureAlgorithm: x509.ECDSAWithSHA256,
NotBefore: time.Now(),
NotAfter: time.Now().Add(time.Hour * 24 * 366 * 40), // valid for > 40 years used for tests...
BasicConstraintsValid: true,

DNSNames: []string{"localhost", dnsName},
IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1)},
}
return &tmpl
}

func TestFetchPartyId(t *testing.T) {
a := assert.New(t)
engines := load5GuardiansSetupForBroadcastChecks(a)
Expand Down
83 changes: 83 additions & 0 deletions node/pkg/tss/internal/cmd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Please read the entire document before running the protocol.


# Running 'local' DKG

The following binary runs the DKG protocol to
generate secrets for guardians to use by the threshold signing scheme (TSS).

The script expects a config file (similar to the cnfg.json) provided
in this package.
The config file contains a few key fields:
```
"NumParticipants": int,
"WantedThreshold": int,
"GuardianSpecifics" : array
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a cfg.example.json with actual numbers





Where `NumParticipants` is the number of guardians in the system,
`WantedThreshold` is the wanted threshold (For instance, `NumParticipants=19` and `WantedThreshold=13`).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WantedThreshold is the number of guardians that need to approve a VAA?


The following is an example of the `GuardianSpecifics` array (for a working example, please see `cnfg.json`):


```
"GuardianSpecifics": [
{
"Identifier": {
"TlsX509":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JS
UgvVENDQmVXZ0F3SUJBZ0lRYUJZRTMvTTA4WEhZQ25OVm1jRkJja
kFOQmdrcWhraUc5dzBCQVFzRkFEQnkKTVFzd0NRWURWUVFHRXdKV
.
.
.
FlscWNPbWVYMXVGbUtiZGkvWG9yR2xrQ29NRjNURHg4cm1wOURCa
UIvCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0="

},
"WhereToSaveSecrets": "/Path/To/File/NameWithoutPrefix"
},
{
"Identifier": {...},
"WhereToSaveSecrets": "..."
},
{...},
.
.
.
]
```

The DKG protocol is used to generate secrets to TSS,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for DKG. This binary runs it locally, so we should clarify that in the local setting, certs are only used for assigning names since there's no communication to encrypt. (thus, no need to provide the secret key that will be used to protect future communication).

and it assumes a public key infrastructure.
These public keys are x509 certificates (and stored inside `GuardianSpecifics[i].Identifier.TlsX509`),
and are used later by the TSS to establish TLS channels between the participants.
As a result, the x509 certificate provided by you should be self-signed root-level certificates.
In addition, you should safely store the signing key you've used to sign your certificate in a known location ([see after running the protocol](#after-running-the-local-dkg-protocol))


When creating the X509 certificates, be aware that the DNS name you set
in the certificate will be used as the hostname of
servers participating in the TSS protocol.
As a result, please refrain from using hostnames that are
unreachable.


# After running the local DKG protocol.

Once you run the protocol, expect numerous files containing secret keys and
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these files created? are they placed in some directory structure? (e.g., one directory per guardian?). numerous seems under specified.

additional configurations.
Each guardian operator should take the file saved by the given name they
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps: those files may be used in a guardian's config to point to its key shard.

provided in the config.

The file each operator holds should be kept like other files containing secret keys.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you rephrase these sentences? I didn't quite get it.
Perhaps the config should also include the TLS secret key that this program doesn't have access to?

og -> of?

This file contains the result og the DKG, before this file is usable, one should provide the signing key used to sign the x509 certificate used by the DKG protocol.






38 changes: 38 additions & 0 deletions node/pkg/tss/internal/cmd/cnfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the cfg.example.json I was asking about earlier. It should be in a separate file that the README points to.

"NumParticipants": 5,
"WantedThreshold": 3,

"GuardianSpecifics": [
{
"Identifier": {
"TlsX509":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUgvVENDQmVXZ0F3SUJBZ0lRYUJZRTMvTTA4WEhZQ25OVm1jRkJjakFOQmdrcWhraUc5dzBCQVFzRkFEQnkKTVFzd0NRWURWUVFHRXdKVlV6RU9NQXdHQTFVRUNBd0ZWR1Y0WVhNeEVEQU9CZ05WQkFjTUIwaHZkWE4wYjI0eApFVEFQQmdOVkJBb01DRk5UVENCRGIzSndNUzR3TEFZRFZRUUREQ1ZUVTB3dVkyOXRJRVZXSUZOVFRDQkpiblJsCmNtMWxaR2xoZEdVZ1EwRWdVbE5CSUZJek1CNFhEVEl3TURRd01UQXdOVGd6TTFvWERUSXhNRGN4TmpBd05UZ3oKTTFvd2diMHhDekFKQmdOVkJBWVRBbFZUTVE0d0RBWURWUVFJREFWVVpYaGhjekVRTUE0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0S2ppNmdPZ0E1dVNVemFHbXEvdjRWbmNLNVVyK245TGJmbmZMYzI4SjVmdC9Hb3Rpbk15RGszaWFyCkYxMFlscWNPbWVYMXVGbUtiZGkvWG9yR2xrQ29NRjNURHg4cm1wOURCaUIvCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0="
},
"WhereToSaveSecrets": "Alex"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is Alex a directory? I'm not sure what this argument means

Also, why not use the standard Alice, Bob, Carol, Dave,... for names?

},
{
"Identifier": {
"TlsX509":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJvVENDQVVlZ0F3SUJBZ0lRVkNTcndsY1hnWnJrTWRzbFYwamk1VEFLQmdncWhrak9QUVFEQWpBU01SQXcKRGdZRFZRUUtFd2QwYzNOamIyMXRNQ0FYRFRJME1Ea3lNakEzTVRjeU1sb1lEekl3TmpReE1ESXlNRGN4TnpJeQpXakFTTVJBd0RnWURWUVFLRXdkMGMzTmpiMjF0TUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFCkhXd3B0YWk2WGRidW5JSmR2cUc2QTZMU3pTSFZRSkNoYWU3ZkNLNnR3ZlhvSFdMVE1jeklaa2RzMTZHZnh3Sy8KY1JFbUM4Y2JsYytsREFFcVIzR0UzcU45TUhzd0RnWURWUjBQQVFIL0JBUURBZ0tFTUIwR0ExVWRKUVFXTUJRRwpDQ3NHQVFVRkJ3TUJCZ2dyQmdFRkJRY0RBakFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlRMCmtJSU95R2p4bGNIaHRnbWFxNm9PZS92WmhEQWFCZ05WSFJFRUV6QVJnZ2xzYjJOaGJHaHZjM1NIQkg4QUFBRXcKQ2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnUkVUSEhyZXNhRndoOW1udm9UZWNlNGFoWGJBWnFnSmFwVWdDSTF0YgovTXNDSVFDT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