mpcium icon indicating copy to clipboard operation
mpcium copied to clipboard

Expect the same walletID to generate the same address

Open cppfuns opened this issue 1 year ago • 2 comments

Expected assumption: In order to enhance the security of the node, it is currently expected that the same walletID can generate the same wallet address, so that only the node-related configuration and all walletIDs need to be backed up to completely rebuild the entire MPC service data

tss-lib expected changes https://github.com/bnb-chain/tss-lib/blob/5d01446c77c7ef4e20189c59a4d0f9db2c71a4e9/ecdsa/keygen/round_1.go#L42-L43

Before modification

// 1. calculate "partial" key share ui
ui := common.GetRandomPositiveInt(round.PartialKeyRand(), round.EC().Params().N)

After modification

// ui := common.GetRandomPositiveInt(round.PartialKeyRand(), round.EC().Params().N)
	ui := round.Params().Salt()
	if ui == nil {
		return round.WrapError(errors.New("ui is nil"))
	}

Add salt parameter in Parameters

https://github.com/bnb-chain/tss-lib/blob/5d01446c77c7ef4e20189c59a4d0f9db2c71a4e9/tss/params.go#L18-L33

// key salt
salt *big.Int

Modify the mpcium code to make the newly added salt parameters take effect

func (s *ecdsaKeygenSession) Init() error {
	logger.Infof("Initializing session with partyID: %s, peerIDs %s", s.selfPartyID, s.partyIDs)
	ctx := tss.NewPeerContext(s.partyIDs)

       // Add a salt parameter
	salt, ok := new(big.Int).SetString(s.walletID, 10)
	if !ok {
		fmt.Println("Illegal string format")
		return ErrIllegalStringFormat
	}

	params := tss.NewParameters(tss.S256(), ctx, s.selfPartyID, len(s.partyIDs), s.threshold, salt) // In the NewParameters parameter passed
	s.party = keygen.NewLocalParty(params, s.outCh, s.endCh, *s.preParams)
	logger.Infof("[INITIALIZED] Initialized session successfully partyID: %s, peerIDs %s, walletID %s, threshold = %d", s.selfPartyID, s.partyIDs, s.walletID, s.threshold)
	return nil
}

Please help me check whether the code I plan to modify is reasonable and whether there are any security risks.

cppfuns avatar Jul 15 '25 12:07 cppfuns

hi @cppfuns , thank you for the suggesiton. however replacing common.GetRandomPositiveInt with ui := round.Params().Salt()` removes entropy.

Anyone who knows or guesses the walletID can potentially reconstruct or simulate key shares.

I would suggest that we regularly backup the badger db files instead of relying on walletID as this is a huge trade off for security

anhthii avatar Jul 15 '25 13:07 anhthii

hi @cppfuns , thank you for the suggesiton. however replacing common.GetRandomPositiveInt with ui := round.Params().Salt()` removes entropy.

Anyone who knows or guesses the walletID can potentially reconstruct or simulate key shares.

I would suggest that we regularly backup the badger db files instead of relying on walletID as this is a huge trade off for security

If the usage scenario is a private network, is this feasible to simplify backup?

cppfuns avatar Jul 15 '25 13:07 cppfuns