Skip to content

Commit

Permalink
updated to tss-lib/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mira Belenkiy committed Nov 20, 2023
1 parent a5c67de commit f47c4a4
Show file tree
Hide file tree
Showing 34 changed files with 116 additions and 209 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ test_unit:
@echo "--> Running Unit Tests"
@echo "!!! WARNING: This will take a long time :)"
go clean -testcache
go test -timeout 60m github.com/bnb-chain/tss-lib/crypto/accmta
go test -timeout 60m github.com/bnb-chain/tss-lib/crypto/zkproofs
go test -timeout 60m github.com/bnb-chain/tss-lib/ecdsa/cggplus
# go test -timeout 60m $(PACKAGES)
go test -timeout 60m $(PACKAGES)

test_unit_race:
@echo "--> Running Unit Tests (with Race Detection)"
Expand Down
8 changes: 4 additions & 4 deletions crypto/accmta/share_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"math/big"
"sync"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func AliceInit(
Expand Down
14 changes: 7 additions & 7 deletions crypto/accmta/share_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/accmta"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/accmta"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/v2/tss"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions crypto/zkproofs/aff_g_inv_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

// Note: (z,u,v) are lowercase in aff-g from CGG21 Section 6.2 Figure 15.
Expand Down
6 changes: 3 additions & 3 deletions crypto/zkproofs/aff_g_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions crypto/zkproofs/aff_g_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func GenerateAffGData(t *testing.T) (*zkproofs.AffGWitness, *zkproofs.AffGStatement) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/zkproofs/aff_p_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions crypto/zkproofs/aff_p_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"math/big"
"testing"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"

"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions crypto/zkproofs/dec_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions crypto/zkproofs/dec_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func TestDecProof(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions crypto/zkproofs/enc_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

const (
Expand Down Expand Up @@ -137,9 +137,9 @@ func (proof *EncProof) Verify(stmt *EncStatement, rp *RingPedersenParams) bool {
// check (1+N0)^z1 * z2^N0 mod N02 == A * K^e mod N02
N02 := new(big.Int).Mul(stmt.N0, stmt.N0)
pkN0 := &paillier.PublicKey{N: stmt.N0}
left1, err := pkN0.EncryptWithRandomness(proof.Z1, proof.Z2)
left1 := pkN0.EncryptWithRandomnessNoErrChk(proof.Z1, proof.Z2)
right1 := ATimesBToTheCModN(proof.A, stmt.K, e, N02)
if err != nil || left1.Cmp(right1) != 0 {
if left1.Cmp(right1) != 0 {
return false
}

Expand Down
26 changes: 2 additions & 24 deletions crypto/zkproofs/enc_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,14 @@
package zkproofs_test

import (
"math/big"
"testing"

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func TestEncKnownInputProof(t *testing.T) {
k, _ := new(big.Int).SetString("114389473239505230491163146795412138983239597318806644445410158725115455132692", 0)
K, _ := new(big.Int).SetString("465731706496473911847378750369631955920537852546894056438324922002323832557052064091918779928998117741164270297323463208064330285407219572177029360826008098571725648121552938575861312248098147580091443066258128496730130821607283612246459392571020574355259214835267622850399259810669526425866890543731585668563000223903364750259693607987689860689205912013767228001149855306031477483177607033616664945169002738496514270876030965906518470081313910226789131722379851589407879764493910658365838303529011095873089917057785671727758265706395079059011018323942761921652586013265038187227881878435999741578132905577045639379857443750047257615234688808089465285800849341881615220067137051394879797468117924789386876077614815545558385023634752683865402913773342113237762409485419286550203760964443643787231978551910564595235133167072250444545071003504714377320420465772179408459459859448083450614589893581034041705745134325422367038213583684619090512936707235222566271258400064022000366699765004412201467436278215661566566076268380633299387576044688216534173466664307669004872674171324245476404394755604318512835901804601155380746059882379447729445237927082554648890833562174587009270444294220972401968147951439030634576490769491329725523066373", 0)
rho, _ := new(big.Int).SetString("1589242199014186642803401666691520301635771315788503864752220777217738751901654796434493911079208937341944417070764384236037629531669977085618074891575239323560840983052587886127349018243828507737099166737147980821930538648101089752705183504157416079572589094945765694857956926575398689326240518052796539017352391285840754641810683001857169286294137848743745186617946790757924489281977116077802106464822099774315121788634674603354884106884083707909112735182653869657570449994189127412585926110940250122589069694819774998940166052085553665809474348432193960236312713027489316513952283294330658069074266897280468237987", 0)

witness := &zkproofs.EncWitness{
K: k,
Rho: rho,
}
statement := &zkproofs.EncStatement{
EC: ec,
N0: publicKey.N,
K: K,
}
proof, err := zkproofs.NewEncProof(witness, statement, ringPedersen)
assert.NoError(t, err)
assert.NotNil(t, proof, "proof is nil")
assert.False(t, proof.Nil(), "proof has nil fields")
assert.True(t, proof.Verify(statement, ringPedersen), "proof failed to verify")
}

func TestEncProof(t *testing.T) {
setUp(t)

Expand Down
6 changes: 3 additions & 3 deletions crypto/zkproofs/logstar_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions crypto/zkproofs/logstar_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func TestLogStarProof(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion crypto/zkproofs/mul_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/v2/common"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions crypto/zkproofs/mul_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
)

func TestMulProof(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/zkproofs/mulstar_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions crypto/zkproofs/mulstar_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func TestMulStarProof(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion crypto/zkproofs/zkproofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"math/big"
"strconv"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/v2/common"
)

type Proof interface {
Expand Down
8 changes: 4 additions & 4 deletions crypto/zkproofs/zkproofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/stretchr/testify/assert"

"github.com/bnb-chain/tss-lib/crypto/paillier"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/crypto/paillier"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/v2/tss"
)

// Using a modulus length of 2048 is recommended in the GG18 spec
Expand Down
6 changes: 3 additions & 3 deletions ecdsa/cggplus/finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"math/big"
"sync"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func (round *finalization) Start() *tss.Error {
Expand Down
10 changes: 5 additions & 5 deletions ecdsa/cggplus/local_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"fmt"
"math/big"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/v2/tss"
)

// Implements Party
Expand Down
8 changes: 4 additions & 4 deletions ecdsa/cggplus/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"math/big"
"strconv"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

var (
Expand Down
10 changes: 5 additions & 5 deletions ecdsa/cggplus/round_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"errors"
"fmt"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/accmta"
"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/ecdsa/signing"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/accmta"
"github.com/bnb-chain/tss-lib/v2/ecdsa/keygen"
"github.com/bnb-chain/tss-lib/v2/ecdsa/signing"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func newRound1(params *tss.Parameters, key *keygen.LocalPartySaveData, data *common.SignatureData, temp *localTempData, out chan<- tss.Message, end chan<- common.SignatureData) tss.Round {
Expand Down
8 changes: 4 additions & 4 deletions ecdsa/cggplus/round_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"errors"
"sync"

"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/accmta"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/accmta"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func (round *round2) Start() *tss.Error {
Expand Down
8 changes: 4 additions & 4 deletions ecdsa/cggplus/round_3.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"math/big"
"sync"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto/accmta"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto/accmta"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func (round *round3) Start() *tss.Error {
Expand Down
8 changes: 4 additions & 4 deletions ecdsa/cggplus/round_4.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"math/big"
"sync"

"github.com/bnb-chain/tss-lib/common"
"github.com/bnb-chain/tss-lib/crypto"
"github.com/bnb-chain/tss-lib/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/tss"
"github.com/bnb-chain/tss-lib/v2/common"
"github.com/bnb-chain/tss-lib/v2/crypto"
"github.com/bnb-chain/tss-lib/v2/crypto/zkproofs"
"github.com/bnb-chain/tss-lib/v2/tss"
)

func (round *round4) Start() *tss.Error {
Expand Down
Loading

0 comments on commit f47c4a4

Please sign in to comment.