bnb-chain / tss-lib

Threshold Signature Scheme, for ECDSA and EDDSA
MIT License
759 stars 261 forks source link

Problem with ecdsa signing using NewLocalPartyWithKDD #293

Closed zargarzadehm closed 4 months ago

zargarzadehm commented 4 months ago

Hi

I'm trying to use ecdsa singing with NewLocalPartyWithKDD but I'm getting this error in round 9:

party {0,tssPeer/12D3KooWCRHb4wfTxxvTKEqgDzgx7YMvyZccJKKG1zxVBUN3T5dq}, round 9, culprits [{0,tssPeer/12D3KooWCRHb4wfTxxvTKEqgDzgx7YMvyZccJKKG1zxVBUN3T5dq}]: U doesn't equal T

Do you have any suggestions? Which parameters in creating a party can affect the verification in round 9?

yycen commented 4 months ago

Hi Do you use the same msg to initialize NewLocalParty*(msg, ...) ? If the message to sign is not the same across all signing parties, it could possibly result in the error in round 9.

zargarzadehm commented 4 months ago

Hi Do you use the same msg to initialize NewLocalParty*(msg, ...) ? If the message to sign is not the same across all signing parties, it could possibly result in the error in round 9.

I checked, and the msg is the same for all parties. I also tested using NewLocalParty instead of NewLocalPartyWithKDD (without key derivation), and the message was signed successfully. The issue arises when attempting to sign using NewLocalPartyWithKDD.

yycen commented 4 months ago

Did you call UpdatePublicKeyAndAdjustBigXj? For a given keyDelta value, it should be noticed that the corresponding child pubkey is needed to feed in

    keyDerivationDelta := big.NewInt(123)

    deltaG := crypto.ScalarBaseMult(tss.S256(), keyDerivationDelta)
    cPk, err := deltaG.Add(keys[0].ECDSAPub)
    cPubKey := ecdsa.PublicKey{
        Curve: btcec.S256(),
        X:     cPk.X(),
        Y:     cPk.Y(),
    }
    err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, &cPubKey, tss.S256())
zargarzadehm commented 4 months ago

Did you call UpdatePublicKeyAndAdjustBigXj? For a given keyDelta value, it should be noticed that the corresponding child pubkey is needed to feed in

    keyDerivationDelta := big.NewInt(123)

    deltaG := crypto.ScalarBaseMult(tss.S256(), keyDerivationDelta)
    cPk, err := deltaG.Add(keys[0].ECDSAPub)
    cPubKey := ecdsa.PublicKey{
        Curve: btcec.S256(),
        X:     cPk.X(),
        Y:     cPk.Y(),
    }
    err = UpdatePublicKeyAndAdjustBigXj(keyDerivationDelta, keys, &cPubKey, tss.S256())

Thank you for your assistance; my issue was related to updating the reference keys.

As a suggestion, I believe that UpdatePublicKeyAndAdjustBigXj should be called for a single key rather than a list of keys. In production use, each user should call this function with their key, which should be passed as a pointer.