diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce390a8f..8393a2ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,10 +14,10 @@ jobs: runs-on: macOS-latest steps: - - name: Set up Go 1.16 + - name: Set up Go 1.17 uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.17 id: go - name: Check out code into the Go module directory @@ -27,5 +27,5 @@ jobs: run: go get -v -t -d ./... - name: Run Tests - run: make test_unit + run: make test diff --git a/.gitignore b/.gitignore index 85908b8a..ab3a5668 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ benchdata *.swp .vscode/*.json +# Test fixtures +test/*fixtures/*.json diff --git a/Makefile b/Makefile index 021f0465..faeb235c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ MODULE = github.com/binance-chain/tss-lib PACKAGES = $(shell go list ./... | grep -v '/vendor/') +UT_TIMEOUT = -timeout 60m +UT_COVER = -covermode=atomic -cover +UT_PACKAGES_LEVEL_0 = $(shell go list ./... | grep -v '/vendor/' | grep 'keygen' ) +UT_PACKAGES_LEVEL_1 = $(shell go list ./... | grep -v '/vendor/' | grep -v 'keygen' ) all: protob test @@ -29,24 +33,42 @@ build: protob ### Benchmarking benchgen: fmt - go run ./cmd/tss-benchgen benchdata + cd cmd && go run ./tss-benchgen benchdata benchsign: fmt - go run ./cmd/tss-benchsign benchdata + cd cmd && go run ./tss-benchsign benchdata ######################################## ### Testing -test_unit: - @echo "--> Running Unit Tests" +test_unit_level0: + @echo "--> Running Unit Tests - Level 0" @echo "!!! WARNING: This will take a long time :)" - go test -timeout 60m $(PACKAGES) + @echo "!!! WARNING: This will delete fixtures :(" + go clean -testcache + rm -f ./test/_ecdsa_fixtures/*json + rm -f ./test/_eddsa_fixtures/*json + go test ${UT_TIMEOUT} ${UT_COVER} $(UT_PACKAGES_LEVEL_0) -test_unit_race: - @echo "--> Running Unit Tests (with Race Detection)" + +test_unit: test_unit_level0 + @echo "--> Running Unit Tests - Level 1" + @echo "!!! WARNING: This will take a long time :)" + go test ${UT_TIMEOUT} ${UT_COVER} $(UT_PACKAGES_LEVEL_1) + +test_unit_race_level0: + @echo "--> Running Unit Tests (with Race Detection) - Level 0" + @echo "!!! WARNING: This will take a long time :)" + @echo "!!! WARNING: This will delete fixtures :(" + go clean -testcache + rm -f ./test/_ecdsa_fixtures/*json + rm -f ./test/_eddsa_fixtures/*json + go test -race ${UT_TIMEOUT} ${UT_COVER} $(UT_PACKAGES_LEVEL_0) + +test_unit_race: test_unit_race_level0 + @echo "--> Running Unit Tests (with Race Detection) - Level 1" @echo "!!! WARNING: This will take a long time :)" - # go clean -testcache - go test -timeout 60m -race $(PACKAGES) + go test -race ${UT_TIMEOUT} ${UT_COVER} $(UT_PACKAGES_LEVEL_1) test: make test_unit_race diff --git a/README.md b/README.md index 2ea214b5..ab61fa15 100644 --- a/README.md +++ b/README.md @@ -171,4 +171,3 @@ A full review of this library was carried out by Kudelski Security and their fin ## References \[1\] https://eprint.iacr.org/2020/540.pdf - diff --git a/cmd/go.mod b/cmd/go.mod new file mode 100644 index 00000000..601c1c20 --- /dev/null +++ b/cmd/go.mod @@ -0,0 +1,41 @@ +module github.com/binance-chain/tss-lib/cmd + +go 1.17 + +require ( + github.com/binance-chain/tss-lib v1.3.3 + github.com/btcsuite/btcd/btcec/v2 v2.0.0 + github.com/ipfs/go-log v1.0.5 + github.com/olekukonko/tablewriter v0.0.5 + github.com/pkg/errors v0.9.1 + golang.org/x/text v0.3.7 +) + +require ( + github.com/agl/ed25519 v0.0.0-20200305024217-f36fc4b53d43 // indirect + github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c // indirect + github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd // indirect + github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/ipfs/go-log/v2 v2.5.0 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/otiai10/primes v0.0.0-20210501021515-f1b2be525a11 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.7.0 // indirect + go.uber.org/zap v1.20.0 // indirect + golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed // indirect + golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect + google.golang.org/protobuf v1.27.1 // indirect +) + +replace github.com/binance-chain/tss-lib => github.com/SwingbyProtocol/tss-lib v1.5.1-0.20220129135114-1e9891f47740 + +replace github.com/agl/ed25519 => github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 + +replace github.com/btcsuite/btcd => github.com/Roasbeef/btcd v0.0.0-20220128222530-5a59e7c0ddfb + +replace github.com/btcsuite/btcd/btcec/v2 => github.com/Roasbeef/btcd/btcec/v2 v2.0.0-20220128222530-5a59e7c0ddfb diff --git a/cmd/go.sum b/cmd/go.sum new file mode 100644 index 00000000..41ef7521 --- /dev/null +++ b/cmd/go.sum @@ -0,0 +1,181 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Roasbeef/btcd v0.0.0-20220128222530-5a59e7c0ddfb h1:iiJ9fLbB/sG4MGNAOAi6DoezeasH2+Hnv/HN4lMMeu8= +github.com/Roasbeef/btcd v0.0.0-20220128222530-5a59e7c0ddfb/go.mod h1:vkwesBkYQtKXFYQYi9PyahtopbX53Tvk/O/qp2WI6Gk= +github.com/Roasbeef/btcd/btcec/v2 v2.0.0-20220128222530-5a59e7c0ddfb h1:BIc4awpCV2FjrFHI4fVjNjRVT6olrTvoF5ebpEucdto= +github.com/Roasbeef/btcd/btcec/v2 v2.0.0-20220128222530-5a59e7c0ddfb/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 h1:oJHEIS4MpbHUZP2P+9+bATmf4KQSX/SGwxdVoJKhrEI= +github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43/go.mod h1:l5lLTZ+iRubuGXG2bs2YcG4EkM2V2jqUOrjQlVDznuo= +github.com/SwingbyProtocol/tss-lib v1.5.1-0.20220129135114-1e9891f47740 h1:ayv/YCZMJCxCAyOlyBq+aXQCMTWXgbaN8iwf3/+uMH4= +github.com/SwingbyProtocol/tss-lib v1.5.1-0.20220129135114-1e9891f47740/go.mod h1:C7dIxMLqVUyn8chxz6dILIUo0o+OMxNQgqhqIy/kUko= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd h1:vAwk2PCYxzUUGAXXtw66PyY2IMCwWBnm8GR5aLIxS3Q= +github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 h1:bX7rtGTMBDJxujZ29GNqtn7YCAdINjHKnA6J6tBBv6s= +github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2/go.mod h1:d0H8xGMWbiIQP7gN3v2rByWUcuZPm9YsgmnfoxgbINc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= +github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= +github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= +github.com/ipfs/go-log/v2 v2.5.0 h1:+MhAooFd9XZNvR0i9FriKW6HB0ql7HNXUuflWtc0dd4= +github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= +github.com/otiai10/jsonindent v0.0.0-20171116142732-447bf004320b/go.mod h1:SXIpH2WO0dyF5YBc6Iq8jc8TEJYe1Fk2Rc1EVYUdIgY= +github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= +github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/otiai10/primes v0.0.0-20210501021515-f1b2be525a11 h1:7x5D/2dkkr27Tgh4WFuX+iCS6OzuE5YJoqJzeqM+5mc= +github.com/otiai10/primes v0.0.0-20210501021515-f1b2be525a11/go.mod h1:1DmRMnU78i/OVkMnHzvhXSi4p8IhYUmtLJWhyOavJc0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= +go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.20.0 h1:N4oPlghZwYG55MlU6LXk/Zp00FVNE9X9wrYO8CEs4lc= +go.uber.org/zap v1.20.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed h1:YoWVYYAfvQ4ddHv3OKmIvX7NCAhFGTj62VP2l2kfBbA= +golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/cmd/tss-benchsign/main.go b/cmd/tss-benchsign/main.go index 11a0302c..7a8d722a 100644 --- a/cmd/tss-benchsign/main.go +++ b/cmd/tss-benchsign/main.go @@ -18,7 +18,8 @@ import ( "github.com/binance-chain/tss-lib/ecdsa/signing" "github.com/binance-chain/tss-lib/test" "github.com/binance-chain/tss-lib/tss" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + ecdsa2 "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/ipfs/go-log" "github.com/olekukonko/tablewriter" "github.com/pkg/errors" @@ -194,10 +195,14 @@ outer: msg.Bytes(), r, s, ); !ok { - panic("ECDSA signature verification did not pass") + panic("ECDSA signature verification 1 did not pass") } - btcecSig := &btcec.Signature{R: r, S: s} - if ok = btcecSig.Verify(msg.Bytes(), (*btcec.PublicKey)(&pk)); !ok { + R := new(btcec.ModNScalar) + R.SetByteSlice(r.Bytes()) + S := new(btcec.ModNScalar) + S.SetByteSlice(s.Bytes()) + sig := ecdsa2.NewSignature(R, S) + if ok = sig.Verify(msg.Bytes(), keys[0].ECDSAPub.ToBtcecPubKey()); !ok { panic("ECDSA signature verification 2 did not pass") } break outer diff --git a/common/signature.pb.go b/common/signature.pb.go index 320e1d84..72a1fbcc 100644 --- a/common/signature.pb.go +++ b/common/signature.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/signature.proto package common diff --git a/common/slice.go b/common/slice.go index f48dc1d4..2162cc8c 100644 --- a/common/slice.go +++ b/common/slice.go @@ -78,3 +78,13 @@ func AnyNonEmptyMultiByte(bzs [][]byte, expectLen ...int) bool { } return false } + +func PadToLengthBytesInPlace(src []byte, length int) []byte { + oriLen := len(src) + if oriLen < length { + for i := 0; i < length-oriLen; i++ { + src = append([]byte{0}, src...) + } + } + return src +} diff --git a/crypto/ckd/child_key_derivation.go b/crypto/ckd/child_key_derivation.go index c906d302..981d619e 100644 --- a/crypto/ckd/child_key_derivation.go +++ b/crypto/ckd/child_key_derivation.go @@ -4,7 +4,6 @@ package ckd import ( "bytes" - "crypto/ecdsa" "crypto/elliptic" "crypto/hmac" "crypto/rand" @@ -17,13 +16,13 @@ import ( "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcutil/base58" "golang.org/x/crypto/ripemd160" ) type ExtendedKey struct { - ecdsa.PublicKey + *btcec.PublicKey Depth uint8 ChildIndex uint32 ChainCode []byte // 32 bytes @@ -71,7 +70,7 @@ func (k *ExtendedKey) String() string { serializedBytes = append(serializedBytes, k.ParentFP...) serializedBytes = append(serializedBytes, childNumBytes[:]...) serializedBytes = append(serializedBytes, k.ChainCode...) - pubKeyBytes := serializeCompressed(k.PublicKey.X, k.PublicKey.Y) + pubKeyBytes := serializeCompressed(k.PublicKey.X(), k.PublicKey.Y()) serializedBytes = append(serializedBytes, pubKeyBytes...) checkSum := doubleHashB(serializedBytes)[:4] @@ -104,23 +103,21 @@ func NewExtendedKeyFromString(key string, curve elliptic.Curve) (*ExtendedKey, e chainCode := payload[13:45] keyData := payload[45:78] - var pubKey ecdsa.PublicKey - - if c, ok := curve.(*btcec.KoblitzCurve); ok { + var pubKey *btcec.PublicKey + if _, ok := curve.(*btcec.KoblitzCurve); ok { // Ensure the public key parses correctly and is actually on the // secp256k1 curve. - pk, err := btcec.ParsePubKey(keyData, c) + pk, err := btcec.ParsePubKey(keyData) if err != nil { return nil, err } - pubKey = ecdsa.PublicKey(*pk) + pubKey = pk } else { + var x, y btcec.FieldVal px, py := elliptic.Unmarshal(curve, keyData) - pubKey = ecdsa.PublicKey{ - Curve: curve, - X: px, - Y: py, - } + x.SetByteSlice(px.Bytes()) + y.SetByteSlice(py.Bytes()) + pubKey = btcec.NewPublicKey(&x, &y) } return &ExtendedKey{ @@ -207,13 +204,13 @@ func DeriveChildKey(index uint32, pk *ExtendedKey, curve elliptic.Curve) (*big.I return nil, nil, errors.New("cannot derive key beyond max depth") } - cryptoPk, err := crypto.NewECPoint(curve, pk.X, pk.Y) + cryptoPk, err := crypto.NewECPoint(curve, pk.X(), pk.Y()) if err != nil { common.Logger.Error("error getting pubkey from extendedkey") return nil, nil, err } - pkPublicKeyBytes := serializeCompressed(pk.X, pk.Y) + pkPublicKeyBytes := serializeCompressed(pk.X(), pk.Y()) data := make([]byte, 37) copy(data, pkPublicKeyBytes) @@ -247,7 +244,7 @@ func DeriveChildKey(index uint32, pk *ExtendedKey, curve elliptic.Curve) (*big.I } childPk := &ExtendedKey{ - PublicKey: *childCryptoPk.ToECDSAPubKey(), + PublicKey: childCryptoPk.ToBtcecPubKey(), Depth: pk.Depth + 1, ChildIndex: index, ChainCode: childChainCode, @@ -257,6 +254,8 @@ func DeriveChildKey(index uint32, pk *ExtendedKey, curve elliptic.Curve) (*big.I return ilNum, childPk, nil } +// GenerateSeed +// TODO: Is this being used? func GenerateSeed(length uint8) ([]byte, error) { // Per [BIP32], the seed must be in range [MinSeedBytes, MaxSeedBytes]. if length < MinSeedBytes || length > MaxSeedBytes { diff --git a/crypto/ckd/child_key_derivation_test.go b/crypto/ckd/child_key_derivation_test.go index b1aa12b3..59d09318 100644 --- a/crypto/ckd/child_key_derivation_test.go +++ b/crypto/ckd/child_key_derivation_test.go @@ -10,7 +10,7 @@ import ( "testing" . "github.com/binance-chain/tss-lib/crypto/ckd" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) func TestPublicDerivation(t *testing.T) { diff --git a/crypto/ecpoint.go b/crypto/ecpoint.go index 4a6fddc3..6be63e2a 100644 --- a/crypto/ecpoint.go +++ b/crypto/ecpoint.go @@ -17,6 +17,8 @@ import ( "math/big" "github.com/binance-chain/tss-lib/tss" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/decred/dcrd/dcrec/edwards/v2" ) // ECPoint convenience helper @@ -58,12 +60,21 @@ func (p *ECPoint) ScalarMult(k *big.Int) *ECPoint { return newP } -func (p *ECPoint) ToECDSAPubKey() *ecdsa.PublicKey { - return &ecdsa.PublicKey{ +func (p *ECPoint) ToBtcecPubKey() *btcec.PublicKey { + var x, y btcec.FieldVal + x.SetByteSlice(p.X().Bytes()) + y.SetByteSlice(p.Y().Bytes()) + return btcec.NewPublicKey(&x, &y) +} + +func (p *ECPoint) ToEdwardsPubKey() *edwards.PublicKey { + ecdsaPK := ecdsa.PublicKey{ Curve: p.curve, X: p.X(), Y: p.Y(), } + pk := edwards.PublicKey(ecdsaPK) + return &pk } func (p *ECPoint) IsOnCurve() bool { @@ -90,6 +101,11 @@ func (p *ECPoint) ValidateBasic() bool { return p != nil && p.coords[0] != nil && p.coords[1] != nil && p.IsOnCurve() } +/* func (p *ECPoint) EightInvEight() *ECPoint { + return p.ScalarMult(eight).ScalarMult(eightInv) +} +*/ + func ScalarBaseMult(curve elliptic.Curve, k *big.Int) *ECPoint { x, y := curve.ScalarBaseMult(k.Bytes()) p, _ := NewECPoint(curve, x, y) // it must be on the curve, no need to check. diff --git a/crypto/ecpoint_test.go b/crypto/ecpoint_test.go index 3d79f7d0..8d4f821a 100644 --- a/crypto/ecpoint_test.go +++ b/crypto/ecpoint_test.go @@ -13,7 +13,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/decred/dcrd/dcrec/edwards/v2" "github.com/stretchr/testify/assert" @@ -126,10 +126,10 @@ func TestS256EcpointJsonSerialization(t *testing.T) { pubKeyBytes, err := hex.DecodeString("03935336acb03b2b801d8f8ac5e92c56c4f6e93319901fdfffba9d340a874e2879") assert.NoError(t, err) - pbk, err := btcec.ParsePubKey(pubKeyBytes, btcec.S256()) + pbk, err := btcec.ParsePubKey(pubKeyBytes) assert.NoError(t, err) - point, err := NewECPoint(ec, pbk.X, pbk.Y) + point, err := NewECPoint(ec, pbk.X(), pbk.Y()) assert.NoError(t, err) bz, err := json.Marshal(point) assert.NoError(t, err) @@ -144,7 +144,7 @@ func TestS256EcpointJsonSerialization(t *testing.T) { } func TestEdwardsEcpointJsonSerialization(t *testing.T) { - ec := edwards.Edwards() + ec := tss.Edwards() tss.RegisterCurve("ed25519", ec) pubKeyBytes, err := hex.DecodeString("ae1e5bf5f3d6bf58b5c222088671fcbe78b437e28fae944c793897b26091f249") diff --git a/crypto/mta/proofs.go b/crypto/mta/proofs.go index cab949a5..b2fdf15d 100644 --- a/crypto/mta/proofs.go +++ b/crypto/mta/proofs.go @@ -7,6 +7,7 @@ package mta import ( + "crypto/elliptic" "errors" "fmt" "math/big" @@ -14,7 +15,6 @@ import ( "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" "github.com/binance-chain/tss-lib/crypto/paillier" - "github.com/binance-chain/tss-lib/tss" ) const ( @@ -35,14 +35,14 @@ type ( // ProveBobWC implements Bob's proof both with or without check "ProveMtawc_Bob" and "ProveMta_Bob" used in the MtA protocol from GG18Spec (9) Figs. 10 & 11. // an absent `X` generates the proof without the X consistency check X = g^x -func ProveBobWC(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int, X *crypto.ECPoint) (*ProofBobWC, error) { +func ProveBobWC(ec elliptic.Curve, pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int, X *crypto.ECPoint) (*ProofBobWC, error) { if pk == nil || NTilde == nil || h1 == nil || h2 == nil || c1 == nil || c2 == nil || x == nil || y == nil || r == nil { return nil, errors.New("ProveBob() received a nil argument") } NSq := pk.NSquare() - q := tss.EC().Params().N + q := ec.Params().N q3 := new(big.Int).Mul(q, q) q3.Mul(q3, q) qNTilde := new(big.Int).Mul(q, NTilde) @@ -65,9 +65,9 @@ func ProveBobWC(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int gamma := common.GetRandomPositiveRelativelyPrimeInt(pk.N) // 5. - u := crypto.NewECPointNoCurveCheck(tss.EC(), zero, zero) // initialization suppresses an IDE warning + u := crypto.NewECPointNoCurveCheck(ec, zero, zero) // initialization suppresses an IDE warning if X != nil { - u = crypto.ScalarBaseMult(tss.EC(), alpha) + u = crypto.ScalarBaseMult(ec, alpha) } // 6. @@ -135,22 +135,22 @@ func ProveBobWC(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int } // ProveBob implements Bob's proof "ProveMta_Bob" used in the MtA protocol from GG18Spec (9) Fig. 11. -func ProveBob(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int) (*ProofBob, error) { +func ProveBob(ec elliptic.Curve, pk *paillier.PublicKey, NTilde, h1, h2, c1, c2, x, y, r *big.Int) (*ProofBob, error) { // the Bob proof ("with check") contains the ProofBob "without check"; this method extracts and returns it // X is supplied as nil to exclude it from the proof hash - pf, err := ProveBobWC(pk, NTilde, h1, h2, c1, c2, x, y, r, nil) + pf, err := ProveBobWC(ec, pk, NTilde, h1, h2, c1, c2, x, y, r, nil) if err != nil { return nil, err } return pf.ProofBob, nil } -func ProofBobWCFromBytes(bzs [][]byte) (*ProofBobWC, error) { +func ProofBobWCFromBytes(ec elliptic.Curve, bzs [][]byte) (*ProofBobWC, error) { proofBob, err := ProofBobFromBytes(bzs) if err != nil { return nil, err } - point, err := crypto.NewECPoint(tss.EC(), + point, err := crypto.NewECPoint(ec, new(big.Int).SetBytes(bzs[10]), new(big.Int).SetBytes(bzs[11])) if err != nil { @@ -185,12 +185,12 @@ func ProofBobFromBytes(bzs [][]byte) (*ProofBob, error) { // ProveBobWC.Verify implements verification of Bob's proof with check "VerifyMtawc_Bob" used in the MtA protocol from GG18Spec (9) Fig. 10. // an absent `X` verifies a proof generated without the X consistency check X = g^x -func (pf *ProofBobWC) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big.Int, X *crypto.ECPoint) bool { +func (pf *ProofBobWC) Verify(ec elliptic.Curve, pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big.Int, X *crypto.ECPoint) bool { if pk == nil || NTilde == nil || h1 == nil || h2 == nil || c1 == nil || c2 == nil { return false } - q := tss.EC().Params().N + q := ec.Params().N q3 := new(big.Int).Mul(q, q) q3.Mul(q3, q) @@ -216,8 +216,8 @@ func (pf *ProofBobWC) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big // 4. runs only in the "with check" mode from Fig. 10 if X != nil { - s1ModQ := new(big.Int).Mod(pf.S1, tss.EC().Params().N) - gS1 := crypto.ScalarBaseMult(tss.EC(), s1ModQ) + s1ModQ := new(big.Int).Mod(pf.S1, ec.Params().N) + gS1 := crypto.ScalarBaseMult(ec, s1ModQ) xEU, err := X.ScalarMult(e).Add(pf.U) if err != nil || !gS1.Equals(xEU) { return false @@ -268,12 +268,12 @@ func (pf *ProofBobWC) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big } // ProveBob.Verify implements verification of Bob's proof without check "VerifyMta_Bob" used in the MtA protocol from GG18Spec (9) Fig. 11. -func (pf *ProofBob) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big.Int) bool { +func (pf *ProofBob) Verify(ec elliptic.Curve, pk *paillier.PublicKey, NTilde, h1, h2, c1, c2 *big.Int) bool { if pf == nil { return false } pfWC := &ProofBobWC{ProofBob: pf, U: nil} - return pfWC.Verify(pk, NTilde, h1, h2, c1, c2, nil) + return pfWC.Verify(ec, pk, NTilde, h1, h2, c1, c2, nil) } func (pf *ProofBob) ValidateBasic() bool { diff --git a/crypto/mta/range_proof.go b/crypto/mta/range_proof.go index 9ef2fa00..f02d57a7 100644 --- a/crypto/mta/range_proof.go +++ b/crypto/mta/range_proof.go @@ -7,13 +7,13 @@ package mta import ( + "crypto/elliptic" "errors" "fmt" "math/big" "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto/paillier" - "github.com/binance-chain/tss-lib/tss" ) const ( @@ -31,12 +31,12 @@ type ( ) // ProveRangeAlice implements Alice's range proof used in the MtA and MtAwc protocols from GG18Spec (9) Fig. 9. -func ProveRangeAlice(pk *paillier.PublicKey, c, NTilde, h1, h2, m, r *big.Int) (*RangeProofAlice, error) { +func ProveRangeAlice(ec elliptic.Curve, pk *paillier.PublicKey, c, NTilde, h1, h2, m, r *big.Int) (*RangeProofAlice, error) { if pk == nil || NTilde == nil || h1 == nil || h2 == nil || c == nil || m == nil || r == nil { return nil, errors.New("ProveRangeAlice constructor received nil value(s)") } - q := tss.EC().Params().N + q := ec.Params().N q3 := new(big.Int).Mul(q, q) q3.Mul(q3, q) qNTilde := new(big.Int).Mul(q, NTilde) @@ -103,13 +103,12 @@ func RangeProofAliceFromBytes(bzs [][]byte) (*RangeProofAlice, error) { }, nil } -func (pf *RangeProofAlice) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c *big.Int) bool { +func (pf *RangeProofAlice) Verify(ec elliptic.Curve, pk *paillier.PublicKey, NTilde, h1, h2, c *big.Int) bool { if pf == nil || !pf.ValidateBasic() || pk == nil || NTilde == nil || h1 == nil || h2 == nil || c == nil { return false } - NSq := new(big.Int).Mul(pk.N, pk.N) - q := tss.EC().Params().N + q := ec.Params().N q3 := new(big.Int).Mul(q, q) q3.Mul(q3, q) @@ -129,14 +128,14 @@ func (pf *RangeProofAlice) Verify(pk *paillier.PublicKey, NTilde, h1, h2, c *big minusE := new(big.Int).Sub(zero, e) { // 4. gamma^s_1 * s^N * c^-e - modNSq := common.ModInt(NSq) + modNSquared := common.ModInt(pk.NSquare()) - cExpMinusE := modNSq.Exp(c, minusE) - sExpN := modNSq.Exp(pf.S, pk.N) - gammaExpS1 := modNSq.Exp(pk.Gamma(), pf.S1) + cExpMinusE := modNSquared.Exp(c, minusE) + sExpN := modNSquared.Exp(pf.S, pk.N) + gammaExpS1 := modNSquared.Exp(pk.Gamma(), pf.S1) // u != (4) - products = modNSq.Mul(gammaExpS1, sExpN) - products = modNSq.Mul(products, cExpMinusE) + products = modNSquared.Mul(gammaExpS1, sExpN) + products = modNSquared.Mul(products, cExpMinusE) if pf.U.Cmp(products) != 0 { return false } diff --git a/crypto/mta/range_proof_test.go b/crypto/mta/range_proof_test.go new file mode 100644 index 00000000..3e44394e --- /dev/null +++ b/crypto/mta/range_proof_test.go @@ -0,0 +1,45 @@ +// Copyright © 2019 Binance +// +// This file is part of Binance. The full Binance copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +package mta + +import ( + "math/big" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/binance-chain/tss-lib/common" + "github.com/binance-chain/tss-lib/crypto" + "github.com/binance-chain/tss-lib/crypto/paillier" + "github.com/binance-chain/tss-lib/tss" +) + +// Using a modulus length of 2048 is recommended in the GG18 spec +const ( + testSafePrimeBits = 1024 +) + +func TestProveRangeAlice(t *testing.T) { + q := tss.EC().Params().N + + sk, pk, err := paillier.GenerateKeyPair(testPaillierKeyLength, 10*time.Minute) + assert.NoError(t, err) + + m := common.GetRandomPositiveInt(q) + c, r, err := sk.EncryptAndReturnRandomness(m) + assert.NoError(t, err) + + primes := [2]*big.Int{common.GetRandomPrimeInt(testSafePrimeBits), common.GetRandomPrimeInt(testSafePrimeBits)} + NTildei, h1i, h2i, err := crypto.GenerateNTildei(primes) + assert.NoError(t, err) + proof, err := ProveRangeAlice(tss.EC(), pk, c, NTildei, h1i, h2i, m, r) + assert.NoError(t, err) + + ok := proof.Verify(tss.EC(), pk, NTildei, h1i, h2i, c) + assert.True(t, ok, "proof must verify") +} diff --git a/crypto/mta/share_protocol.go b/crypto/mta/share_protocol.go index 18ec99f3..f66aa485 100644 --- a/crypto/mta/share_protocol.go +++ b/crypto/mta/share_protocol.go @@ -7,32 +7,34 @@ package mta import ( + "crypto/elliptic" "errors" "math/big" "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" "github.com/binance-chain/tss-lib/crypto/paillier" - "github.com/binance-chain/tss-lib/tss" ) func AliceInit( + ec elliptic.Curve, pkA *paillier.PublicKey, a, cA, rA, NTildeB, h1B, h2B *big.Int, ) (pf *RangeProofAlice, err error) { - return ProveRangeAlice(pkA, cA, NTildeB, h1B, h2B, a, rA) + return ProveRangeAlice(ec, pkA, cA, NTildeB, h1B, h2B, a, rA) } func BobMid( + ec elliptic.Curve, pkA *paillier.PublicKey, pf *RangeProofAlice, b, cA, NTildeA, h1A, h2A, NTildeB, h1B, h2B *big.Int, ) (beta, cB, betaPrm *big.Int, piB *ProofBob, err error) { - if !pf.Verify(pkA, NTildeB, h1B, h2B, cA) { + if !pf.Verify(ec, pkA, NTildeB, h1B, h2B, cA) { err = errors.New("RangeProofAlice.Verify() returned false") return } - q := tss.EC().Params().N + q := ec.Params().N betaPrm = common.GetRandomPositiveInt(pkA.N) cBetaPrm, cRand, err := pkA.EncryptAndReturnRandomness(betaPrm) if err != nil { @@ -45,17 +47,18 @@ func BobMid( return } beta = common.ModInt(q).Sub(zero, betaPrm) - piB, err = ProveBob(pkA, NTildeA, h1A, h2A, cA, cB, b, betaPrm, cRand) + piB, err = ProveBob(ec, pkA, NTildeA, h1A, h2A, cA, cB, b, betaPrm, cRand) return } func BobMidWC( + ec elliptic.Curve, pkA *paillier.PublicKey, pf *RangeProofAlice, b, cA, NTildeA, h1A, h2A, NTildeB, h1B, h2B *big.Int, B *crypto.ECPoint, ) (betaPrm, cB *big.Int, piB *ProofBobWC, err error) { - if !pf.Verify(pkA, NTildeB, h1B, h2B, cA) { + if !pf.Verify(ec, pkA, NTildeB, h1B, h2B, cA) { err = errors.New("RangeProofAlice.Verify() returned false") return } @@ -72,43 +75,45 @@ func BobMidWC( if err != nil { return } - piB, err = ProveBobWC(pkA, NTildeA, h1A, h2A, cA, cB, b, betaPrm, cRand, B) + piB, err = ProveBobWC(ec, pkA, NTildeA, h1A, h2A, cA, cB, b, betaPrm, cRand, B) return } func AliceEnd( + ec elliptic.Curve, pkA *paillier.PublicKey, pf *ProofBob, h1A, h2A, cA, cB, NTildeA *big.Int, sk *paillier.PrivateKey, ) (alphaIJ *big.Int, err error) { - if !pf.Verify(pkA, NTildeA, h1A, h2A, cA, cB) { + if !pf.Verify(ec, pkA, NTildeA, h1A, h2A, cA, cB) { err = errors.New("ProofBob.Verify() returned false") return } if alphaIJ, err = sk.Decrypt(cB); err != nil { return } - q := tss.EC().Params().N + q := ec.Params().N alphaIJ.Mod(alphaIJ, q) return } func AliceEndWC( + ec elliptic.Curve, pkA *paillier.PublicKey, pf *ProofBobWC, B *crypto.ECPoint, cA, cB, NTildeA, h1A, h2A *big.Int, sk *paillier.PrivateKey, ) (muIJ, muIJRec, muIJRand *big.Int, err error) { - if !pf.Verify(pkA, NTildeA, h1A, h2A, cA, cB, B) { + if !pf.Verify(ec, pkA, NTildeA, h1A, h2A, cA, cB, B) { err = errors.New("ProofBobWC.Verify() returned false") return } if muIJRec, muIJRand, err = sk.DecryptAndRecoverRandomness(cB); err != nil { return } - q := tss.EC().Params().N + q := ec.Params().N muIJ = new(big.Int).Mod(muIJRec, q) return } diff --git a/crypto/mta/share_protocol_test.go b/crypto/mta/share_protocol_test.go index 5c3660c4..d65915d2 100644 --- a/crypto/mta/share_protocol_test.go +++ b/crypto/mta/share_protocol_test.go @@ -34,20 +34,20 @@ func TestShareProtocol(t *testing.T) { a := common.GetRandomPositiveInt(q) b := common.GetRandomPositiveInt(q) - NTildei, h1i, h2i, err := keygen.LoadNTildeH1H2FromTestFixture(0) + NTildei, h1i, h2i, err := keygen.ConstantTestNTildeH1H2(0) assert.NoError(t, err) - NTildej, h1j, h2j, err := keygen.LoadNTildeH1H2FromTestFixture(1) + NTildej, h1j, h2j, err := keygen.ConstantTestNTildeH1H2(1) assert.NoError(t, err) cA, rA, err := pk.EncryptAndReturnRandomness(a) assert.NoError(t, err) - pf, err := AliceInit(pk, a, cA, rA, NTildej, h1j, h2j) + pf, err := AliceInit(tss.EC(), pk, a, cA, rA, NTildej, h1j, h2j) assert.NoError(t, err) - _, cB, betaPrm, pfB, err := BobMid(pk, pf, b, cA, NTildei, h1i, h2i, NTildej, h1j, h2j) + _, cB, betaPrm, pfB, err := BobMid(tss.EC(), pk, pf, b, cA, NTildei, h1i, h2i, NTildej, h1j, h2j) assert.NoError(t, err) - alpha, err := AliceEnd(pk, pfB, h1i, h2i, cA, cB, NTildei, sk) + alpha, err := AliceEnd(tss.EC(), pk, pfB, h1i, h2i, cA, cB, NTildei, sk) assert.NoError(t, err) // expect: alpha = ab + betaPrm @@ -67,22 +67,22 @@ func TestShareProtocolWC(t *testing.T) { b := common.GetRandomPositiveInt(q) gBX, gBY := tss.EC().ScalarBaseMult(b.Bytes()) - NTildei, h1i, h2i, err := keygen.LoadNTildeH1H2FromTestFixture(0) + NTildei, h1i, h2i, err := keygen.ConstantTestNTildeH1H2(0) assert.NoError(t, err) - NTildej, h1j, h2j, err := keygen.LoadNTildeH1H2FromTestFixture(1) + NTildej, h1j, h2j, err := keygen.ConstantTestNTildeH1H2(1) assert.NoError(t, err) cA, rA, err := pk.EncryptAndReturnRandomness(a) assert.NoError(t, err) - pf, err := AliceInit(pk, a, cA, rA, NTildej, h1j, h2j) + pf, err := AliceInit(tss.EC(), pk, a, cA, rA, NTildej, h1j, h2j) assert.NoError(t, err) gBPoint, err := crypto.NewECPoint(tss.EC(), gBX, gBY) assert.NoError(t, err) - betaPrm, cB, pfB, err := BobMidWC(pk, pf, b, cA, NTildei, h1i, h2i, NTildej, h1j, h2j, gBPoint) + betaPrm, cB, pfB, err := BobMidWC(tss.EC(), pk, pf, b, cA, NTildei, h1i, h2i, NTildej, h1j, h2j, gBPoint) assert.NoError(t, err) - muIJ, _, muRandIJ, err := AliceEndWC(pk, pfB, gBPoint, cA, cB, NTildei, h1i, h2i, sk) + muIJ, _, muRandIJ, err := AliceEndWC(tss.EC(), pk, pfB, gBPoint, cA, cB, NTildei, h1i, h2i, sk) assert.NoError(t, err) assert.NotNil(t, muRandIJ) diff --git a/crypto/zkp/affg/affg_test.go b/crypto/zkp/affg/affg_test.go index 4320c7f1..3737d6f5 100644 --- a/crypto/zkp/affg/affg_test.go +++ b/crypto/zkp/affg/affg_test.go @@ -49,7 +49,7 @@ func TestAffg(test *testing.T) { Y, rhoy, err := pk1.EncryptAndReturnRandomness(y) assert.NoError(test, err) - NCap, s, t, err := keygen.LoadNTildeH1H2FromTestFixture(1) + NCap, s, t, err := keygen.ConstantTestNTildeH1H2(1) assert.NoError(test, err) C, _, err := pk0.EncryptAndReturnRandomness(a) diff --git a/crypto/zkp/mod/mod_test.go b/crypto/zkp/mod/mod_test.go index b2eef112..432c6385 100644 --- a/crypto/zkp/mod/mod_test.go +++ b/crypto/zkp/mod/mod_test.go @@ -17,7 +17,7 @@ import ( ) func TestMod(test *testing.T) { - preParams, err := keygen.GeneratePreParams(time.Minute*10, 8) + preParams, err := keygen.GeneratePreParams(time.Minute*20, 8) assert.NoError(test, err) p, q, N := preParams.P, preParams.Q, preParams.NTildei diff --git a/ecdsa/keygen/ecdsa-keygen.pb.go b/ecdsa/keygen/ecdsa-keygen.pb.go index 590d33b3..800d1461 100644 --- a/ecdsa/keygen/ecdsa-keygen.pb.go +++ b/ecdsa/keygen/ecdsa-keygen.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/ecdsa-keygen.proto package keygen diff --git a/ecdsa/keygen/local_party_test.go b/ecdsa/keygen/local_party_test.go index 565720ac..e035d0f1 100644 --- a/ecdsa/keygen/local_party_test.go +++ b/ecdsa/keygen/local_party_test.go @@ -225,9 +225,12 @@ func TestBadMessageCulprits(t *testing.T) { } assert.Equal(t, 1, len(err2.Culprits())) assert.Equal(t, pIDs[1], err2.Culprits()[0]) - assert.Equal(t, - "task ecdsa-keygen, party {0,P[1]}, round 1, culprits [{1,2}]: message failed ValidateBasic: Type: binance.tsslib.ecdsa.keygen.KGRound1Message, From: {1,2}", - err2.Error()) + assert.Regexpf(t, `^task ecdsa-keygen, party.+round 1, culprits.+message failed ValidateBasic.+KGRound1Message`, err2.Error(), "unexpected culprit error message") + assert.Regexpf(t, `^task ecdsa-keygen, party.+round 1, culprits.+1,.*2.+message failed ValidateBasic.+KGRound1Message`, err2.Error(), "unexpected culprit error message") + + // expected: "task ecdsa-keygen, party {0,P[1]}, round 1, culprits [{1,2}]: message failed ValidateBasic: Type: binance.tsslib.ecdsa.keygen.KGRound1Message, From: {1,2}", + // or "[...] culprits [{1,P[2]}]: message failed[...]" + } func TestE2EConcurrentAndSaveFixtures(t *testing.T) { diff --git a/ecdsa/keygen/round_1.go b/ecdsa/keygen/round_1.go index 51374e46..1a42f781 100644 --- a/ecdsa/keygen/round_1.go +++ b/ecdsa/keygen/round_1.go @@ -41,7 +41,7 @@ func (round *round1) Start() *tss.Error { // Fig 5. Round 1. private key part ridi := common.GetRandomPositiveInt(round.EC().Params().N) - ui := common.GetRandomPositiveInt(round.EC().Params().N) + ui := common.GetRandomPositiveInt(round.Params().EC().Params().N) // Fig 5. Round 1. pub key part, vss shares ids := round.Parties().IDs().Keys() diff --git a/ecdsa/keygen/save_data.go b/ecdsa/keygen/save_data.go index 4e51bca0..a01e20eb 100644 --- a/ecdsa/keygen/save_data.go +++ b/ecdsa/keygen/save_data.go @@ -8,9 +8,9 @@ package keygen import ( "encoding/hex" + "errors" "math/big" - "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" "github.com/binance-chain/tss-lib/crypto/paillier" "github.com/binance-chain/tss-lib/tss" @@ -68,7 +68,7 @@ func (preParams LocalPreParams) Validate() bool { func (preParams LocalPreParams) ValidateWithProof() bool { return preParams.Validate() && - //preParams.Alpha != nil && + // preParams.Alpha != nil && preParams.Beta != nil && preParams.P != nil && preParams.Q != nil @@ -87,7 +87,7 @@ func BuildLocalSaveDataSubset(sourceData LocalPartySaveData, sortedIDs tss.Sorte for j, id := range sortedIDs { savedIdx, ok := keysToIndices[hex.EncodeToString(id.Key)] if !ok { - common.Logger.Warning("BuildLocalSaveDataSubset: unable to find a signer party in the local save data", id) + panic(errors.New("BuildLocalSaveDataSubset: unable to find a signer party in the local save data")) } newData.Ks[j] = sourceData.Ks[savedIdx] newData.NTildej[j] = sourceData.NTildej[savedIdx] diff --git a/ecdsa/keygen/test_utils.go b/ecdsa/keygen/test_utils.go index 81355fca..5d2e52b6 100644 --- a/ecdsa/keygen/test_utils.go +++ b/ecdsa/keygen/test_utils.go @@ -7,6 +7,7 @@ package keygen import ( + "encoding/hex" "encoding/json" "fmt" "io/ioutil" @@ -28,11 +29,26 @@ const ( TestParticipants = test.TestParticipants TestThreshold = test.TestThreshold ) + const ( testFixtureDirFormat = "%s/../../test/_ecdsa_fixtures" testFixtureFileFormat = "keygen_data_%d.json" ) +var ( + constTestNTildei0, _ = hex.DecodeString("deaf005da2e13f26b1821700f495b4bc9f29145055ec1fdba496b85fcd5b217190473c42176104381cc0475385e929798fd09fec37626082e825bdadd54e3910e9e55a0a45903c57ec9f4c26006c62c5d81725d94a3d3ddbe427ef34f11b7f177f78862fff4612d9536272c5951aee9974bb98bdbfebcd4ad40ee26204f3425d18dde90e6976a5cfdd2fb8a476ee5be3fbd6fd5f32d5697735df420f84d6c4ad6f4754dcea0a3f036aeeeefbf65337694f14e442cba0e862449174e7d6edd023cbad7329adae6917fcc028de5e3fc681e6a601ef2de7503a3485b6809ee54dc82ab8edc178a934b42b2dd9b7b778307050373f6b51b20179ef3997befebeb3d5") + constTestH1i0, _ = hex.DecodeString("8a263bf5d5b19bd0c0ca2a57d7181f987a0ad39ece0ad3dbf747cbcaa4296f048e3b8306a25bb9fb426b00cb78423e8f741e7e1b48bc6c3cb8d036cc482b5734888e66eecb0b33afd026f2bd98fc2ca57aede26f82f416accfc21999442b10fdfa7a962a8607ff10eeb2f3512b0bfa72097cdcc65fe25a1f6681b605804fa2f554e972b9f10931094d1edc3888f1cb98528a77cea2a9597a2c91177e4d28ec50d32a2b26162c28988fac633c5839db916e00a56e5b33130fefd5662ddca80224fd1b9d924f676b944b387b89a283e02aab9def9d3e9be04f59a8b2545b6a55f4a5a4e996d0b2ae431baad205f5a47067bea561885c55a16e52f36bda2a36bc4d") + constTestH2i0, _ = hex.DecodeString("d375f48fda5728f8d8db394dde4c024922c23ac8e09ba84bf14360da0ded6a257416baac2ef6879aa508f57dd31e120d05976126673dd5df4d677cf24c87eb52dcdd6c47da61c4e221ae45bfa19e088784d7a512f8f0a90fedfbea44e05abe95120a9ec8a0d0bea473677b390a220bd7a83e3d79482314109b17ab8b596f2b46b8c1620ce232a44245c920cbfc7ac94010181c4d10c4cece99da3f3a20359ec3271666b7885b6a94538a7ab4d70066ddeb30a6f40b036f3f9e61dfc4bfdf91a5e2e9719e4ab65f479e9f66fef347795abb0f8ce47ac9ca0aa75471c9fafdba72d2e3b4c7ae231fcefd3bffdc93292b16cc8a28a0c935de64c33d91f750d63635") + + constTestNTildei1, _ = hex.DecodeString("deaf005da2e13f26b1821700f495b4bc9f29145055ec1fdba496b85fcd5b217190473c42176104381cc0475385e929798fd09fec37626082e825bdadd54e3910e9e55a0a45903c57ec9f4c26006c62c5d81725d94a3d3ddbe427ef34f11b7f177f78862fff4612d9536272c5951aee9974bb98bdbfebcd4ad40ee26204f3425d18dde90e6976a5cfdd2fb8a476ee5be3fbd6fd5f32d5697735df420f84d6c4ad6f4754dcea0a3f036aeeeefbf65337694f14e442cba0e862449174e7d6edd023cbad7329adae6917fcc028de5e3fc681e6a601ef2de7503a3485b6809ee54dc82ab8edc178a934b42b2dd9b7b778307050373f6b51b20179ef3997befebeb3d5") + constTestH1i1, _ = hex.DecodeString("8a263bf5d5b19bd0c0ca2a57d7181f987a0ad39ece0ad3dbf747cbcaa4296f048e3b8306a25bb9fb426b00cb78423e8f741e7e1b48bc6c3cb8d036cc482b5734888e66eecb0b33afd026f2bd98fc2ca57aede26f82f416accfc21999442b10fdfa7a962a8607ff10eeb2f3512b0bfa72097cdcc65fe25a1f6681b605804fa2f554e972b9f10931094d1edc3888f1cb98528a77cea2a9597a2c91177e4d28ec50d32a2b26162c28988fac633c5839db916e00a56e5b33130fefd5662ddca80224fd1b9d924f676b944b387b89a283e02aab9def9d3e9be04f59a8b2545b6a55f4a5a4e996d0b2ae431baad205f5a47067bea561885c55a16e52f36bda2a36bc4d") + constTestH2i1, _ = hex.DecodeString("d375f48fda5728f8d8db394dde4c024922c23ac8e09ba84bf14360da0ded6a257416baac2ef6879aa508f57dd31e120d05976126673dd5df4d677cf24c87eb52dcdd6c47da61c4e221ae45bfa19e088784d7a512f8f0a90fedfbea44e05abe95120a9ec8a0d0bea473677b390a220bd7a83e3d79482314109b17ab8b596f2b46b8c1620ce232a44245c920cbfc7ac94010181c4d10c4cece99da3f3a20359ec3271666b7885b6a94538a7ab4d70066ddeb30a6f40b036f3f9e61dfc4bfdf91a5e2e9719e4ab65f479e9f66fef347795abb0f8ce47ac9ca0aa75471c9fafdba72d2e3b4c7ae231fcefd3bffdc93292b16cc8a28a0c935de64c33d91f750d63635") + + constTestNTildeiArray = [][]byte{constTestNTildei0, constTestNTildei1} + constTestH1iArray = [][]byte{constTestH1i0, constTestH1i1} + constTestH2iArray = [][]byte{constTestH2i0, constTestH2i1} +) + func LoadKeygenTestFixtures(qty int, optionalStart ...int) ([]LocalPartySaveData, tss.SortedPartyIDs, error) { keys := make([]LocalPartySaveData, 0, qty) start := 0 @@ -120,6 +136,12 @@ func LoadNTildeH1H2FromTestFixture(idx int) (NTildei, h1i, h2i *big.Int, err err return } +func ConstantTestNTildeH1H2(idx int) (NTildei, h1i, h2i *big.Int, err error) { + NTildei = big.NewInt(0).SetBytes(constTestNTildeiArray[idx]) + h1i, h2i = big.NewInt(0).SetBytes(constTestH1iArray[idx]), big.NewInt(0).SetBytes(constTestH2iArray[idx]) + return +} + func makeTestFixtureFilePath(partyIndex int) string { _, callerFileName, _, _ := runtime.Caller(0) srcDirName := filepath.Dir(callerFileName) diff --git a/ecdsa/resharing/ecdsa-resharing.pb.go b/ecdsa/resharing/ecdsa-resharing.pb.go index 904504cb..a527c83e 100644 --- a/ecdsa/resharing/ecdsa-resharing.pb.go +++ b/ecdsa/resharing/ecdsa-resharing.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/ecdsa-resharing.proto package resharing diff --git a/ecdsa/signing/ecdsa-signature.pb.go b/ecdsa/signing/ecdsa-signature.pb.go deleted file mode 100644 index 23baeca0..00000000 --- a/ecdsa/signing/ecdsa-signature.pb.go +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright © 2019 Binance -// -// This file is part of Binance. The full Binance copyright notice, including -// terms governing use, modification, and redistribution, is contained in the -// file LICENSE at the root of the source code distribution tree. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.1 -// protoc v3.17.3 -// source: protob/ecdsa-signature.proto - -package signing - -import ( - common "github.com/binance-chain/tss-lib/common" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// -// State object for signatures, either partial (for offline/async "one round" signing) or full (contains the final ECDSA signature). -type SignatureData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Signature *common.ECSignature `protobuf:"bytes,10,opt,name=signature,proto3" json:"signature,omitempty"` - OneRoundData *SignatureData_OneRoundData `protobuf:"bytes,11,opt,name=one_round_data,json=oneRoundData,proto3" json:"one_round_data,omitempty"` -} - -func (x *SignatureData) Reset() { - *x = SignatureData{} - if protoimpl.UnsafeEnabled { - mi := &file_protob_ecdsa_signature_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignatureData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignatureData) ProtoMessage() {} - -func (x *SignatureData) ProtoReflect() protoreflect.Message { - mi := &file_protob_ecdsa_signature_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignatureData.ProtoReflect.Descriptor instead. -func (*SignatureData) Descriptor() ([]byte, []int) { - return file_protob_ecdsa_signature_proto_rawDescGZIP(), []int{0} -} - -func (x *SignatureData) GetSignature() *common.ECSignature { - if x != nil { - return x.Signature - } - return nil -} - -func (x *SignatureData) GetOneRoundData() *SignatureData_OneRoundData { - if x != nil { - return x.OneRoundData - } - return nil -} - -type SignatureData_OneRoundData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Sanity check in FinalizeGetAndVerifyFinalSig - T int32 `protobuf:"varint,1,opt,name=t,proto3" json:"t,omitempty"` - // Components to produce s = sum(s_i) - KI []byte `protobuf:"bytes,2,opt,name=k_i,json=kI,proto3" json:"k_i,omitempty"` - RSigmaI []byte `protobuf:"bytes,3,opt,name=r_sigma_i,json=rSigmaI,proto3" json:"r_sigma_i,omitempty"` - BigR *common.ECPoint `protobuf:"bytes,4,opt,name=big_r,json=bigR,proto3" json:"big_r,omitempty"` - // Components for identifiable aborts during the final phase - BigRBarJ map[string]*common.ECPoint `protobuf:"bytes,5,rep,name=big_r_bar_j,json=bigRBarJ,proto3" json:"big_r_bar_j,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - BigSJ map[string]*common.ECPoint `protobuf:"bytes,6,rep,name=big_s_j,json=bigSJ,proto3" json:"big_s_j,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *SignatureData_OneRoundData) Reset() { - *x = SignatureData_OneRoundData{} - if protoimpl.UnsafeEnabled { - mi := &file_protob_ecdsa_signature_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignatureData_OneRoundData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignatureData_OneRoundData) ProtoMessage() {} - -func (x *SignatureData_OneRoundData) ProtoReflect() protoreflect.Message { - mi := &file_protob_ecdsa_signature_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignatureData_OneRoundData.ProtoReflect.Descriptor instead. -func (*SignatureData_OneRoundData) Descriptor() ([]byte, []int) { - return file_protob_ecdsa_signature_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *SignatureData_OneRoundData) GetT() int32 { - if x != nil { - return x.T - } - return 0 -} - -func (x *SignatureData_OneRoundData) GetKI() []byte { - if x != nil { - return x.KI - } - return nil -} - -func (x *SignatureData_OneRoundData) GetRSigmaI() []byte { - if x != nil { - return x.RSigmaI - } - return nil -} - -func (x *SignatureData_OneRoundData) GetBigR() *common.ECPoint { - if x != nil { - return x.BigR - } - return nil -} - -func (x *SignatureData_OneRoundData) GetBigRBarJ() map[string]*common.ECPoint { - if x != nil { - return x.BigRBarJ - } - return nil -} - -func (x *SignatureData_OneRoundData) GetBigSJ() map[string]*common.ECPoint { - if x != nil { - return x.BigSJ - } - return nil -} - -var File_protob_ecdsa_signature_proto protoreflect.FileDescriptor - -var file_protob_ecdsa_signature_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x2f, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2d, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x03, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x45, 0x43, 0x53, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x12, 0x41, 0x0a, 0x0e, 0x6f, 0x6e, 0x65, 0x5f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x4f, 0x6e, 0x65, 0x52, 0x6f, 0x75, - 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0c, 0x6f, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x6e, 0x64, - 0x44, 0x61, 0x74, 0x61, 0x1a, 0xfd, 0x02, 0x0a, 0x0c, 0x4f, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x6e, - 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x01, 0x74, 0x12, 0x0f, 0x0a, 0x03, 0x6b, 0x5f, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x02, 0x6b, 0x49, 0x12, 0x1a, 0x0a, 0x09, 0x72, 0x5f, 0x73, 0x69, 0x67, 0x6d, 0x61, 0x5f, - 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x53, 0x69, 0x67, 0x6d, 0x61, 0x49, - 0x12, 0x1d, 0x0a, 0x05, 0x62, 0x69, 0x67, 0x5f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x08, 0x2e, 0x45, 0x43, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x04, 0x62, 0x69, 0x67, 0x52, 0x12, - 0x48, 0x0a, 0x0b, 0x62, 0x69, 0x67, 0x5f, 0x72, 0x5f, 0x62, 0x61, 0x72, 0x5f, 0x6a, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x2e, 0x4f, 0x6e, 0x65, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x61, 0x74, - 0x61, 0x2e, 0x42, 0x69, 0x67, 0x52, 0x42, 0x61, 0x72, 0x4a, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x08, 0x62, 0x69, 0x67, 0x52, 0x42, 0x61, 0x72, 0x4a, 0x12, 0x3e, 0x0a, 0x07, 0x62, 0x69, 0x67, - 0x5f, 0x73, 0x5f, 0x6a, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x53, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x4f, 0x6e, 0x65, 0x52, 0x6f, - 0x75, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x42, 0x69, 0x67, 0x53, 0x4a, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x05, 0x62, 0x69, 0x67, 0x53, 0x4a, 0x1a, 0x45, 0x0a, 0x0d, 0x42, 0x69, 0x67, - 0x52, 0x42, 0x61, 0x72, 0x4a, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x45, 0x43, - 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x1a, 0x42, 0x0a, 0x0a, 0x42, 0x69, 0x67, 0x53, 0x4a, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x08, 0x2e, 0x45, 0x43, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x2d, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x2f, 0x74, 0x73, 0x73, 0x2d, 0x6c, 0x69, 0x62, 0x2f, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2f, 0x73, - 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_protob_ecdsa_signature_proto_rawDescOnce sync.Once - file_protob_ecdsa_signature_proto_rawDescData = file_protob_ecdsa_signature_proto_rawDesc -) - -func file_protob_ecdsa_signature_proto_rawDescGZIP() []byte { - file_protob_ecdsa_signature_proto_rawDescOnce.Do(func() { - file_protob_ecdsa_signature_proto_rawDescData = protoimpl.X.CompressGZIP(file_protob_ecdsa_signature_proto_rawDescData) - }) - return file_protob_ecdsa_signature_proto_rawDescData -} - -var file_protob_ecdsa_signature_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_protob_ecdsa_signature_proto_goTypes = []interface{}{ - (*SignatureData)(nil), // 0: SignatureData - (*SignatureData_OneRoundData)(nil), // 1: SignatureData.OneRoundData - nil, // 2: SignatureData.OneRoundData.BigRBarJEntry - nil, // 3: SignatureData.OneRoundData.BigSJEntry - (*common.ECSignature)(nil), // 4: ECSignature - (*common.ECPoint)(nil), // 5: ECPoint -} -var file_protob_ecdsa_signature_proto_depIdxs = []int32{ - 4, // 0: SignatureData.signature:type_name -> ECSignature - 1, // 1: SignatureData.one_round_data:type_name -> SignatureData.OneRoundData - 5, // 2: SignatureData.OneRoundData.big_r:type_name -> ECPoint - 2, // 3: SignatureData.OneRoundData.big_r_bar_j:type_name -> SignatureData.OneRoundData.BigRBarJEntry - 3, // 4: SignatureData.OneRoundData.big_s_j:type_name -> SignatureData.OneRoundData.BigSJEntry - 5, // 5: SignatureData.OneRoundData.BigRBarJEntry.value:type_name -> ECPoint - 5, // 6: SignatureData.OneRoundData.BigSJEntry.value:type_name -> ECPoint - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_protob_ecdsa_signature_proto_init() } -func file_protob_ecdsa_signature_proto_init() { - if File_protob_ecdsa_signature_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_protob_ecdsa_signature_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SignatureData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_protob_ecdsa_signature_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SignatureData_OneRoundData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_protob_ecdsa_signature_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_protob_ecdsa_signature_proto_goTypes, - DependencyIndexes: file_protob_ecdsa_signature_proto_depIdxs, - MessageInfos: file_protob_ecdsa_signature_proto_msgTypes, - }.Build() - File_protob_ecdsa_signature_proto = out.File - file_protob_ecdsa_signature_proto_rawDesc = nil - file_protob_ecdsa_signature_proto_goTypes = nil - file_protob_ecdsa_signature_proto_depIdxs = nil -} diff --git a/ecdsa/signing/ecdsa-signing.pb.go b/ecdsa/signing/ecdsa-signing.pb.go index 3dc2ea8a..3cc996ce 100644 --- a/ecdsa/signing/ecdsa-signing.pb.go +++ b/ecdsa/signing/ecdsa-signing.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/ecdsa-signing.proto package signing diff --git a/ecdsa/signing/key_derivation_test.go b/ecdsa/signing/key_derivation_test.go index 39ad6c20..b29b0ec2 100644 --- a/ecdsa/signing/key_derivation_test.go +++ b/ecdsa/signing/key_derivation_test.go @@ -10,7 +10,6 @@ import ( "sync/atomic" "testing" - "github.com/btcsuite/btcd/btcec" "github.com/stretchr/testify/assert" "github.com/binance-chain/tss-lib/common" @@ -28,7 +27,7 @@ import ( // in signing. Our code does not require updates u_i or the VSS commitment to the polynomial either, // as these are not used during the signing phase. func TestHDKeyDerivation(t *testing.T) { - setUp("debug") + setUp("info") threshold := testThreshold // PHASE: load keygen fixtures @@ -39,12 +38,7 @@ func TestHDKeyDerivation(t *testing.T) { assert.NotNil(t, keys[0].ECDSAPub, "the first ECDSA public key must not be null") // build ecdsa key pair - parentPkX, parentPkY := keys[0].ECDSAPub.X(), keys[0].ECDSAPub.Y() - pk := ecdsa.PublicKey{ - Curve: tss.EC(), - X: parentPkX, - Y: parentPkY, - } + pk := keys[0].ECDSAPub.ToBtcecPubKey() // setting the chain code to a random positive number smaller than the maximum allowed of 32 bytes chainCode := make([]byte, 32) @@ -66,7 +60,7 @@ func TestHDKeyDerivation(t *testing.T) { keyDerivationDelta := il - err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, &extendedChildPk.PublicKey, tss.EC()) + err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, extendedChildPk.PublicKey, tss.EC()) assert.NoErrorf(t, err, "there should not be an error setting the derived keys") // PHASE: signing @@ -117,8 +111,7 @@ signing: bigRX, bigRY := parties[0].temp.BigR.X(), parties[0].temp.BigR.Y() bigR := crypto.NewECPointNoCurveCheck(tss.EC(), bigRX, bigRY) - r := parties[0].temp.Rx - fmt.Printf("sign result: R(%s, %s), r=%s\n", bigR.X().String(), bigR.Y().String(), r.String()) + // fmt.Printf("sign result: R(%s, %s), r=%s\n", bigR.X().String(), bigR.Y().String(), r.String()) modN := common.ModInt(tss.EC().Params().N) @@ -127,16 +120,17 @@ signing: for _, p := range parties { sumS = modN.Add(sumS, p.temp.SigmaShare) } - fmt.Printf("S: %s\n", sumS.String()) + // fmt.Printf("S: %s\n", sumS.String()) // END check s correctness - ok := ecdsa.Verify(&extendedChildPk.PublicKey, msg.Bytes(), bigR.X(), sumS) + ecdsaPK := &ecdsa.PublicKey{ + Curve: tss.EC(), + X: extendedChildPk.X(), + Y: extendedChildPk.Y(), + } + ok := ecdsa.Verify(ecdsaPK, msg.Bytes(), bigR.X(), sumS) assert.True(t, ok, "ecdsa verify must pass") - btcecSig := &btcec.Signature{R: r, S: sumS} - btcecSig.Verify(msg.Bytes(), (*btcec.PublicKey)(&extendedChildPk.PublicKey)) - assert.True(t, ok, "ecdsa verify 2 must pass") - t.Log("ECDSA signing test done.") // END ECDSA verify diff --git a/ecdsa/signing/key_derivation_util.go b/ecdsa/signing/key_derivation_util.go index e6192d98..82f11719 100644 --- a/ecdsa/signing/key_derivation_util.go +++ b/ecdsa/signing/key_derivation_util.go @@ -3,7 +3,6 @@ package signing import ( - "crypto/ecdsa" "crypto/elliptic" "math/big" @@ -11,15 +10,16 @@ import ( "github.com/binance-chain/tss-lib/crypto" "github.com/binance-chain/tss-lib/crypto/ckd" "github.com/binance-chain/tss-lib/ecdsa/keygen" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" ) func UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta *big.Int, keys []keygen.LocalPartySaveData, - extendedChildPk *ecdsa.PublicKey, ec elliptic.Curve) error { + extendedChildPk *btcec.PublicKey, ec elliptic.Curve) error { var err error gDelta := crypto.ScalarBaseMult(ec, keyDerivationDelta) for k := range keys { - keys[k].ECDSAPub, err = crypto.NewECPoint(ec, extendedChildPk.X, extendedChildPk.Y) + keys[k].ECDSAPub, err = crypto.NewECPoint(ec, extendedChildPk.X(), extendedChildPk.Y()) if err != nil { common.Logger.Errorf("error creating new extended child public key") return err @@ -39,12 +39,7 @@ func UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta *big.Int, keys []keygen.Lo func derivingPubkeyFromPath(masterPub *crypto.ECPoint, chainCode []byte, path []uint32, ec elliptic.Curve) (*big.Int, *ckd.ExtendedKey, error) { // build ecdsa key pair - pk := ecdsa.PublicKey{ - Curve: ec, - X: masterPub.X(), - Y: masterPub.Y(), - } - + pk := masterPub.ToBtcecPubKey() net := &chaincfg.MainNetParams extendedParentPk := &ckd.ExtendedKey{ PublicKey: pk, @@ -54,6 +49,5 @@ func derivingPubkeyFromPath(masterPub *crypto.ECPoint, chainCode []byte, path [] ParentFP: []byte{0x00, 0x00, 0x00, 0x00}, Version: net.HDPrivateKeyID[:], } - return ckd.DeriveChildKeyFromHierarchy(path, extendedParentPk, ec.Params().N, ec) } diff --git a/ecdsa/signing/local_party_test.go b/ecdsa/signing/local_party_test.go index 6cf6864c..c499176e 100644 --- a/ecdsa/signing/local_party_test.go +++ b/ecdsa/signing/local_party_test.go @@ -21,7 +21,7 @@ import ( "github.com/binance-chain/tss-lib/crypto/paillier" zkpdec "github.com/binance-chain/tss-lib/crypto/zkp/dec" zkplogstar "github.com/binance-chain/tss-lib/crypto/zkp/logstar" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/ipfs/go-log" "github.com/stretchr/testify/assert" @@ -137,8 +137,8 @@ signing: if atomic.LoadInt32(&ended) == int32(len(signPIDs)) { t.Logf("Done. Received signature data from %d participants", ended) R := parties[0].temp.BigR - r := parties[0].temp.Rx - fmt.Printf("sign result: R(%s, %s), r=%s\n", R.X().String(), R.Y().String(), r.String()) + // r := parties[0].temp.Rx + // fmt.Printf("sign result: R(%s, %s), r=%s\n", R.X().String(), R.Y().String(), r.String()) modN := common.ModInt(tss.S256().Params().N) @@ -147,7 +147,7 @@ signing: for _, p := range parties { sumS = modN.Add(sumS, p.temp.SigmaShare) } - fmt.Printf("S: %s\n", sumS.String()) + // fmt.Printf("S: %s\n", sumS.String()) // END check s correctness // BEGIN ECDSA verify @@ -188,7 +188,7 @@ func TestE2EWithHDKeyDerivation(t *testing.T) { keyDerivationDelta := il - err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, &extendedChildPk.PublicKey, btcec.S256()) + err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, extendedChildPk.PublicKey, btcec.S256()) assert.NoErrorf(t, err, "there should not be an error setting the derived keys") // PHASE: signing @@ -246,8 +246,8 @@ signing: if atomic.LoadInt32(&ended) == int32(len(signPIDs)) { t.Logf("Done. Received signature data from %d participants", ended) R := parties[0].temp.BigR - r := parties[0].temp.Rx - fmt.Printf("sign result: R(%s, %s), r=%s\n", R.X().String(), R.Y().String(), r.String()) + // r := parties[0].temp.Rx + // fmt.Printf("sign result: R(%s, %s), r=%s\n", R.X().String(), R.Y().String(), r.String()) modN := common.ModInt(tss.S256().Params().N) @@ -256,7 +256,7 @@ signing: for _, p := range parties { sumS = modN.Add(sumS, p.temp.SigmaShare) } - fmt.Printf("S: %s\n", sumS.String()) + // fmt.Printf("S: %s\n", sumS.String()) // END check s correctness // BEGIN ECDSA verify @@ -375,7 +375,7 @@ func identifiedAbortUpdater(party tss.Party, msg tss.Message, parties []*LocalPa } func TestAbortIdentification(t *testing.T) { - setUp("debug") + setUp("info") threshold := testThreshold // PHASE: load keygen fixtures @@ -457,7 +457,7 @@ signing: } func TestIdAbortSimulateRound7(test *testing.T) { - setUp("debug") + setUp("info") var err error ec := tss.S256() q := ec.Params().N @@ -636,7 +636,7 @@ func TestIdAbortSimulateRound7(test *testing.T) { func TestFillTo32BytesInPlace(t *testing.T) { s := big.NewInt(123456789) - normalizedS := padToLengthBytesInPlace(s.Bytes(), 32) + normalizedS := common.PadToLengthBytesInPlace(s.Bytes(), 32) assert.True(t, big.NewInt(0).SetBytes(normalizedS).Cmp(s) == 0) assert.Equal(t, 32, len(normalizedS)) assert.NotEqual(t, 32, len(s.Bytes())) diff --git a/ecdsa/signing/mta_test.go b/ecdsa/signing/mta_test.go index 9c1cea58..142adf87 100644 --- a/ecdsa/signing/mta_test.go +++ b/ecdsa/signing/mta_test.go @@ -46,7 +46,7 @@ func TestAffg(test *testing.T) { gammai := common.GetRandomPositiveInt(q) BigGammai := crypto.ScalarBaseMult(ec, gammai) - NCap, s, t, err := keygen.LoadNTildeH1H2FromTestFixture(1) + NCap, s, t, err := keygen.ConstantTestNTildeH1H2(1) assert.NoError(test, err) MtaOut, err := NewMtA(ec, Kj, gammai, BigGammai, pkj, pki, NCap, s, t) @@ -83,7 +83,7 @@ func TestDec(test *testing.T) { 𝛾i := common.GetRandomPositiveInt(q) Γi := crypto.ScalarBaseMult(ec, 𝛾i) - NCap, s, t, err := keygen.LoadNTildeH1H2FromTestFixture(1) + NCap, s, t, err := keygen.ConstantTestNTildeH1H2(1) assert.NoError(test, err) N2 := pkj.NSquare() diff --git a/ecdsa/signing/rounds.go b/ecdsa/signing/rounds.go index 36405c34..c6167086 100644 --- a/ecdsa/signing/rounds.go +++ b/ecdsa/signing/rounds.go @@ -13,7 +13,7 @@ import ( ) const ( - TaskName = "signing" + TaskName = "ecdsa-signing" ) type ( diff --git a/ecdsa/signing/sign_out.go b/ecdsa/signing/sign_out.go index 5d6c2efd..0b640ef6 100644 --- a/ecdsa/signing/sign_out.go +++ b/ecdsa/signing/sign_out.go @@ -74,8 +74,8 @@ func (round *signout) Start() *tss.Error { // save the signature for final output bitSizeInBytes := round.Params().EC().Params().BitSize / 8 - round.data.R = padToLengthBytesInPlace(round.temp.Rx.Bytes(), bitSizeInBytes) - round.data.S = padToLengthBytesInPlace(Sigma.Bytes(), bitSizeInBytes) + round.data.R = common.PadToLengthBytesInPlace(round.temp.Rx.Bytes(), bitSizeInBytes) + round.data.S = common.PadToLengthBytesInPlace(Sigma.Bytes(), bitSizeInBytes) round.data.Signature = append(round.data.R, round.data.S...) round.data.SignatureRecovery = []byte{byte(recid)} round.data.M = round.temp.m.Bytes() @@ -109,13 +109,3 @@ func (round *signout) Update() (bool, *tss.Error) { func (round *signout) NextRound() tss.Round { return nil // finished! } - -func padToLengthBytesInPlace(src []byte, length int) []byte { - oriLen := len(src) - if oriLen < length { - for i := 0; i < length-oriLen; i++ { - src = append([]byte{0}, src...) - } - } - return src -} diff --git a/eddsa/keygen/eddsa-keygen.pb.go b/eddsa/keygen/eddsa-keygen.pb.go index fd8ec69c..0b4afd81 100644 --- a/eddsa/keygen/eddsa-keygen.pb.go +++ b/eddsa/keygen/eddsa-keygen.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/eddsa-keygen.proto package keygen diff --git a/eddsa/keygen/local_party_test.go b/eddsa/keygen/local_party_test.go index 7957657b..4cd101cb 100644 --- a/eddsa/keygen/local_party_test.go +++ b/eddsa/keygen/local_party_test.go @@ -15,20 +15,23 @@ import ( "sync/atomic" "testing" - "github.com/decred/dcrd/dcrec/edwards/v2" - "github.com/ipfs/go-log" - "github.com/stretchr/testify/assert" - "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" "github.com/binance-chain/tss-lib/crypto/vss" "github.com/binance-chain/tss-lib/test" "github.com/binance-chain/tss-lib/tss" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/decred/dcrd/dcrec/edwards/v2" + "github.com/ipfs/go-log" + "github.com/stretchr/testify/assert" ) const ( - testParticipants = TestParticipants - testThreshold = TestThreshold + testParticipants = TestParticipants + testThreshold = TestThreshold + testSetIdS256Schnorr = "S256" + testSetIdEdwards = "Edwards" ) func setUp(level string) { @@ -37,11 +40,11 @@ func setUp(level string) { } } -func TestE2EConcurrentAndSaveFixtures(t *testing.T) { +func TestE2EConcurrentAndSaveFixturesEdwards(t *testing.T) { setUp("info") threshold := testThreshold - fixtures, pIDs, err := LoadKeygenTestFixtures(testParticipants) + fixtures, pIDs, err := LoadKeygenTestFixtures(testParticipants, testSetIdEdwards) if err != nil { common.Logger.Info("No test fixtures were found, so the safe primes will be generated from scratch. This may take a while...") pIDs = tss.GenerateTestPartyIDs(testParticipants) @@ -61,7 +64,7 @@ func TestE2EConcurrentAndSaveFixtures(t *testing.T) { // init the parties for i := 0; i < len(pIDs); i++ { var P *LocalParty - params := tss.NewParameters(tss.Edwards(), p2pCtx, pIDs[i], len(pIDs), threshold) + params := tss.NewParameters(tss.Edwards(), p2pCtx, pIDs[i], len(pIDs), threshold) // TODO if i < len(fixtures) { P = NewLocalParty(params, outCh, endCh).(*LocalParty) } else { @@ -108,7 +111,7 @@ keygen: // .. here comes a workaround to recover this party's index (it was removed from save data) index, err := save.OriginalIndex() assert.NoErrorf(t, err, "should not be an error getting a party's index from save data") - tryWriteTestFixtureFile(t, index, save) + tryWriteTestFixtureFile(t, index, testSetIdEdwards, save) atomic.AddInt32(&ended, 1) if atomic.LoadInt32(&ended) == int32(len(pIDs)) { @@ -116,6 +119,7 @@ keygen: // combine shares for each Pj to get u u := new(big.Int) + modQ := common.ModInt(tss.Edwards().Params().N) for j, Pj := range parties { pShares := make(vss.Shares, 0) for j2, P := range parties { @@ -156,9 +160,8 @@ keygen: assert.NotEqual(t, BigXjX, Pj.temp.vs[0].X()) assert.NotEqual(t, BigXjY, Pj.temp.vs[0].Y()) } - u = new(big.Int).Add(u, uj) + u = modQ.Add(u, uj) } - u = new(big.Int).Mod(u, tss.Edwards().Params().N) scalar := make([]byte, 0, 32) copy(scalar, u.Bytes()) @@ -169,8 +172,10 @@ keygen: X: pkX, Y: pkY, } - println("u len: ", len(u.Bytes())) - sk, _, err := edwards.PrivKeyFromScalar(u.Bytes()) + t.Logf("u len: %v", len(u.Bytes())) + uBytes := common.PadToLengthBytesInPlace(u.Bytes(), edwards.PrivScalarSize) + sk, _, err := edwards.PrivKeyFromScalar(uBytes) + assert.NoError(t, err, "error loading private key") // fmt.Println("err: ", err.Error()) // test pub key, should be on curve and match pkX, pkY @@ -209,8 +214,187 @@ keygen: } } -func tryWriteTestFixtureFile(t *testing.T, index int, data LocalPartySaveData) { - fixtureFileName := makeTestFixtureFilePath(index) +func TestE2EConcurrentAndSaveFixturesS256Schnorr(t *testing.T) { + setUp("info") + + threshold := testThreshold + fixtures, pIDs, err := LoadKeygenTestFixtures(testParticipants, testSetIdS256Schnorr) + if err != nil { + common.Logger.Info("No test fixtures were found, so the safe primes will be generated from scratch. This may take a while...") + pIDs = tss.GenerateTestPartyIDs(testParticipants) + } + + p2pCtx := tss.NewPeerContext(pIDs) + parties := make([]*LocalParty, 0, len(pIDs)) + + errCh := make(chan *tss.Error, len(pIDs)) + outCh := make(chan tss.Message, len(pIDs)) + endCh := make(chan LocalPartySaveData, len(pIDs)) + + updater := test.SharedPartyUpdater + + startGR := runtime.NumGoroutine() + + // init the parties + for i := 0; i < len(pIDs); i++ { + var P *LocalParty + params := tss.NewParameters(tss.S256(), p2pCtx, pIDs[i], len(pIDs), threshold) + if i < len(fixtures) { + P = NewLocalParty(params, outCh, endCh).(*LocalParty) + } else { + P = NewLocalParty(params, outCh, endCh).(*LocalParty) + } + parties = append(parties, P) + go func(P *LocalParty) { + if err := P.Start(); err != nil { + errCh <- err + } + }(P) + } + + // PHASE: keygen + var ended int32 +keygen: + for { + fmt.Printf("ACTIVE GOROUTINES: %d\n", runtime.NumGoroutine()) + select { + case err := <-errCh: + common.Logger.Errorf("Error: %s", err) + assert.FailNow(t, err.Error()) + break keygen + + case msg := <-outCh: + dest := msg.GetTo() + if dest == nil { // broadcast! + for _, P := range parties { + if P.PartyID().Index == msg.GetFrom().Index { + continue + } + go updater(P, msg, errCh) + } + } else { // point-to-point! + if dest[0].Index == msg.GetFrom().Index { + t.Fatalf("party %d tried to send a message to itself (%d)", dest[0].Index, msg.GetFrom().Index) + return + } + go updater(parties[dest[0].Index], msg, errCh) + } + + case save := <-endCh: + // SAVE a test fixture file for this P (if it doesn't already exist) + // .. here comes a workaround to recover this party's index (it was removed from save data) + index, err := save.OriginalIndex() + assert.NoErrorf(t, err, "should not be an error getting a party's index from save data") + tryWriteTestFixtureFile(t, index, testSetIdS256Schnorr, save) + + atomic.AddInt32(&ended, 1) + if atomic.LoadInt32(&ended) == int32(len(pIDs)) { + t.Logf("Done. Received save data from %d participants", ended) + + // combine shares for each Pj to get u + u := new(big.Int) + for j, Pj := range parties { + pShares := make(vss.Shares, 0) + for j2, P := range parties { + if j2 == j { + continue + } + P.Lock() + vssMsgs := P.temp.kgRound2Message1s + share := vssMsgs[j].Content().(*KGRound2Message1).Share + P.Unlock() + shareStruct := &vss.Share{ + Threshold: threshold, + ID: P.PartyID().KeyInt(), + Share: new(big.Int).SetBytes(share), + } + pShares = append(pShares, shareStruct) + } + uj, err := pShares[:threshold+1].ReConstruct(tss.S256()) + assert.NoError(t, err, "vss.ReConstruct should not throw error") + + // uG test: u*G[j] == V[0] + if eq := assert.Equal(t, uj, Pj.temp.ui); !eq { + t.Logf("Pj: %v, uj: %v, ui: %v", Pj, + common.FormatBigInt(uj), common.FormatBigInt(Pj.temp.ui)) + t.FailNow() + } + uG := crypto.ScalarBaseMult(tss.S256(), uj) + if eq := assert.Equal(t, uG, Pj.temp.vs[0], "ensure u*G[j] == V_0"); !eq { + t.Logf("Pj: %v", Pj) + t.FailNow() + } + + // xj tests: BigXj == xj*G + xj := Pj.data.Xi + gXj := crypto.ScalarBaseMult(tss.S256(), xj) + BigXj := Pj.data.BigXj[j] + assert.True(t, BigXj.Equals(gXj), "ensure BigX_j == g^x_j") + + // fails if threshold cannot be satisfied (bad share) + { + badShares := pShares[:threshold] + badShares[len(badShares)-1].Share.Set(big.NewInt(0)) + uj, err := pShares[:threshold].ReConstruct(tss.S256()) + assert.NoError(t, err) + assert.NotEqual(t, parties[j].temp.ui, uj) + BigXjX, BigXjY := tss.S256().ScalarBaseMult(uj.Bytes()) + assert.NotEqual(t, BigXjX, Pj.temp.vs[0].X()) + assert.NotEqual(t, BigXjY, Pj.temp.vs[0].Y()) + } + u = new(big.Int).Add(u, uj) + } + u = new(big.Int).Mod(u, tss.S256().Params().N) + t.Logf("u len: %v", len(u.Bytes())) + + scalar := make([]byte, 0, 32) + copy(scalar, u.Bytes()) + + // build eddsa key pair + pkX, pkY := save.EDDSAPub.X(), save.EDDSAPub.Y() + pk := save.EDDSAPub.ToBtcecPubKey() + sk, _ := btcec.PrivKeyFromBytes(u.Bytes()) + // fmt.Println("err: ", err.Error()) + + // test pub key, should be on curve and match pkX, pkY + assert.True(t, pk.IsOnCurve(), "public key must be on curve") + + // public key tests + assert.NotZero(t, u, "u should not be zero") + ourPkX, ourPkY := tss.S256().ScalarBaseMult(u.Bytes()) + assert.Equal(t, pkX, ourPkX, "pkX should match expected pk derived from u") + assert.Equal(t, pkY, ourPkY, "pkY should match expected pk derived from u") + t.Log("Public key tests done.") + + // make sure everyone has the same EdDSA public key + for _, Pj := range parties { + assert.Equal(t, pkX, Pj.data.EDDSAPub.X()) + assert.Equal(t, pkY, Pj.data.EDDSAPub.Y()) + } + t.Logf("Public key: X: %v, Y: %v", common.FormatBigInt(pkX), common.FormatBigInt(pkY)) + t.Log("Public key distribution test done.") + + // test sign/verify + data := make([]byte, 32) + for i := range data { + data[i] = byte(i) + } + signature, err := schnorr.Sign(sk, data) + assert.NoError(t, err, "sign should not throw an error") + ok := signature.Verify(data, save.EDDSAPub.ToBtcecPubKey()) + assert.True(t, ok, "signature should be ok") + t.Log("EdDSA signing test done.") + + t.Logf("Start goroutines: %d, End goroutines: %d", startGR, runtime.NumGoroutine()) + + break keygen + } + } + } +} + +func tryWriteTestFixtureFile(t *testing.T, index int, testSetId string, data LocalPartySaveData) { + fixtureFileName := makeTestFixtureFilePath(testSetId, index) // fixture file does not already exist? // if it does, we won't re-create it here diff --git a/eddsa/keygen/test_utils.go b/eddsa/keygen/test_utils.go index a4655f70..9994aa41 100644 --- a/eddsa/keygen/test_utils.go +++ b/eddsa/keygen/test_utils.go @@ -29,17 +29,17 @@ const ( ) const ( testFixtureDirFormat = "%s/../../test/_eddsa_fixtures" - testFixtureFileFormat = "keygen_data_%d.json" + testFixtureFileFormat = "keygen_data_%s_%d.json" ) -func LoadKeygenTestFixtures(qty int, optionalStart ...int) ([]LocalPartySaveData, tss.SortedPartyIDs, error) { +func LoadKeygenTestFixtures(qty int, testSetId string, optionalStart ...int) ([]LocalPartySaveData, tss.SortedPartyIDs, error) { keys := make([]LocalPartySaveData, 0, qty) start := 0 if 0 < len(optionalStart) { start = optionalStart[0] } for i := start; i < qty; i++ { - fixtureFilePath := makeTestFixtureFilePath(i) + fixtureFilePath := makeTestFixtureFilePath(testSetId, i) bz, err := ioutil.ReadFile(fixtureFilePath) if err != nil { return nil, nil, errors.Wrapf(err, @@ -67,7 +67,7 @@ func LoadKeygenTestFixtures(qty int, optionalStart ...int) ([]LocalPartySaveData return keys, sortedPIDs, nil } -func LoadKeygenTestFixturesRandomSet(qty, fixtureCount int) ([]LocalPartySaveData, tss.SortedPartyIDs, error) { +func LoadKeygenTestFixturesRandomSet(qty, fixtureCount int, testSetId string) ([]LocalPartySaveData, tss.SortedPartyIDs, error) { keys := make([]LocalPartySaveData, 0, qty) plucked := make(map[int]interface{}, qty) for i := 0; len(plucked) < qty; i = (i + 1) % fixtureCount { @@ -77,7 +77,7 @@ func LoadKeygenTestFixturesRandomSet(qty, fixtureCount int) ([]LocalPartySaveDat } } for i := range plucked { - fixtureFilePath := makeTestFixtureFilePath(i) + fixtureFilePath := makeTestFixtureFilePath(testSetId, i) bz, err := ioutil.ReadFile(fixtureFilePath) if err != nil { return nil, nil, errors.Wrapf(err, @@ -109,9 +109,9 @@ func LoadKeygenTestFixturesRandomSet(qty, fixtureCount int) ([]LocalPartySaveDat return keys, sortedPIDs, nil } -func makeTestFixtureFilePath(partyIndex int) string { +func makeTestFixtureFilePath(testSetId string, partyIndex int) string { _, callerFileName, _, _ := runtime.Caller(0) srcDirName := filepath.Dir(callerFileName) fixtureDirName := fmt.Sprintf(testFixtureDirFormat, srcDirName) - return fmt.Sprintf("%s/"+testFixtureFileFormat, fixtureDirName, partyIndex) + return fmt.Sprintf("%s/"+testFixtureFileFormat, fixtureDirName, testSetId, partyIndex) } diff --git a/eddsa/resharing/eddsa-resharing.pb.go b/eddsa/resharing/eddsa-resharing.pb.go index edcfdcb1..c5790b46 100644 --- a/eddsa/resharing/eddsa-resharing.pb.go +++ b/eddsa/resharing/eddsa-resharing.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/eddsa-resharing.proto package resharing diff --git a/eddsa/resharing/local_party_test.go b/eddsa/resharing/local_party_test.go index 105be357..c7e4dc78 100644 --- a/eddsa/resharing/local_party_test.go +++ b/eddsa/resharing/local_party_test.go @@ -27,6 +27,7 @@ import ( const ( testParticipants = test.TestParticipants testThreshold = test.TestThreshold + testSetIdEdwards = "Edwards" ) func setUp(level string) { @@ -45,7 +46,7 @@ func TestE2EConcurrent(t *testing.T) { // PHASE: load keygen fixtures firstPartyIdx, extraParties := 0, 1 // // extra can be 0 to N-first - oldKeys, oldPIDs, err := keygen.LoadKeygenTestFixtures(testThreshold+1+extraParties+firstPartyIdx, firstPartyIdx) + oldKeys, oldPIDs, err := keygen.LoadKeygenTestFixtures(testThreshold+1+extraParties+firstPartyIdx, testSetIdEdwards, firstPartyIdx) assert.NoError(t, err, "should load keygen fixtures") // PHASE: resharing diff --git a/eddsa/resharing/messages.go b/eddsa/resharing/messages.go index a1e79f69..80cb32d7 100644 --- a/eddsa/resharing/messages.go +++ b/eddsa/resharing/messages.go @@ -26,6 +26,7 @@ var ( (*DGRound2Message)(nil), (*DGRound3Message1)(nil), (*DGRound3Message2)(nil), + (*DGRound4Message)(nil), } ) diff --git a/eddsa/signing/eddsa-signature.pb.go b/eddsa/signing/eddsa-signature.pb.go deleted file mode 100644 index ce282594..00000000 --- a/eddsa/signing/eddsa-signature.pb.go +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright © 2019 Binance -// -// This file is part of Binance. The full Binance copyright notice, including -// terms governing use, modification, and redistribution, is contained in the -// file LICENSE at the root of the source code distribution tree. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.1 -// protoc v3.17.3 -// source: protob/eddsa-signature.proto - -package signing - -import ( - common "github.com/binance-chain/tss-lib/common" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// -// State object for signatures, contains the final EdDSA signature. -type SignatureData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Signature *common.ECSignature `protobuf:"bytes,10,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (x *SignatureData) Reset() { - *x = SignatureData{} - if protoimpl.UnsafeEnabled { - mi := &file_protob_eddsa_signature_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignatureData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignatureData) ProtoMessage() {} - -func (x *SignatureData) ProtoReflect() protoreflect.Message { - mi := &file_protob_eddsa_signature_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignatureData.ProtoReflect.Descriptor instead. -func (*SignatureData) Descriptor() ([]byte, []int) { - return file_protob_eddsa_signature_proto_rawDescGZIP(), []int{0} -} - -func (x *SignatureData) GetSignature() *common.ECSignature { - if x != nil { - return x.Signature - } - return nil -} - -var File_protob_eddsa_signature_proto protoreflect.FileDescriptor - -var file_protob_eddsa_signature_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x2f, 0x65, 0x64, 0x64, 0x73, 0x61, 0x2d, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x3b, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x45, 0x43, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, - 0x69, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x2d, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2f, 0x74, 0x73, 0x73, - 0x2d, 0x6c, 0x69, 0x62, 0x2f, 0x65, 0x64, 0x64, 0x73, 0x61, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x69, - 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_protob_eddsa_signature_proto_rawDescOnce sync.Once - file_protob_eddsa_signature_proto_rawDescData = file_protob_eddsa_signature_proto_rawDesc -) - -func file_protob_eddsa_signature_proto_rawDescGZIP() []byte { - file_protob_eddsa_signature_proto_rawDescOnce.Do(func() { - file_protob_eddsa_signature_proto_rawDescData = protoimpl.X.CompressGZIP(file_protob_eddsa_signature_proto_rawDescData) - }) - return file_protob_eddsa_signature_proto_rawDescData -} - -var file_protob_eddsa_signature_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_protob_eddsa_signature_proto_goTypes = []interface{}{ - (*SignatureData)(nil), // 0: SignatureData - (*common.ECSignature)(nil), // 1: ECSignature -} -var file_protob_eddsa_signature_proto_depIdxs = []int32{ - 1, // 0: SignatureData.signature:type_name -> ECSignature - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_protob_eddsa_signature_proto_init() } -func file_protob_eddsa_signature_proto_init() { - if File_protob_eddsa_signature_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_protob_eddsa_signature_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SignatureData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_protob_eddsa_signature_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_protob_eddsa_signature_proto_goTypes, - DependencyIndexes: file_protob_eddsa_signature_proto_depIdxs, - MessageInfos: file_protob_eddsa_signature_proto_msgTypes, - }.Build() - File_protob_eddsa_signature_proto = out.File - file_protob_eddsa_signature_proto_rawDesc = nil - file_protob_eddsa_signature_proto_goTypes = nil - file_protob_eddsa_signature_proto_depIdxs = nil -} diff --git a/eddsa/signing/eddsa-signing.pb.go b/eddsa/signing/eddsa-signing.pb.go index 94343b6c..ed3887be 100644 --- a/eddsa/signing/eddsa-signing.pb.go +++ b/eddsa/signing/eddsa-signing.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/eddsa-signing.proto package signing diff --git a/eddsa/signing/finalize.go b/eddsa/signing/finalize.go index efb255e7..2ac468a6 100644 --- a/eddsa/signing/finalize.go +++ b/eddsa/signing/finalize.go @@ -7,15 +7,17 @@ package signing import ( + "encoding/hex" "errors" "fmt" "math/big" + "strings" "github.com/agl/ed25519/edwards25519" - "github.com/decred/dcrd/dcrec/edwards/v2" - "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/tss" + "github.com/decred/dcrd/dcrec/edwards/v2" + errors2 "github.com/pkg/errors" ) func (round *finalization) Start() *tss.Error { @@ -26,43 +28,75 @@ func (round *finalization) Start() *tss.Error { round.started = true round.resetOK() - sumS := round.temp.si - for j := range round.Parties().IDs() { - round.ok[j] = true - if j == round.PartyID().Index { - continue + ok := false + var s *big.Int + var sumS *[32]byte + + _, isTwistedEdwardsCurve := round.Params().EC().(*edwards.TwistedEdwardsCurve) + isSecp256k1Curve := strings.Compare("secp256k1", round.Params().EC().Params().Name) == 0 + + if isTwistedEdwardsCurve { + sumS = bigIntToEncodedBytes(&round.temp.si) + for j := range round.Parties().IDs() { + round.ok[j] = true + if j == round.PartyID().Index { + continue + } + r3msg := round.temp.signRound3Messages[j].Content().(*SignRound3Message) + sjBytes := bigIntToEncodedBytes(r3msg.UnmarshalS()) + var tmpSumS [32]byte + edwards25519.ScMulAdd(&tmpSumS, sumS, bigIntToEncodedBytes(big.NewInt(1)), sjBytes) + + sumS = &tmpSumS } - r3msg := round.temp.signRound3Messages[j].Content().(*SignRound3Message) - sjBytes := bigIntToEncodedBytes(r3msg.UnmarshalS()) - var tmpSumS [32]byte - edwards25519.ScMulAdd(&tmpSumS, sumS, bigIntToEncodedBytes(big.NewInt(1)), sjBytes) - sumS = &tmpSumS + s = encodedBytesToBigInt(sumS) + } else if isSecp256k1Curve { + sumSInt := &round.temp.si + modN := common.ModInt(tss.S256().Params().N) + for j := range round.Parties().IDs() { + round.ok[j] = true + if j == round.PartyID().Index { + continue + } + r3msg := round.temp.signRound3Messages[j].Content().(*SignRound3Message) + sumSInt = modN.Add(sumSInt, r3msg.UnmarshalS()) + } + // if we adjusted R by adding aG to find R with an even Y coordinate, add a to s also. + s = modN.Add(sumSInt, big.NewInt(int64(round.temp.a))) } - s := encodedBytesToBigInt(sumS) // save the signature for final output signature := new(common.ECSignature) - signature.Signature = append(bigIntToEncodedBytes(round.temp.r)[:], sumS[:]...) - signature.R = bigIntToEncodedBytes(round.temp.r)[:] - signature.S = bigIntToEncodedBytes(s)[:] + if isTwistedEdwardsCurve { + signature.Signature = append(bigIntToEncodedBytes(round.temp.r)[:], sumS[:]...) + signature.R = bigIntToEncodedBytes(round.temp.r)[:] + signature.S = bigIntToEncodedBytes(s)[:] + } else if isSecp256k1Curve { + var r32b, s32b [32]byte + encode32bytes(round.temp.r, &r32b) + encode32bytes(s, &s32b) + signature.Signature = append(r32b[:], s32b[:]...) + signature.R = r32b[:] + signature.S = s32b[:] + } signature.M = round.temp.m.Bytes() round.data.R = signature.R round.data.S = signature.S round.data.Signature = append(round.data.R, round.data.S...) - pk := edwards.PublicKey{ - Curve: round.Params().EC(), - X: round.key.EDDSAPub.X(), - Y: round.key.EDDSAPub.Y(), - } - - ok := edwards.Verify(&pk, round.temp.m.Bytes(), round.temp.r, s) - if !ok { - return round.WrapError(fmt.Errorf("signature verification failed")) + if isTwistedEdwardsCurve { + common.Logger.Debugf("finalize - r: %v, s:%v", hex.EncodeToString(round.temp.r.Bytes()), + hex.EncodeToString(s.Bytes())) + if ok = edwards.Verify(round.key.EDDSAPub.ToEdwardsPubKey(), round.temp.m.Bytes(), round.temp.r, s); !ok { + return round.WrapError(fmt.Errorf("edwards signature verification failed")) + } + } else if isSecp256k1Curve { + if err := SchnorrVerify(round.key.EDDSAPub.ToBtcecPubKey(), round.temp.m.Bytes(), round.temp.r, s); err != nil { + return round.WrapError(errors2.Wrapf(err, "schnorr signature verification failed")) + } } round.end <- *round.data - return nil } @@ -80,12 +114,6 @@ func (round *finalization) NextRound() tss.Round { return nil // finished! } -func padToLengthBytesInPlace(src []byte, length int) []byte { - oriLen := len(src) - if oriLen < length { - for i := 0; i < length-oriLen; i++ { - src = append([]byte{0}, src...) - } - } - return src +func encode32bytes(i *big.Int, buff *[32]byte) { + i.FillBytes(buff[:]) } diff --git a/eddsa/signing/local_party.go b/eddsa/signing/local_party.go index ee765389..8097e3f8 100644 --- a/eddsa/signing/local_party.go +++ b/eddsa/signing/local_party.go @@ -55,10 +55,11 @@ type ( // round 2 cjs []*big.Int - si *[32]byte + si big.Int // round 3 r *big.Int + a int // aG, ensuring R with even Y } ) diff --git a/eddsa/signing/local_party_test.go b/eddsa/signing/local_party_test.go index 5f71e01f..29b436ee 100644 --- a/eddsa/signing/local_party_test.go +++ b/eddsa/signing/local_party_test.go @@ -7,6 +7,8 @@ package signing import ( + "encoding/hex" + "fmt" "math/big" "sync/atomic" "testing" @@ -23,25 +25,28 @@ import ( ) const ( - testParticipants = test.TestParticipants - testThreshold = test.TestThreshold + testParticipants = test.TestParticipants + testThreshold = test.TestThreshold + testSetIdS256Schnorr = "S256" + testSetIdEdwards = "Edwards" ) func setUp(level string) { if err := log.SetLogLevel("tss-lib", level); err != nil { panic(err) } -} -func TestE2EConcurrent(t *testing.T) { - setUp("debug") + // only for test + tss.SetCurve(tss.Edwards()) +} - // tss.SetCurve(edwards.Edwards()) deprecated +func TestE2EConcurrentEdwards(t *testing.T) { + setUp("info") threshold := testThreshold // PHASE: load keygen fixtures - keys, signPIDs, err := keygen.LoadKeygenTestFixturesRandomSet(testThreshold+1, testParticipants) + keys, signPIDs, err := keygen.LoadKeygenTestFixturesRandomSet(testThreshold+1, testParticipants, testSetIdEdwards) assert.NoError(t, err, "should load keygen fixtures") assert.Equal(t, testThreshold+1, len(keys)) assert.Equal(t, testThreshold+1, len(signPIDs)) @@ -103,14 +108,14 @@ signing: R := parties[0].temp.r // BEGIN check s correctness - sumS := parties[0].temp.si + sumS := bigIntToEncodedBytes(&parties[0].temp.si) for i, p := range parties { if i == 0 { continue } var tmpSumS [32]byte - edwards25519.ScMulAdd(&tmpSumS, sumS, bigIntToEncodedBytes(big.NewInt(1)), p.temp.si) + edwards25519.ScMulAdd(&tmpSumS, sumS, bigIntToEncodedBytes(big.NewInt(1)), bigIntToEncodedBytes(&p.temp.si)) sumS = &tmpSumS } // END check s correctness @@ -118,7 +123,7 @@ signing: // BEGIN EDDSA verify pkX, pkY := keys[0].EDDSAPub.X(), keys[0].EDDSAPub.Y() pk := edwards.PublicKey{ - Curve: tss.EC(), + Curve: tss.Edwards(), X: pkX, Y: pkY, } @@ -147,3 +152,101 @@ signing: } } } + +func TestE2EConcurrentS256Schnorr(t *testing.T) { + setUp("info") + + threshold := testThreshold + + // PHASE: load keygen fixtures + + keys, signPIDs, err := keygen.LoadKeygenTestFixturesRandomSet(testThreshold+1, testParticipants, testSetIdS256Schnorr) + assert.NoError(t, err, "should load keygen fixtures") + assert.Equal(t, testThreshold+1, len(keys)) + assert.Equal(t, testThreshold+1, len(signPIDs)) + + // PHASE: signing + + p2pCtx := tss.NewPeerContext(signPIDs) + parties := make([]*LocalParty, 0, len(signPIDs)) + + errCh := make(chan *tss.Error, len(signPIDs)) + outCh := make(chan tss.Message, len(signPIDs)) + endCh := make(chan common.SignatureData, len(signPIDs)) + + updater := test.SharedPartyUpdater + + msg, _ := hex.DecodeString("304502210088BE0644191B935DB1CD786B43FF27798006578D8C908906B49E89") // big.NewInt(200).Bytes() + msgI := big.NewInt(0).SetBytes(msg) + + // init the parties + for i := 0; i < len(signPIDs); i++ { + params := tss.NewParameters(tss.S256(), p2pCtx, signPIDs[i], len(signPIDs), threshold) + + P := NewLocalParty(msgI, params, keys[i], outCh, endCh).(*LocalParty) + parties = append(parties, P) + go func(P *LocalParty) { + if err := P.Start(); err != nil { + errCh <- err + } + }(P) + } + + var ended int32 +signing: + for { + select { + case err := <-errCh: + common.Logger.Errorf("Error: %s", err) + assert.FailNow(t, err.Error()) + break signing + + case msg := <-outCh: + dest := msg.GetTo() + if dest == nil { + for _, P := range parties { + if P.PartyID().Index == msg.GetFrom().Index { + continue + } + go updater(P, msg, errCh) + } + } else { + if dest[0].Index == msg.GetFrom().Index { + t.Fatalf("party %d tried to send a message to itself (%d)", dest[0].Index, msg.GetFrom().Index) + } + go updater(parties[dest[0].Index], msg, errCh) + } + + case <-endCh: + atomic.AddInt32(&ended, 1) + if atomic.LoadInt32(&ended) == int32(len(signPIDs)) { + t.Logf("Done. Received save data from %d participants", ended) + R := parties[0].temp.r + + modN := common.ModInt(tss.S256().Params().N) + + // BEGIN check s correctness + sumS := big.NewInt(0) + for _, p := range parties { + sumS = modN.Add(sumS, &p.temp.si) + } + fmt.Printf("S: %s\n", common.FormatBigInt(sumS)) + fmt.Printf("R: %s\n", R.String()) + // END check s correctness + + // BEGIN EdDSA verify + + r := new(big.Int).SetBytes(parties[0].data.GetR()) + s := new(big.Int).SetBytes(parties[0].data.GetS()) + + if err2 := SchnorrVerify(keys[0].EDDSAPub.ToBtcecPubKey(), msg, r, s); !assert.NoError(t, err2, "EdDSA sig must verify") { + return + } + t.Log("EdDSA signing test done.") + // END EdDSA verify + + break signing + } + } + } +} diff --git a/eddsa/signing/round_1.go b/eddsa/signing/round_1.go index e176da5a..e6ea4339 100644 --- a/eddsa/signing/round_1.go +++ b/eddsa/signing/round_1.go @@ -9,7 +9,6 @@ package signing import ( "errors" "fmt" - "math/big" "github.com/binance-chain/tss-lib/common" "github.com/binance-chain/tss-lib/crypto" @@ -18,10 +17,6 @@ import ( "github.com/binance-chain/tss-lib/tss" ) -var ( - zero = big.NewInt(0) -) - // round 1 represents round 1 of the signing part of the EDDSA TSS spec func newRound1(params *tss.Parameters, key *keygen.LocalPartySaveData, data *common.SignatureData, temp *localTempData, out chan<- tss.Message, end chan<- common.SignatureData) tss.Round { return &round1{ diff --git a/eddsa/signing/round_3.go b/eddsa/signing/round_3.go index 42950c62..99977f6b 100644 --- a/eddsa/signing/round_3.go +++ b/eddsa/signing/round_3.go @@ -8,8 +8,13 @@ package signing import ( "crypto/sha512" + "math/big" + "strings" "github.com/agl/ed25519/edwards25519" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/decred/dcrd/dcrec/edwards/v2" "github.com/pkg/errors" "github.com/binance-chain/tss-lib/crypto" @@ -27,9 +32,18 @@ func (round *round3) Start() *tss.Error { round.resetOK() // 1. init R - var R edwards25519.ExtendedGroupElement - riBytes := bigIntToEncodedBytes(round.temp.ri) - edwards25519.GeScalarMultBase(&R, riBytes) + var Redwards edwards25519.ExtendedGroupElement + var Rsecp256k1 *crypto.ECPoint + + var riBytes *[32]byte + _, isTwistedEdwardsCurve := round.Params().EC().(*edwards.TwistedEdwardsCurve) + isSecp256k1Curve := strings.Compare("secp256k1", round.Params().EC().Params().Name) == 0 + if isTwistedEdwardsCurve { + riBytes = bigIntToEncodedBytes(round.temp.ri) + edwards25519.GeScalarMultBase(&Redwards, riBytes) + } else if isSecp256k1Curve { + Rsecp256k1 = crypto.ScalarBaseMult(round.Params().EC(), round.temp.ri) + } // 2-6. compute R i := round.PartyID().Index @@ -62,37 +76,85 @@ func (round *round3) Start() *tss.Error { return round.WrapError(errors.New("failed to prove Rj"), Pj) } - extendedRj := ecPointToExtendedElement(round.Params().EC(), Rj.X(), Rj.Y()) - R = addExtendedElements(R, extendedRj) + if isTwistedEdwardsCurve { + extendedRj := ecPointToExtendedElement(round.Params().EC(), Rj.X(), Rj.Y()) + Redwards = addExtendedElements(Redwards, extendedRj) + } else if isSecp256k1Curve { + Rsecp256k1, err = Rsecp256k1.Add(Rj) + if err != nil { + return round.WrapError(errors.Wrapf(err, "error with addition"), Pj) + } + } } - // 7. compute lambda var encodedR [32]byte - R.ToBytes(&encodedR) - encodedPubKey := ecPointToEncodedBytes(round.key.EDDSAPub.X(), round.key.EDDSAPub.Y()) + var encodedPubKey *[32]byte + + if isTwistedEdwardsCurve { + Redwards.ToBytes(&encodedR) + encodedPubKey = ecPointToEncodedBytes(round.key.EDDSAPub.X(), round.key.EDDSAPub.Y()) + } else if isSecp256k1Curve { + s := new([32]byte) + round.key.EDDSAPub.X().FillBytes(s[:]) + encodedPubKey = s + } + // 7. compute lambda // h = hash512(k || A || M) - h := sha512.New() - h.Reset() - h.Write(encodedR[:]) - h.Write(encodedPubKey[:]) - h.Write(round.temp.m.Bytes()) - var lambda [64]byte - h.Sum(lambda[:0]) + var 𝜆 *chainhash.Hash var lambdaReduced [32]byte - edwards25519.ScReduce(&lambdaReduced, &lambda) + if isTwistedEdwardsCurve { + h := sha512.New() + h.Reset() + h.Write(encodedR[:]) + h.Write(encodedPubKey[:]) + h.Write(round.temp.m.Bytes()) + h.Sum(lambda[:0]) + + edwards25519.ScReduce(&lambdaReduced, &lambda) + } else if isSecp256k1Curve { + // if R has an odd Y coordinate, we'll add to it until we find an R with even Y. + a := 0 + G := crypto.ScalarBaseMult(round.Params().EC(), big.NewInt(1)) + for ; OddY(Rsecp256k1); a++ { // Y cannot be odd in BIP340 + Rsecp256k1, _ = Rsecp256k1.Add(G) + } + round.temp.a = a + + // + encode32bytes(Rsecp256k1.X(), &encodedR) + 𝜆 = chainhash.TaggedHash( + []byte("BIP0340/challenge"), encodedR[:], encodedPubKey[:], round.temp.m.Bytes(), + ) // commitment + var e btcec.ModNScalar + if overflow := e.SetBytes((*[32]byte)(𝜆)); overflow != 0 { + str := "hash of (r || P || m) too big" + return round.WrapError(errors.New(str)) + } + } // 8. compute si var localS [32]byte - edwards25519.ScMulAdd(&localS, &lambdaReduced, bigIntToEncodedBytes(round.temp.wi), riBytes) + var si *big.Int + if isTwistedEdwardsCurve { + edwards25519.ScMulAdd(&localS, &lambdaReduced, bigIntToEncodedBytes(round.temp.wi), riBytes) + si = encodedBytesToBigInt(&localS) + } else if isSecp256k1Curve { + 𝜆wi := big.NewInt(0).Mul(big.NewInt(0).SetBytes(𝜆.CloneBytes()), round.temp.wi) + si = big.NewInt(0).Add(round.temp.ri, 𝜆wi) + } // 9. store r3 message pieces - round.temp.si = &localS - round.temp.r = encodedBytesToBigInt(&encodedR) + round.temp.si = *si + if isTwistedEdwardsCurve { + round.temp.r = encodedBytesToBigInt(&encodedR) + } else if isSecp256k1Curve { + round.temp.r = Rsecp256k1.X() + } // 10. broadcast si to other parties - r3msg := NewSignRound3Message(round.PartyID(), encodedBytesToBigInt(&localS)) + r3msg := NewSignRound3Message(round.PartyID(), si) round.temp.signRound3Messages[round.PartyID().Index] = r3msg round.out <- r3msg diff --git a/eddsa/signing/utils.go b/eddsa/signing/utils.go index 2cda9b6d..22c4fed6 100644 --- a/eddsa/signing/utils.go +++ b/eddsa/signing/utils.go @@ -8,11 +8,15 @@ package signing import ( "crypto/elliptic" + "fmt" "math/big" "github.com/agl/ed25519/edwards25519" - "github.com/binance-chain/tss-lib/common" + "github.com/binance-chain/tss-lib/crypto" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/btcsuite/btcd/chaincfg/chainhash" ) func encodedBytesToBigInt(s *[32]byte) *big.Int { @@ -80,7 +84,6 @@ func ecPointToEncodedBytes(x *big.Int, y *big.Int) *[32]byte { } else { s[31] &^= (1 << 7) } - return s } @@ -126,3 +129,135 @@ func ecPointToExtendedElement(ec elliptic.Curve, x *big.Int, y *big.Int) edwards T: T, } } + +func OddY(a *crypto.ECPoint) bool { + return a.Y().Bit(0) > 0 +} + +func SchnorrVerify(p *btcec.PublicKey, m []byte, r *big.Int, s *big.Int) error { + var R btcec.FieldVal + R.SetByteSlice(r.Bytes()) + var S btcec.ModNScalar + S.SetByteSlice(s.Bytes()) + return schnorrVerify(m, p, R, S) +} + +/////////////////////////// + +// signatureError creates an Error given a set of arguments. +func signatureError(kind schnorr.ErrorKind, desc string) schnorr.Error { + return schnorr.Error{Err: kind, Description: desc} +} + +// from https://github.com/Roasbeef/btcd/blob/5a59e7c0ddfb46d1bd7a99b87dbb8f7657a14382/btcec/schnorr/signature.go +// for whatever reason using this code directly yields some issues +func schnorrVerify(hash []byte, pubKey *btcec.PublicKey, r btcec.FieldVal, s btcec.ModNScalar) error { + // The algorithm for producing a BIP-340 signature is described in + // README.md and is reproduced here for reference: + // + // 1. Fail if m is not 32 bytes + // 2. P = lift_x(int(pk)). + // 3. r = int(sig[0:32]); fail is r >= p. + // 4. s = int(sig[32:64]); fail if s >= n. + // 5. e = int(tagged_hash("BIP0340/challenge", bytes(r) || bytes(P) || M)) mod n. + // 6. R = s*G - e*P + // 7. Fail if is_infinite(R) + // 8. Fail if not hash_even_y(R) + // 9. Fail is x(R) != r. + // 10. Return success iff not failure occured before reachign this + // point. + + // Step 1. + // + // Fail if m is not 32 bytes + if len(hash) != 32 { + str := fmt.Sprintf("wrong size for message (got %v, want %v)", len(hash), 32) + return signatureError("ErrInvalidHashLen", str) + } + + // Step 2. + // + // P = lift_x(int(pk)) + // + // Fail if P is not a point on the curve + if !pubKey.IsOnCurve() { + str := "pubkey point is not on curve" + return signatureError("ErrPubKeyNotOnCurve", str) + } + + // Step 3. + // + // Fail if r >= p + // + // Note this is already handled by the fact r is a field element. + + // Step 4. + // + // Fail if s >= n + // + // Note this is already handled by the fact s is a mod n scalar. + + // Step 5. + // + // e = int(tagged_hash("BIP0340/challenge", bytes(r) || bytes(P) || M)) mod n. + var rBytes [32]byte + r.PutBytesUnchecked(rBytes[:]) + pBytes := schnorr.SerializePubKey(pubKey) + + commitment := chainhash.TaggedHash( + []byte("BIP0340/challenge"), rBytes[:], pBytes, hash, + ) + + var e btcec.ModNScalar + if overflow := e.SetBytes((*[32]byte)(commitment)); overflow != 0 { + str := "hash of (r || P || m) too big" + return signatureError("ErrSchnorrHashValue", str) + } + + // Negate e here so we can use AddNonConst below to subtract the s*G + // point from e*P. + e.Negate() + + // Step 6. + // + // R = s*G - e*P + var P, R, sG, eP btcec.JacobianPoint + pubKey.AsJacobian(&P) + btcec.ScalarBaseMultNonConst(&s, &sG) + btcec.ScalarMultNonConst(&e, &P, &eP) + btcec.AddNonConst(&sG, &eP, &R) + + // Step 7. + // + // Fail if R is the point at infinity + if (R.X.IsZero() && R.Y.IsZero()) || R.Z.IsZero() { + str := "calculated R point is the point at infinity" + return signatureError("ErrSigRNotOnCurve", str) + } + + // Step 8. + // + // Fail if R.y is odd + // + // Note that R must be in affine coordinates for this check. + R.ToAffine() + if R.Y.IsOdd() { + str := "calculated R y-value is odd" + return signatureError("ErrSigRYIsOdd", str) + } + + // Step 9. + // + // Verified if R.x == r + // + // Note that R must be in affine coordinates for this check. + if !r.Equals(&R.X) { + str := "calculated R point was not given R" + return signatureError("ErrUnequalRValues", str) + } + + // Step 10. + // + // Return success iff not failure occured before reachign this + return nil +} diff --git a/go.mod b/go.mod index 37b4a854..ce43f7ca 100644 --- a/go.mod +++ b/go.mod @@ -1,33 +1,41 @@ module github.com/binance-chain/tss-lib -go 1.15 +go 1.17 require ( - github.com/Workiva/go-datastructures v1.0.52 - github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 - github.com/btcsuite/btcd v0.22.0-beta - github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce + github.com/agl/ed25519 v0.0.0-20200305024217-f36fc4b53d43 + github.com/btcsuite/btcd v0.22.0-beta.0.20220201204404-81fbd9b67e54 + github.com/btcsuite/btcd/btcec/v2 v2.1.0 + github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 - github.com/golang/protobuf v1.5.2 - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 github.com/ipfs/go-log v1.0.5 - github.com/ipfs/go-log/v2 v2.4.0 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect - github.com/olekukonko/tablewriter v0.0.4 github.com/otiai10/primes v0.0.0-20210501021515-f1b2be525a11 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 + golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 + google.golang.org/protobuf v1.27.1 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/ipfs/go-log/v2 v2.5.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect - go.uber.org/zap v1.19.1 // indirect - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect - golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827 // indirect - golang.org/x/text v0.3.6 - google.golang.org/protobuf v1.27.1 + go.uber.org/zap v1.21.0 // indirect + golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) -replace github.com/agl/ed25519 => github.com/binance-chain/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 +replace github.com/agl/ed25519 => github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 diff --git a/go.sum b/go.sum index 370b1699..7197dbde 100644 --- a/go.sum +++ b/go.sum @@ -1,41 +1,66 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= +github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 h1:oJHEIS4MpbHUZP2P+9+bATmf4KQSX/SGwxdVoJKhrEI= +github.com/SwingbyProtocol/edwards25519 v0.0.0-20200305024217-f36fc4b53d43/go.mod h1:l5lLTZ+iRubuGXG2bs2YcG4EkM2V2jqUOrjQlVDznuo= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/binance-chain/edwards25519 v0.0.0-20200305024217-f36fc4b53d43 h1:Vkf7rtHx8uHx8gDfkQaCdVfc+gfrF9v6sR6xJy7RXNg= -github.com/binance-chain/edwards25519 v0.0.0-20200305024217-f36fc4b53d43/go.mod h1:TnVqVdGEK8b6erOMkcyYGWzCQMw7HEMCOw3BgFYCFWs= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= -github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.22.0-beta.0.20220201204404-81fbd9b67e54 h1:khJx6kvXopB224O05cs6iwmX/zAh7RlkMf8MiPXVS1I= +github.com/btcsuite/btcd v0.22.0-beta.0.20220201204404-81fbd9b67e54/go.mod h1:vkwesBkYQtKXFYQYi9PyahtopbX53Tvk/O/qp2WI6Gk= +github.com/btcsuite/btcd/btcec/v2 v2.0.0/go.mod h1:vu+77Lro3alBlmsmlDnkZtgGiNo6OBwMHSb1XTGDwGo= +github.com/btcsuite/btcd/btcec/v2 v2.1.0 h1:Whmbo9yShKKG+WrUfYGFfgj77vYBiwhwBSJnM66TMKI= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= -github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd h1:vAwk2PCYxzUUGAXXtw66PyY2IMCwWBnm8GR5aLIxS3Q= +github.com/btcsuite/btcutil v1.0.3-0.20211129182920-9c4bbabe7acd/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 h1:bX7rtGTMBDJxujZ29GNqtn7YCAdINjHKnA6J6tBBv6s= github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2/go.mod h1:d0H8xGMWbiIQP7gN3v2rByWUcuZPm9YsgmnfoxgbINc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= @@ -48,8 +73,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= -github.com/ipfs/go-log/v2 v2.4.0 h1:iR/2o9PGWanVJrBgIH5Ff8mPGOwpqLaPIAFqSnsdlzk= -github.com/ipfs/go-log/v2 v2.4.0/go.mod h1:nPZnh7Cj7lwS3LpRU5Mwr2ol1c2gXIEXuF6aywqrtmo= +github.com/ipfs/go-log/v2 v2.5.0 h1:+MhAooFd9XZNvR0i9FriKW6HB0ql7HNXUuflWtc0dd4= +github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= @@ -63,20 +88,20 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= -github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/jsonindent v0.0.0-20171116142732-447bf004320b/go.mod h1:SXIpH2WO0dyF5YBc6Iq8jc8TEJYe1Fk2Rc1EVYUdIgY= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= @@ -105,41 +130,50 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.20.0 h1:N4oPlghZwYG55MlU6LXk/Zp00FVNE9X9wrYO8CEs4lc= +go.uber.org/zap v1.20.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE= +golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 h1:XdAboW3BNMv9ocSCOk/u1MFioZGzCNkiJZ19v9Oe3Ig= +golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -148,23 +182,34 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827 h1:A0Qkn7Z/n8zC1xd9LTw17AiKlBRK64tw3ejWQiEqca0= -golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a h1:ppl5mZgokTT8uPkmYOyEUmPTr3ypaKkg5eFOGrAmxxE= +golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -172,10 +217,8 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -185,10 +228,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -202,8 +249,10 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/protob/ecdsa-signature.proto b/protob/ecdsa-signature.proto.delete similarity index 96% rename from protob/ecdsa-signature.proto rename to protob/ecdsa-signature.proto.delete index 5168af83..996be745 100644 --- a/protob/ecdsa-signature.proto +++ b/protob/ecdsa-signature.proto.delete @@ -5,7 +5,7 @@ // file LICENSE at the root of the source code distribution tree. syntax = "proto3"; - +package binance.tsslib.ecdsa.signing; option go_package = "github.com/binance-chain/tss-lib/ecdsa/signing"; import "protob/shared.proto"; diff --git a/protob/eddsa-signature.proto b/protob/eddsa-signature.proto.delete similarity index 93% rename from protob/eddsa-signature.proto rename to protob/eddsa-signature.proto.delete index 72b86942..1c215f94 100644 --- a/protob/eddsa-signature.proto +++ b/protob/eddsa-signature.proto.delete @@ -5,7 +5,7 @@ // file LICENSE at the root of the source code distribution tree. syntax = "proto3"; - +package binance.tsslib.eddsa.signing; option go_package = "github.com/binance-chain/tss-lib/eddsa/signing"; import "protob/shared.proto"; diff --git a/test/_ecdsa_fixtures/.gitkeep b/test/_ecdsa_fixtures/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/_ecdsa_fixtures/keygen_data_0.json b/test/_ecdsa_fixtures/keygen_data_0.json deleted file mode 100644 index b13138ee..00000000 --- a/test/_ecdsa_fixtures/keygen_data_0.json +++ /dev/null @@ -1 +0,0 @@ -{"PaillierSK":{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,"LambdaN":12244288467800177208539238462052011342254030771702255472147276750713378968968988427210056388820686206446187952378228367546099600631781506020763858317986651600624291548394114829197589558645045453881635603485584954584530436544720030519555440817257002069277532889886614496034158223545688636096849110387402387024528223628617374593769999264811588741432087970537480855839974072192640846465127734783052189068506929754332767063036832027419385620331463446206002989826208646900752477151275584044483720203684345006160252628954713743333528434400168081723633869350346509775917996401044899580728991601465887658618084552090225088074,"PhiN":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049056447257234749187539998529623177482864175941074961711679948144385281692930255469566104378137013859508665534126073664054838771240662926892412005979652417293801504954302551168088967440407368690012320505257909427486667056868800336163447267738700693019551835992802089799161457983202931775317236169104180450176148},"NTildei":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,"H1i":22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,"H2i":4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,"Alpha":20134327893367906186848271747912040110633235155763756608962289665503800402443988610726562974659748340392676514491380028407112376655469504552238349712061211717272326970870137348022169591735942483477878239273386567217277531623360047075339813316023218409990359740980244373133523198267179187714619353413025748035317451421076915031289010895281684327410514275604062451792248129547636609921534494143068354633589312854471928693183148023467082056846965124395590232761913356768140701213970358727760835554935901732479642986466580178078914698960641458765669439291483820484660952058410890249589994714934783196689876305102317892128,"Beta":4769104749502215160103528276907405901039701274645558463841176399426766953251453276997585888336056667058003742560066962203889266160238261104780750185678792016783899685896820470597839801834700997782130686915660425482853175234790494909107857618155084349333754580989593384733739124609723930512465938052260992180099202081026797373928344195857383729859098895075217181612716914446473920221615683752726822588525504221927157806098347431696468687828158956040124186182719538835556368212535020393869358028833163489204691904642226112768693413875158920066595197595224501972965758170532687753505910207190061088883357744579014092752,"P":87263040677642185744670221243368593343731356313572068663794955417522100633736230381991931275537243144757969880827016784466391195604029198799418957687715105703397011312540469603691751275183038739578806835559866535463908060918431135351255483056546683157397967784222215986121160376647847984298442187783135789719,"Q":70157356268570340391167588566652484404699125816686111100335599384724972909645683598894591557109079629672842190893094895224516312192231658553266337679800264517057353212078639884592942505339090130936541285731509111487345601972797758934834667946183637561047841930220368831942721386784968033749455410522766959523,"Xi":16087305610084587677561099384215137857274146882580896345420805013663877079278,"ShareID":57484939971914870596598028213478494578965713220443315190897899253201796287887,"Ks":[57484939971914870596598028213478494578965713220443315190897899253201796287887,57484939971914870596598028213478494578965713220443315190897899253201796287888,57484939971914870596598028213478494578965713220443315190897899253201796287889,57484939971914870596598028213478494578965713220443315190897899253201796287890,57484939971914870596598028213478494578965713220443315190897899253201796287891],"NTildej":[24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489],"H1j":[22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163],"H2j":[4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884],"BigXj":[{"Curve":"secp256k1","Coords":[107835648724779949798808640837827953945816038786532991396734013925392112360222,111356957611616249622396087208812686735392078462911685737986672070502845300027]},{"Curve":"secp256k1","Coords":[101799429129399946712041928379464497916746083969766093060270737364302888604041,23666070898593487758158635604566044778188015356404389255931507506014455903839]},{"Curve":"secp256k1","Coords":[33621518412977179855230181863510046030105962945340821640863059880740258338589,56484044118560761934429329424058122069724129472112256667718154435273085775496]},{"Curve":"secp256k1","Coords":[38072094342526463674028902246753899069434959052326768776660942160541487619985,94706193766123352043331837317359268395870178692988172914401092257882385090624]},{"Curve":"secp256k1","Coords":[26472828124593202764717669281084254145728114975717896354180477989005181650525,14515424185278663327566869905852177050824670586129973820595918189269016785181]}],"PaillierPKs":[{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633},{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541},{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797},{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861},{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489}],"ECDSAPub":{"Curve":"secp256k1","Coords":[79493525990032375682542969979618533998789989364559036285904621150911797629480,36018009044469152286863753693366264314070719680968472490450927755593871021822]}} \ No newline at end of file diff --git a/test/_ecdsa_fixtures/keygen_data_1.json b/test/_ecdsa_fixtures/keygen_data_1.json deleted file mode 100644 index b4c9c8fe..00000000 --- a/test/_ecdsa_fixtures/keygen_data_1.json +++ /dev/null @@ -1 +0,0 @@ -{"PaillierSK":{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,"LambdaN":11699139673635926902889579884085398750869468248622554639934332936159818227678296638590376056695724318253204448870781090137923983744648608965723612493227692041744927684020638856349501451412592114313607598638079531623978349863497048861174830935412009828830501850614497542272227729077976237781377730690405572192889573239961768201617291815968334309618106950336812899588925712395686431438216748459597773786316876596561177634920114095897603060384325741921616105101343398098160356951617134353672649669696962813278624282061255921004103251571254000910588314893382298901603944384856841053510396866840212528030093373141861380486,"PhiN":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144385779146479923536403234583631936668619236213900673625799177851424791372862876433496919195547572633753193122355269840228191795206120768651483843232210202686796196320713903234268707345299339393925626557248564122511842008206503142508001821176629786764597803207888769713682107020793733680425056060186746283722760972},"NTildei":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,"H1i":243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,"H2i":21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,"Alpha":4673655074940613680289197904827423419737773677185517635437556483988766502167490864236487991558974438544556887373656742671939417323769864454508392577347952805931226146338163765464788150858722826831024173122264504875676251282167101479079213828580986575974110619893073436551863207276506215824667685069941093315230027945394560713056392061101480778848843752867052248509675213237205457352303010045645908090661429930919930135358344947856951261847845956435686050974151318318372033013312096495066544402770015696043905342231426171500848447458266781578082476376705355056625538459978278297560191097053578855596306846471602841101,"Beta":12801524292818443564892133351773256678641314143044588193329593217098426460207596819811072199922006310012210719685795990085744393066228361438475411612013834538009514722193812758077965563931726088123202795041550644374333580833243856761824587306357742639716124995075398386926379205726189760204236639774032476934313965678193463611415700936943564877998804308064402684837682601161144001201165388312680255232150509931980664241230922509859908953678383077498574764798006791565642170402066158041734158623469912092128973417528714787865366455094663456048763721891104619278446700629242645604353265832654767622700997979739188904,"P":69659493559662389686966171534557556111304365561039371584056683350552475298788220522685051347676628378337665007798636581868972242815275782968366029883515523021117196309659828357408949750617050465363295601684811785260481845180357609670940811817025913548256427310825230964895875036997655554953834768660828380053,"Q":83973763487210656373631203970443214248028099985809339909881648341264752642168124656731238843352234599190251196671690586691187184112930154347731746092584696579580223828810060013044911582205618143450673787371033617115488920494720030781060480426859662191660199549688621543358112451121014485454030558301933866231,"Xi":7440248876316700627456490931034065615692046009714080105785406552022482731206,"ShareID":57484939971914870596598028213478494578965713220443315190897899253201796287888,"Ks":[57484939971914870596598028213478494578965713220443315190897899253201796287887,57484939971914870596598028213478494578965713220443315190897899253201796287888,57484939971914870596598028213478494578965713220443315190897899253201796287889,57484939971914870596598028213478494578965713220443315190897899253201796287890,57484939971914870596598028213478494578965713220443315190897899253201796287891],"NTildej":[24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489],"H1j":[22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163],"H2j":[4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884],"BigXj":[{"Curve":"secp256k1","Coords":[107835648724779949798808640837827953945816038786532991396734013925392112360222,111356957611616249622396087208812686735392078462911685737986672070502845300027]},{"Curve":"secp256k1","Coords":[101799429129399946712041928379464497916746083969766093060270737364302888604041,23666070898593487758158635604566044778188015356404389255931507506014455903839]},{"Curve":"secp256k1","Coords":[33621518412977179855230181863510046030105962945340821640863059880740258338589,56484044118560761934429329424058122069724129472112256667718154435273085775496]},{"Curve":"secp256k1","Coords":[38072094342526463674028902246753899069434959052326768776660942160541487619985,94706193766123352043331837317359268395870178692988172914401092257882385090624]},{"Curve":"secp256k1","Coords":[26472828124593202764717669281084254145728114975717896354180477989005181650525,14515424185278663327566869905852177050824670586129973820595918189269016785181]}],"PaillierPKs":[{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633},{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541},{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797},{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861},{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489}],"ECDSAPub":{"Curve":"secp256k1","Coords":[79493525990032375682542969979618533998789989364559036285904621150911797629480,36018009044469152286863753693366264314070719680968472490450927755593871021822]}} \ No newline at end of file diff --git a/test/_ecdsa_fixtures/keygen_data_2.json b/test/_ecdsa_fixtures/keygen_data_2.json deleted file mode 100644 index d86c73c1..00000000 --- a/test/_ecdsa_fixtures/keygen_data_2.json +++ /dev/null @@ -1 +0,0 @@ -{"PaillierSK":{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,"LambdaN":13280900778994969406681544535442281997449261211362954616688789961142825039240001392144050284758013002936434138024123280648820804746016631210608906329806167486447076382048468707489094262054629796689939533442547077488623133427702090344898544063467776169502777327274511759225687485050179821576268147892730240041830425149589888268175095251032154486638096289903611474182804306508891328224873976115344291452104360279658912251686425083597765024711908267161169522661542775763586619543856513579861734343277267566343817631518298311718045791524379454686704864634016970918862486260840515949256666037686478357726837318220517066798,"PhiN":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083660850299179776536350190502064308973276192579807222948365608613017782656449747952230688582904208720559317824503372850167195530049423816534322339045323085551527173239087713027159723468686554535132687635263036596623436091583048758909373409729268033941837724972521681031898513332075372956715453674636441034133596},"NTildei":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,"H1i":18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,"H2i":3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,"Alpha":6359038170843016267272670298900517981275890434029877435839834298582631906330852305325647919065729927083059945242941171108063381884878596981325705925901540290448222518799193159686611402977408092854543719782550019930413992793802137589259047658962103732382313219179545939349713542872395592880464242651499206792364115392724922087540541021682479030855893580754352626642835422264016779068401511093984830329635382991630195558407726706321670136828582571470575791945498301484180458903162568362774948612290668513330346242243391702809053425156690135128054218747449140958752862188321966323573086082091153188034013351311382303486,"Beta":6118176388772590759390838795288441615774284768514772010300333424431003051651667356238328699555667601307630023760587599919253921815981409011415816401967002786008153650788027042435672965082772047594584145012262321401410204465017539003987913382203233856521096437454194698674087847075656190996095012686553898592102217698033192359107171044773433235219206875395661380766572713026199074037485067850136148963044037200493500791840671685019205262300404053729724537979876139310953082758851736962975545188156755791534474940696012045362551405967999973585073958170290585093217477249260550232888096354189290974640913112743210588762,"P":75732768670668108405624252453165596348703484192308065971566237629360060064447957954477894285013069062898285487530025489794550318431372718327550373520424446307212947852811329866617962836291723234414130004996765607894724632803358842156541781925390003562795930893180894110384176653704539589034245756166427443249,"Q":87682657138473043799246182563658831111329013484239094734018089650321671606567116098210276990890167779320071531950899231835194605053247506351626777544825896604053226514237473972478384621624717130833348208672793978667600013725403660784067837759393039030830306593807903209354875473094154040494666186290669297351,"Xi":64917705738580334038727029061507814489989668801134921781559417532335564723781,"ShareID":57484939971914870596598028213478494578965713220443315190897899253201796287889,"Ks":[57484939971914870596598028213478494578965713220443315190897899253201796287887,57484939971914870596598028213478494578965713220443315190897899253201796287888,57484939971914870596598028213478494578965713220443315190897899253201796287889,57484939971914870596598028213478494578965713220443315190897899253201796287890,57484939971914870596598028213478494578965713220443315190897899253201796287891],"NTildej":[24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489],"H1j":[22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163],"H2j":[4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884],"BigXj":[{"Curve":"secp256k1","Coords":[107835648724779949798808640837827953945816038786532991396734013925392112360222,111356957611616249622396087208812686735392078462911685737986672070502845300027]},{"Curve":"secp256k1","Coords":[101799429129399946712041928379464497916746083969766093060270737364302888604041,23666070898593487758158635604566044778188015356404389255931507506014455903839]},{"Curve":"secp256k1","Coords":[33621518412977179855230181863510046030105962945340821640863059880740258338589,56484044118560761934429329424058122069724129472112256667718154435273085775496]},{"Curve":"secp256k1","Coords":[38072094342526463674028902246753899069434959052326768776660942160541487619985,94706193766123352043331837317359268395870178692988172914401092257882385090624]},{"Curve":"secp256k1","Coords":[26472828124593202764717669281084254145728114975717896354180477989005181650525,14515424185278663327566869905852177050824670586129973820595918189269016785181]}],"PaillierPKs":[{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633},{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541},{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797},{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861},{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489}],"ECDSAPub":{"Curve":"secp256k1","Coords":[79493525990032375682542969979618533998789989364559036285904621150911797629480,36018009044469152286863753693366264314070719680968472490450927755593871021822]}} \ No newline at end of file diff --git a/test/_ecdsa_fixtures/keygen_data_3.json b/test/_ecdsa_fixtures/keygen_data_3.json deleted file mode 100644 index aa052a52..00000000 --- a/test/_ecdsa_fixtures/keygen_data_3.json +++ /dev/null @@ -1 +0,0 @@ -{"PaillierSK":{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,"LambdaN":10396634245109342387256346800676139222514161344721601040532456775308701333151684773004659495054988275845445558348923310556618130164707824849363341674077214655262976434354033840087303825565618907194631324834224352219732523702093004077376960506675034278486281695295026364491584017231722187974175395230348032800773156172640978543691208001624290793045373744682425011687632359151347894409051401720265005342811152921465965666980398067031765284775912633010848503432459826093486837510311487351649662726043317917753941752152225675808553321802462270932481545525914906412749354373014764035557170191019066879773786043672882619462,"PhiN":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601546312345281957087382416003248581586090747489364850023375264718302695788818102803440530010685622305842931931333960796134063530569551825266021697006864919652186973675020622974703299325452086635835507883504304451351617106643604924541864963091051829812825498708746029528071114340382038133759547572087345765238924},"NTildei":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,"H1i":3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,"H2i":4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,"Alpha":3174277577609098411382832939130001125695873431249341546715896952024830773447154457654849405811708263304784520675512157005461866400869912508872515961071967228827313288382700222351386327674026913573574187419155166099409970009611810510832014376496891429078090602758605828177741616777652244270010873801677951181442053506384221339724623330459669274498439649678674546464092039501575830131866194971202812462185994529471407186329529835104957197524461361735436414735649587868328477772264850910184837595548563312422310365457245057849850511461348439914435721731486603869924771624437029844557189476270458426917400405903041195272,"Beta":4083885739404704324307653490227793326481330180756644151904305695515656717433472849974985801383356623603679458726280411418245060708694310533383452092706144501998709986610805811008220789426852264902432865453050379418874291981918200974194899438110649470264987294873167352110492106489514073391330661456273107511644456587899614191066007379024655242635159830630125908411841491099744835889397970222260507975410094662842401940217852972451775090936482990687496697343189301789925607198512586442037224862090913244244310059932864979286458346720685806980174000031678665774811293621249078062386067645178119999408563471177351132816,"P":73724539956035188951643923371096202909846769701628135656723292322387108309309131322820457605897555848614277642033372230427964146356841288301499404911328565284569272225247129975513151910287392925538600320207010822094476047260912889776142956587834744464973280805747717207920989471451384915336225555487497470129,"Q":70509997426292926446136051589185542064639407755934064435093446955599168571518039691448436734834533853091954003033900518514040226721802430612748288594695723940599284788683324095440390966510201242432569673425677355973462368879614406025509088970147533083259945830900180517756241755060509487012728387562048984339,"Xi":72727586959559292487801728766948476627329450977768516990137674813084961562666,"ShareID":57484939971914870596598028213478494578965713220443315190897899253201796287890,"Ks":[57484939971914870596598028213478494578965713220443315190897899253201796287887,57484939971914870596598028213478494578965713220443315190897899253201796287888,57484939971914870596598028213478494578965713220443315190897899253201796287889,57484939971914870596598028213478494578965713220443315190897899253201796287890,57484939971914870596598028213478494578965713220443315190897899253201796287891],"NTildej":[24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489],"H1j":[22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163],"H2j":[4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884],"BigXj":[{"Curve":"secp256k1","Coords":[107835648724779949798808640837827953945816038786532991396734013925392112360222,111356957611616249622396087208812686735392078462911685737986672070502845300027]},{"Curve":"secp256k1","Coords":[101799429129399946712041928379464497916746083969766093060270737364302888604041,23666070898593487758158635604566044778188015356404389255931507506014455903839]},{"Curve":"secp256k1","Coords":[33621518412977179855230181863510046030105962945340821640863059880740258338589,56484044118560761934429329424058122069724129472112256667718154435273085775496]},{"Curve":"secp256k1","Coords":[38072094342526463674028902246753899069434959052326768776660942160541487619985,94706193766123352043331837317359268395870178692988172914401092257882385090624]},{"Curve":"secp256k1","Coords":[26472828124593202764717669281084254145728114975717896354180477989005181650525,14515424185278663327566869905852177050824670586129973820595918189269016785181]}],"PaillierPKs":[{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633},{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541},{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797},{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861},{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489}],"ECDSAPub":{"Curve":"secp256k1","Coords":[79493525990032375682542969979618533998789989364559036285904621150911797629480,36018009044469152286863753693366264314070719680968472490450927755593871021822]}} \ No newline at end of file diff --git a/test/_ecdsa_fixtures/keygen_data_4.json b/test/_ecdsa_fixtures/keygen_data_4.json deleted file mode 100644 index 2ecf667c..00000000 --- a/test/_ecdsa_fixtures/keygen_data_4.json +++ /dev/null @@ -1 +0,0 @@ -{"PaillierSK":{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489,"LambdaN":13719439580862569660610038270197643594148250239620257975246627970382445701714045403777178190999860327048359159100221665219210037153719439831269585330001059176058825858023318745794896610349675773908701559962023899655128969747466945116739656255886089236240101065165376359834306859518237466988769502567382569212028586612736179719707186756311412158452406339894712668087584252706861079590690206597467882674711850384626913422041140620323816641867809459030198599525915578374510189633908762403473316177499490242387693125094186241311506514336571607995303769250161021190538138328091761274449116573301461734336202584258309065962,"PhiN":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424057173225472359439414373512622824316904812679789425336175168505413722159181380413194935765349423700769253826844082281240647633283735618918060397199051831156749020379267817524806946632354998980484775386250188372482623013028673143215990607538500322042381076276656183522548898233146602923468672405168516618131924},"NTildei":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489,"H1i":12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163,"H2i":10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884,"Alpha":20085346912084533807594495712273675854997165103045042610094623667676008869674288270698717163302447358661325941442316690977011451450450075528645671412964368819578702753724900108831167389602954082839705628887052828769263400580126437287260153768900805421221861449128267254858509165306865288012087727593118414189371146013169179700362897447155231707279720670801295709224224403307402168195546324614397293059917881088258218419030553858218517002321085755502157779840173086060283347358341497980594604714390533368570781801607282479468659499609952309181815079279845606214905022200410576114500098700387027572641084262408498404128,"Beta":3295112256488003037031454540995334202894730765438353962213305103650495122135218568459731891426646410961627275381097462514502881527264288789351828660675105959651099237728046019773486316232113598753668993864943191079931421936218807963121691506063525227442838816209875179846938360044577611393926855439774464828650534374476012814281415862752821884681894105057152482166634471045907012473348471820383454074521614047150869518670453326248392409046061874783569091789518871648083507447567980354594483022746680413860302095992741739564327692375276914191472283795400075600880615885833262286258345357653402244100970356941335195753,"P":78958733889611813074890847641433295327265853641746665887222903242297355169433897153012296341037905508824904943589242701761200123234885836718808046499764824537238101194955255110927660051895644147918976871628396372671181070348839146106685293578946741314954445291325898230061528569510549567673776969603283878071,"Q":86877276933309365319404018971649525911515254534944223944044586155694456518848824925951306938697890947305710491390796869871375264663215154524700420907289345448330044857660817684826933436120190632481090783371559125634356468908560436340812424788059833007982826823651708140763688110320334593144657419004332060211,"Xi":30869892539253575974680590047356052027711392539614865731520178394270673247861,"ShareID":57484939971914870596598028213478494578965713220443315190897899253201796287891,"Ks":[57484939971914870596598028213478494578965713220443315190897899253201796287887,57484939971914870596598028213478494578965713220443315190897899253201796287888,57484939971914870596598028213478494578965713220443315190897899253201796287889,57484939971914870596598028213478494578965713220443315190897899253201796287890,57484939971914870596598028213478494578965713220443315190897899253201796287891],"NTildej":[24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633,23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541,26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797,20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861,27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489],"H1j":[22231450562334471973618961742797616763434877603759536990055429171943655580664439279419958610772888014456353798981020361149135639525217821205425121486845662180390893935912842304490739461795526425936110185882557879383453966537438512163687673804582033522868345148763295767567221643994073486758870040420796087598143821022690141049410630612722219545247476715172769522813550748788268380178598324837703471829676064678228829702767153912677237945521290063086959482869616602461506402904230610340087208669128408849755792873299578530538374647998629096468609296430016568706541070523464581186829665248448703993586477544553956034821,243564909304646187826183888297681169720877985015680269905983587714837096845390274012688472193406961678810875572537040473860157456926888979142985458669283794727393513439677026887752875758121486989558765604530238677274335131006816351104449995127915498200667761930946464604512161169974158365984447829972674720289063485244230614033492725856247882775589351836570149368319732677864210781190313457540915101720950915966638194939967976938527849567733018974247540951843584867318260634080191424253740128944404737384952924071557119336733983982474112706274716188090946825451340811018400408030512011856140888590383225075124298818,18289002154283623311976266698431211498293734784963868427394245636767119021572249187048386604056252337381471327681265497325630945571777201104688073443965462590425611949197022064581120380987118857747827311731386272136444254806283427519187025413729275683680827267179424974147706698036663953657222392436057744578237859837487234202441250423837052403698219490017791306859855036403233739503134816788149299872176635574289715300073763346350018904256627259358139111177721613066257195741789726100240844475561781279728184036625367665746351018458939770769998766661245582115890818346211382937397604593813004153808612966185967427589,3608707151290460120200313410110317938146529777445481958869507370584267620919874484498244059048971126154641633379388869358167189533743653131477952093156726329245547726549260047498848971213721020937708746935830987729499111818281464816773948822560383145213156864544997896853240503134201367807396994374797160786219742083391049914579858286609731831548186420615207770200989603116469207097383368660658672246192732776358994961035507100437260197407890754435552914690505390593714278050100573867221837896240388297823476836158838968128580054882100677023446344292677326241593066945113747271107113730288470944437688095858200689177,12049772947335122078839454143136842763336714101294350398638263569288276853287186329465277851416773957299235990197580844230822666028936140143158506598954385615569304988062231966466995517907818981933532581402108322189469049381687034219914611020056307456777330494879335754282280016952296774821827594641493838211623624403007367892758601757526070117498103294189971647340450961879076110345922273827329860215671698078617127492413410616612764048779260754599752021616091100432084751555947767285558977881966000809888374655420457219878303172776117557068286461912967518896658743903722358978614824894388859733298934112534154960163],"H2j":[4903195124758783101014195122857885149885108217839819693509468695262427930011900534897220638698974555118369032111074317283371179147198752666772379003701090668715880719755862118611910504517411877325663327382275081719175405355478217593357959082658416334550793581368702940807510050067324477863771083298562291247389195817645177719295423270237472084819695982459001922219915224058741833179773113086123062556841877168128535203020515515884172395470425653836651420491478078521498470502057565813752803261046047438368132133582558379717160016464058601966595485808534122429942536044824404974630356183526949241716476300904453899070,21084886300862505519216367534751919606519594534830658834308002106197683557152978825903624943032297892958317007940831859981871637978913521722088866608196806790988827738157631713857585789132787909569397782677707811662378654174894297343707243607674741204960879391529329411571838044744539466606197565827388072300955320748584869517526540741833860373507412808882961431994962818777141128939901328026075426821040060992072921151932259146227574651731243971634621833545502778720935214861538852574332847645265501451223714089304220802411255269458501696223193092894948851858176596731579177703217340349071048197445150144891298785644,3007783261672980154491744327172997063138589503217753237687559765359177705434774684467861158985361752197735046298475212393949782937608233697218483261367228341578817363129536706256568426815050879419779726563535194250271016345451700683851334863679243336379812576029824122529475518166131290103671591777002124370053711823786959648713805164891735589917136333353705894381517072851044807507028794822247821394176071409967951453887359512551495667063699315624550623628593537905180159275720797402283341621516945427935141443129218113056015993442971497566471595042915046681883002609204821645644938881151616286926712871468864117845,4016822118839092488553776325766595497662837615157606725450869716413592115974012200295269098332482594080853193926753081402606478539310846527374791196257921121362982097689906959098763225966615088837914518556140124054135024117351548727208441888363811484027672142011153118521261756963060549756747016003518897078218669473635373512171106475319991327017205242968685946699808300618760086895295680043693147169773060090561526469192834375280298856575716124508724793645162361229895678890566826340776698163109353537588108903562084797768648888247062565564603088847683798696451886449802810475519018585474518314627077924533059654802,10535138036525962541398812617306958727306013457601320581308737461309299906691317691515916590339505543285315839851378590807111761017323948751485295437227423782051947820658990148190496027422064397590104159315550564612075136524850927319989040698989405812675023978970954916175315018516257846773336511822776043355914179231618369121019891776969392225087688323016859389297066526616464508598591140509516613394191708390957155686309476748859459390338867679846538888803696297674236171398143515079259057215530519688470207018485879274779380503038253404816439176548437604833126690433454291280029508847048812295847509711050229626884],"BigXj":[{"Curve":"secp256k1","Coords":[107835648724779949798808640837827953945816038786532991396734013925392112360222,111356957611616249622396087208812686735392078462911685737986672070502845300027]},{"Curve":"secp256k1","Coords":[101799429129399946712041928379464497916746083969766093060270737364302888604041,23666070898593487758158635604566044778188015356404389255931507506014455903839]},{"Curve":"secp256k1","Coords":[33621518412977179855230181863510046030105962945340821640863059880740258338589,56484044118560761934429329424058122069724129472112256667718154435273085775496]},{"Curve":"secp256k1","Coords":[38072094342526463674028902246753899069434959052326768776660942160541487619985,94706193766123352043331837317359268395870178692988172914401092257882385090624]},{"Curve":"secp256k1","Coords":[26472828124593202764717669281084254145728114975717896354180477989005181650525,14515424185278663327566869905852177050824670586129973820595918189269016785181]}],"PaillierPKs":[{"N":24488576935600354417078476924104022684508061543404510944294553501426757937937976854420112777641372412892375904756456735092199201263563012041527716635973303201248583096788229658395179117290090907763271206971169909169060873089440061039110881634514004138555065779773228992068316447091377272193698220774804774049371288051127174239811674149243219638361036905335478071208209253989775840017019297527877423802306505057527158269513887414220586256255448607117376570387448034242413683351789387065536827968412947753351201500492178780569564194582793952019448040706153660988727612230974968797585746729797407353331964300792255674633},{"N":23398279347271853805779159768170797501738936497245109279868665872319636455356593277180752113391448636506408897741562180275847967489297217931447224986455384083489855368041277712699002902825184228627215197276159063247956699726994097722349661870824019657661003701228995084544455458155952475562755461380811144386086412994017282495355778382946670159954878831767323222165728088175007318758346187278028127954691479148178187678780882528915524974625063358475427762154887235397715554180174045448253022005039262844185187342234202646760148034492663282725179214274535749283041142490741387123528768709917765136875917400209247253541},{"N":26561801557989938813363089070884563994898522422725909233377579922285650078480002784288100569516026005872868276048246561297641609492033262421217812659612334972894152764096937414978188524109259593379879066885094154977246266855404180689797088126935552339005554654549023518451374970100359643152536295785460480083987681150798058840759931372097957828196257575160317269776777267577146119791778100336064925456015194243754538542334699610455019896393056983680693347453586237349705587821810634837916163602387415863182591690375715796560740876106283915254628968637600027024977447495658626537991436328970343974511498521355227614797},{"N":20793268490218684774512693601352278445028322689443202081064913550617402666303369546009318990109976551690891116697846621113236260329415649698726683348154429310525952868708067680174607651131237814389262649668448704439465047404186008154753921013350068556972563390590052728983168034463444375948350790460696065601834781420046613318177975953169145076039719844279974423558898196858668342579757145469067799367086485246344394624095341631947539315709112703850192393876968230637310789048483882845206411205681824171450223491569827707752983475885979133468267182167794367921965162019325323522468802835061922564245479973444858147861},{"N":27438879161725139321220076540395287188296500479240515950493255940764891403428090807554356381999720654096718318200443330438420074307438879662539170660002118352117651716046637491589793220699351547817403119924047799310257939494933890233479312511772178472480202130330752719668613719036474933977539005134765138424388845247118201796202963245848989959382374896142807115837703484209705782557945857352862971908895293681515057714042360383912784059531820900547414133865939496720156671373049670398455819331030650045575521560188283479234088107187942380885602975234335191026950820886138735290548666506264691790309273945731850008489}],"ECDSAPub":{"Curve":"secp256k1","Coords":[79493525990032375682542969979618533998789989364559036285904621150911797629480,36018009044469152286863753693366264314070719680968472490450927755593871021822]}} \ No newline at end of file diff --git a/test/_eddsa_fixtures/.gitkeep b/test/_eddsa_fixtures/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/_eddsa_fixtures/keygen_data_0.json b/test/_eddsa_fixtures/keygen_data_0.json deleted file mode 100644 index 78edff9e..00000000 --- a/test/_eddsa_fixtures/keygen_data_0.json +++ /dev/null @@ -1 +0,0 @@ -{"Xi":4035558533062709819999066175720808528201062157116959842237332813932238616128,"ShareID":4331412928177670560630249357713645140224222675389722735738732090810250798211,"Ks":[4331412928177670560630249357713645140224222675389722735738732090810250798211,4331412928177670560630249357713645140224222675389722735738732090810250798212,4331412928177670560630249357713645140224222675389722735738732090810250798213,4331412928177670560630249357713645140224222675389722735738732090810250798214,4331412928177670560630249357713645140224222675389722735738732090810250798215],"BigXj":[{"Curve":"ed25519","Coords":[43310099667191579169521946934030711066313578772454024333166342656953690707905,38262908547499520970138465680473622143445318034940413117238454107324155485797]},{"Curve":"ed25519","Coords":[24927223220985169141357864268825305163035760221331262595481037667448513230521,54543586647335403608940330836676147882229516532084699385623699026578670835490]},{"Curve":"ed25519","Coords":[19616187786153771277930658236501515378058310865337414616528052406614836915381,5716086794073894084115757926314451153376043864681595081544933294419482836932]},{"Curve":"ed25519","Coords":[54894815670576274903749323651006626882715390257891571131934873815604647096151,6261975146537300228952779313756496780554610579250869076285924817563901726620]},{"Curve":"ed25519","Coords":[56199043572031726140854435832515077152685912346629787788574432437354212337803,20932642671481609624660147804972444129208387391842241879798619789962570609578]}],"EDDSAPub":{"Curve":"ed25519","Coords":[19086049614490163056889859244855881816030591019773605655349500169700108043042,41654918635428963527745188055885714592211199796738262868910566706065491471139]}} \ No newline at end of file diff --git a/test/_eddsa_fixtures/keygen_data_1.json b/test/_eddsa_fixtures/keygen_data_1.json deleted file mode 100644 index c8f4f027..00000000 --- a/test/_eddsa_fixtures/keygen_data_1.json +++ /dev/null @@ -1 +0,0 @@ -{"Xi":3043586451770172198202994337291909300581990387576065449561143874105554349662,"ShareID":4331412928177670560630249357713645140224222675389722735738732090810250798212,"Ks":[4331412928177670560630249357713645140224222675389722735738732090810250798211,4331412928177670560630249357713645140224222675389722735738732090810250798212,4331412928177670560630249357713645140224222675389722735738732090810250798213,4331412928177670560630249357713645140224222675389722735738732090810250798214,4331412928177670560630249357713645140224222675389722735738732090810250798215],"BigXj":[{"Curve":"ed25519","Coords":[43310099667191579169521946934030711066313578772454024333166342656953690707905,38262908547499520970138465680473622143445318034940413117238454107324155485797]},{"Curve":"ed25519","Coords":[24927223220985169141357864268825305163035760221331262595481037667448513230521,54543586647335403608940330836676147882229516532084699385623699026578670835490]},{"Curve":"ed25519","Coords":[19616187786153771277930658236501515378058310865337414616528052406614836915381,5716086794073894084115757926314451153376043864681595081544933294419482836932]},{"Curve":"ed25519","Coords":[54894815670576274903749323651006626882715390257891571131934873815604647096151,6261975146537300228952779313756496780554610579250869076285924817563901726620]},{"Curve":"ed25519","Coords":[56199043572031726140854435832515077152685912346629787788574432437354212337803,20932642671481609624660147804972444129208387391842241879798619789962570609578]}],"EDDSAPub":{"Curve":"ed25519","Coords":[19086049614490163056889859244855881816030591019773605655349500169700108043042,41654918635428963527745188055885714592211199796738262868910566706065491471139]}} \ No newline at end of file diff --git a/test/_eddsa_fixtures/keygen_data_2.json b/test/_eddsa_fixtures/keygen_data_2.json deleted file mode 100644 index 30a7bbda..00000000 --- a/test/_eddsa_fixtures/keygen_data_2.json +++ /dev/null @@ -1 +0,0 @@ -{"Xi":3816246280213061394677789505107161438228093145050056017416883247327953924913,"ShareID":4331412928177670560630249357713645140224222675389722735738732090810250798213,"Ks":[4331412928177670560630249357713645140224222675389722735738732090810250798211,4331412928177670560630249357713645140224222675389722735738732090810250798212,4331412928177670560630249357713645140224222675389722735738732090810250798213,4331412928177670560630249357713645140224222675389722735738732090810250798214,4331412928177670560630249357713645140224222675389722735738732090810250798215],"BigXj":[{"Curve":"ed25519","Coords":[43310099667191579169521946934030711066313578772454024333166342656953690707905,38262908547499520970138465680473622143445318034940413117238454107324155485797]},{"Curve":"ed25519","Coords":[24927223220985169141357864268825305163035760221331262595481037667448513230521,54543586647335403608940330836676147882229516532084699385623699026578670835490]},{"Curve":"ed25519","Coords":[19616187786153771277930658236501515378058310865337414616528052406614836915381,5716086794073894084115757926314451153376043864681595081544933294419482836932]},{"Curve":"ed25519","Coords":[54894815670576274903749323651006626882715390257891571131934873815604647096151,6261975146537300228952779313756496780554610579250869076285924817563901726620]},{"Curve":"ed25519","Coords":[56199043572031726140854435832515077152685912346629787788574432437354212337803,20932642671481609624660147804972444129208387391842241879798619789962570609578]}],"EDDSAPub":{"Curve":"ed25519","Coords":[19086049614490163056889859244855881816030591019773605655349500169700108043042,41654918635428963527745188055885714592211199796738262868910566706065491471139]}} \ No newline at end of file diff --git a/test/_eddsa_fixtures/keygen_data_3.json b/test/_eddsa_fixtures/keygen_data_3.json deleted file mode 100644 index d2b69df9..00000000 --- a/test/_eddsa_fixtures/keygen_data_3.json +++ /dev/null @@ -1 +0,0 @@ -{"Xi":6353538018391377409423451679166564941139370429538931545804550933599437341881,"ShareID":4331412928177670560630249357713645140224222675389722735738732090810250798214,"Ks":[4331412928177670560630249357713645140224222675389722735738732090810250798211,4331412928177670560630249357713645140224222675389722735738732090810250798212,4331412928177670560630249357713645140224222675389722735738732090810250798213,4331412928177670560630249357713645140224222675389722735738732090810250798214,4331412928177670560630249357713645140224222675389722735738732090810250798215],"BigXj":[{"Curve":"ed25519","Coords":[43310099667191579169521946934030711066313578772454024333166342656953690707905,38262908547499520970138465680473622143445318034940413117238454107324155485797]},{"Curve":"ed25519","Coords":[24927223220985169141357864268825305163035760221331262595481037667448513230521,54543586647335403608940330836676147882229516532084699385623699026578670835490]},{"Curve":"ed25519","Coords":[19616187786153771277930658236501515378058310865337414616528052406614836915381,5716086794073894084115757926314451153376043864681595081544933294419482836932]},{"Curve":"ed25519","Coords":[54894815670576274903749323651006626882715390257891571131934873815604647096151,6261975146537300228952779313756496780554610579250869076285924817563901726620]},{"Curve":"ed25519","Coords":[56199043572031726140854435832515077152685912346629787788574432437354212337803,20932642671481609624660147804972444129208387391842241879798619789962570609578]}],"EDDSAPub":{"Curve":"ed25519","Coords":[19086049614490163056889859244855881816030591019773605655349500169700108043042,41654918635428963527745188055885714592211199796738262868910566706065491471139]}} \ No newline at end of file diff --git a/test/_eddsa_fixtures/keygen_data_4.json b/test/_eddsa_fixtures/keygen_data_4.json deleted file mode 100644 index eec4b008..00000000 --- a/test/_eddsa_fixtures/keygen_data_4.json +++ /dev/null @@ -1 +0,0 @@ -{"Xi":3418456088972858028466794296427125568458705881662784428722195994634550349577,"ShareID":4331412928177670560630249357713645140224222675389722735738732090810250798215,"Ks":[4331412928177670560630249357713645140224222675389722735738732090810250798211,4331412928177670560630249357713645140224222675389722735738732090810250798212,4331412928177670560630249357713645140224222675389722735738732090810250798213,4331412928177670560630249357713645140224222675389722735738732090810250798214,4331412928177670560630249357713645140224222675389722735738732090810250798215],"BigXj":[{"Curve":"ed25519","Coords":[43310099667191579169521946934030711066313578772454024333166342656953690707905,38262908547499520970138465680473622143445318034940413117238454107324155485797]},{"Curve":"ed25519","Coords":[24927223220985169141357864268825305163035760221331262595481037667448513230521,54543586647335403608940330836676147882229516532084699385623699026578670835490]},{"Curve":"ed25519","Coords":[19616187786153771277930658236501515378058310865337414616528052406614836915381,5716086794073894084115757926314451153376043864681595081544933294419482836932]},{"Curve":"ed25519","Coords":[54894815670576274903749323651006626882715390257891571131934873815604647096151,6261975146537300228952779313756496780554610579250869076285924817563901726620]},{"Curve":"ed25519","Coords":[56199043572031726140854435832515077152685912346629787788574432437354212337803,20932642671481609624660147804972444129208387391842241879798619789962570609578]}],"EDDSAPub":{"Curve":"ed25519","Coords":[19086049614490163056889859244855881816030591019773605655349500169700108043042,41654918635428963527745188055885714592211199796738262868910566706065491471139]}} \ No newline at end of file diff --git a/tss/curve.go b/tss/curve.go index 798767a6..68c99bd6 100644 --- a/tss/curve.go +++ b/tss/curve.go @@ -11,7 +11,7 @@ import ( "errors" "reflect" - s256k1 "github.com/btcsuite/btcd/btcec" + s256k1 "github.com/btcsuite/btcd/btcec/v2" "github.com/decred/dcrd/dcrec/edwards/v2" ) diff --git a/tss/message.go b/tss/message.go index d34ecb26..26ec8cb4 100644 --- a/tss/message.go +++ b/tss/message.go @@ -9,7 +9,7 @@ package tss import ( "fmt" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) @@ -81,7 +81,7 @@ var ( // NewMessageWrapper constructs a MessageWrapper from routing metadata and content func NewMessageWrapper(routing MessageRouting, content MessageContent) *MessageWrapper { // marshal the content to the ProtoBuf Any type - any, _ := anypb.New(proto.MessageV2(content)) + any, _ := anypb.New(content) // convert given PartyIDs to the wire format var to []*MessageWrapper_PartyID if routing.To != nil { @@ -111,7 +111,7 @@ func NewMessage(meta MessageRouting, content MessageContent, wire *MessageWrappe } func (mm *MessageImpl) Type() string { - return proto.MessageName(mm.content) + return string(proto.MessageName(mm.content)) } func (mm *MessageImpl) GetTo() []*PartyID { diff --git a/tss/message.pb.go b/tss/message.pb.go index 2e515a84..dc787987 100644 --- a/tss/message.pb.go +++ b/tss/message.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.18.1 +// protoc v3.19.3 // source: protob/message.proto package tss diff --git a/tss/party.go b/tss/party.go index 3c4b3b15..d97b37ad 100644 --- a/tss/party.go +++ b/tss/party.go @@ -34,8 +34,8 @@ type Party interface { setRound(Round) *Error Round() Round advance() - lock() - unlock() + Lock() + Unlock() } type BaseParty struct { @@ -49,8 +49,8 @@ func (p *BaseParty) Running() bool { } func (p *BaseParty) WaitingFor() []*PartyID { - p.lock() - defer p.unlock() + p.Lock() + defer p.Unlock() if p.rnd == nil { return []*PartyID{} } @@ -101,19 +101,19 @@ func (p *BaseParty) advance() { p.rnd = p.rnd.NextRound() } -func (p *BaseParty) lock() { +func (p *BaseParty) Lock() { p.mtx.Lock() } -func (p *BaseParty) unlock() { +func (p *BaseParty) Unlock() { p.mtx.Unlock() } // ----- // func BaseStart(p Party, task string, prepare ...func(Round) *Error) *Error { - p.lock() - defer p.unlock() + p.Lock() + defer p.Unlock() if p.PartyID() == nil || !p.PartyID().ValidateBasic() { return p.WrapError(fmt.Errorf("could not start. this party has an invalid PartyID: %+v", p.PartyID())) } @@ -147,10 +147,10 @@ func BaseUpdate2(p Party, msg ParsedMessage, task string) (ok bool, err *Error) } // lock the mutex. need this mtx unlock hook; L108 is recursive so cannot use defer r := func(ok bool, err *Error) (bool, *Error) { - p.unlock() + p.Unlock() return ok, err } - p.lock() // data is written to P state below + p.Lock() // data is written to P state below common.Logger.Debugf("party %s received message: %s", p.PartyID(), msg.String()) if p.Round() != nil { common.Logger.Debugf("party %s round %d update: %s", p.PartyID(), p.Round().RoundNumber(), msg.String()) @@ -174,7 +174,7 @@ func BaseUpdate2(p Party, msg ParsedMessage, task string) (ok bool, err *Error) // finished! the round implementation will have sent the data through the `end` channel. common.Logger.Infof("party %s: %s finished!", p.PartyID(), task) } - p.unlock() // recursive so can't defer after return + p.Unlock() // recursive so can't defer after return return BaseUpdate2(p, msg, task) // re-run round update or finish) } return r(true, nil) @@ -190,10 +190,10 @@ func BaseUpdate(p Party, msg ParsedMessage, task string) (ok bool, err *Error) { } // lock the mutex. need this mtx unlock hook; L108 is recursive so cannot use defer r := func(ok bool, err *Error) (bool, *Error) { - p.unlock() + p.Unlock() return ok, err } - p.lock() // data is written to P state below + p.Lock() // data is written to P state below if p.Round() != nil { common.Logger.Debugf("party %s BaseUpdate round %d update. msg: %s", p.PartyID(), p.Round().RoundNumber(), msg.String()) } @@ -217,7 +217,7 @@ func BaseUpdate(p Party, msg ParsedMessage, task string) (ok bool, err *Error) { // finished! the round implementation will have sent the data through the `end` channel. common.Logger.Infof("party %s: %s finished!", p.PartyID(), task) } - p.unlock() // recursive so can't defer after return + p.Unlock() // recursive so can't defer after return return BaseUpdate(p, msg, task) // re-run round update or finish) } return r(true, nil) diff --git a/tss/wire.go b/tss/wire.go index bb9234ba..01083fe3 100644 --- a/tss/wire.go +++ b/tss/wire.go @@ -9,20 +9,14 @@ package tss import ( "errors" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - "github.com/golang/protobuf/ptypes/any" -) - -const ( - ECDSAProtoNamePrefix = "binance.tss-lib.ecdsa." - EDDSAProtoNamePrefix = "binance.tss-lib.eddsa." + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" ) // Used externally to update a LocalParty with a valid ParsedMessage func ParseWireMessage(wireBytes []byte, from *PartyID, isBroadcast bool) (ParsedMessage, error) { wire := new(MessageWrapper) - wire.Message = new(any.Any) + wire.Message = new(anypb.Any) wire.From = from.MessageWrapper_PartyID wire.IsBroadcast = isBroadcast if err := proto.Unmarshal(wireBytes, wire.Message); err != nil { @@ -32,15 +26,15 @@ func ParseWireMessage(wireBytes []byte, from *PartyID, isBroadcast bool) (Parsed } func parseWrappedMessage(wire *MessageWrapper, from *PartyID) (ParsedMessage, error) { - var any ptypes.DynamicAny + m, err := wire.Message.UnmarshalNew() + if err != nil { + return nil, err + } meta := MessageRouting{ From: from, IsBroadcast: wire.IsBroadcast, } - if err := ptypes.UnmarshalAny(wire.Message, &any); err != nil { - return nil, err - } - if content, ok := any.Message.(MessageContent); ok { + if content, ok := m.(MessageContent); ok { return NewMessage(meta, content, wire), nil } return nil, errors.New("ParseWireMessage: the message contained unknown content")