bnb-chain / tss-lib

Threshold Signature Scheme, for ECDSA and EDDSA
MIT License
803 stars 273 forks source link

will you offer a complete demo code with network module for gen Key and address, sign, verify ? #193

Open powellsz opened 2 years ago

powellsz commented 2 years ago

as the binary tss in https://github.com/bnb-chain/node-binary/tree/master/cli/prod/0.6.2-TSS-0.1.2.

0xYao commented 2 years ago

bump 👍

r4881t commented 2 years ago

I tried to make it work my way (https://github.com/bnb-chain/tss-lib/issues/204), but unfortunately unable to get it. I am able to find an implementation that works, and it's here https://github.com/seemenkina/tss-lib-test

Here's how to use it

go.mod

module github.com/org/mpc-api-tsslib

go 1.16

replace github.com/agl/ed25519 => github.com/binance-chain/edwards25519 v0.0.0-20200305024217-f36fc4b53d43

require (
    github.com/binance-chain/tss-lib v1.3.2 // indirect
    github.com/ipfs/go-log v1.0.4 // indirect
    github.com/seemenkina/tss-lib-test v0.0.0-20200616040000-a1406bde7c52 // indirect
)

main.go

package main

import (
    "encoding/json"
    "fmt"
    "io"
    "log"
    "math/big"
    "net/http"
    "strings"

    "github.com/binance-chain/tss-lib/ecdsa/keygen"
    logging "github.com/ipfs/go-log"
    "github.com/seemenkina/tss-lib-test/tssInterface"
)

func keyGen(userIds []big.Int, threshold int) keygen.LocalPartySaveData {
        x := tssInterface.GenerateKeys(threshold, len(userIds), "hello")
        return x

}
powellsz commented 2 years ago

I tried to make it work my way (#204), but unfortunately unable to get it. I am able to find an implementation that works, and it's here https://github.com/seemenkina/tss-lib-test

Here's how to use it

go.mod

module github.com/org/mpc-api-tsslib

go 1.16

replace github.com/agl/ed25519 => github.com/binance-chain/edwards25519 v0.0.0-20200305024217-f36fc4b53d43

require (
  github.com/binance-chain/tss-lib v1.3.2 // indirect
  github.com/ipfs/go-log v1.0.4 // indirect
  github.com/seemenkina/tss-lib-test v0.0.0-20200616040000-a1406bde7c52 // indirect
)

main.go

package main

import (
  "encoding/json"
  "fmt"
  "io"
  "log"
  "math/big"
  "net/http"
  "strings"

  "github.com/binance-chain/tss-lib/ecdsa/keygen"
  logging "github.com/ipfs/go-log"
  "github.com/seemenkina/tss-lib-test/tssInterface"
)

func keyGen(userIds []big.Int, threshold int) keygen.LocalPartySaveData {
        x := tssInterface.GenerateKeys(threshold, len(userIds), "hello")
        return x

}

Thanks a lot.It's just a single instance. We need multi instances to communicate with each other and finish mpc .

r4881t commented 2 years ago

The actual implementation of network will depend on your use case. Out of curiosity, how does it look like?

oday0311 commented 2 years ago

the lib only has local test. You need to build network connection module or code , then connect the logic with the party update.