multi-party-sig icon indicating copy to clipboard operation
multi-party-sig copied to clipboard

Minimum example for creating keys & signing

Open Jefferson111 opened this issue 3 years ago • 0 comments

It would be great to have a minimum example on how to use this library. I tried following the example in README and it wasn't enough.

func main() {
    sessionID := []byte("dddd")
    ids := party.IDSlice{"a", "b", "c", "d", "e", "f"}
    threshold := 4
    pl := pool.NewPool(0)
    defer pl.TearDown()

    for _, id := range ids {
        handler, err := protocol.NewMultiHandler(cmp.Keygen(curve.Secp256k1{}, id, ids, threshold, pl), sessionID)
        if err != nil {
            // the handler was not able to start the protocol, most likely due to incorrect configuration.
            fmt.Println("error")
        }
        fmt.Println(handler.Result())
    }

The output of the handler just gives <nil> protocol: not finished My instinct tells me that I need to do something with the handler to make it work. So I tried adding this to handle my handlers based on the README

func runProtocol(handler *protocol.MultiHandler) {
    // Message handling loop
    for {
      select {
  
      // Message to be sent to other participants
      case msg, ok := <-handler.Listen():
        // a closed channel indicates that the protocol has finished executing
        if !ok {
          return
        }
        if handler.CanAccept(msg) {
            handler.Accept(msg)
        }
    }
  }
}

And it did not work.

So I gave up and open an issue on Github and hope that developer of this software is kind enough to provide an example on how to use their software

Jefferson111 avatar Aug 13 '22 15:08 Jefferson111