Key Lifecycle Management

Listing and Deleting Keys

You can get a list of the IDs of all keys for which a given MPC node holds shares:

Go

ctx := context.Background()
keyIDs, err := client.KeyManagement().ListKeys(ctx)

Given a specific key ID, you can delete the corresponding key share on the MPC node like this:

Go

err := client.KeyManagement().DeleteKeyShare(ctx, keyID)

Note that ListKeys and DeleteKeyShare operate on a single MPC node. So, the fact that a single MPC node returns a key ID does not necessarily mean that the key “exists” in the TSM. Likewise, deleting the key share may not delete the key itself from the TSM. Generally, a key “exists” in the TSM if a sufficient number of MPC nodes (usually t+1, where t is the security threshold of the key) hold shares of the key to generate MPC signatures using the key.

You can also count and delete the presignatures for a given key:

Go

presigCount, err := client.KeyManagement().CountPresignatures(ctx, keyID)
err := client.KeyManagement().DeletePresignatures(ctx, keyID)

Key Resharing

Suppose you have a key with ID keyID in the TSM. The secret sharing of the key can then be refreshed by running an MPC key resharing session.

First, choose the MPC session metadata, the session ID, and the set of nodes to participate. All nodes holding key shares of the key must participate in the resharing.

Go

sessionID := tsm.GenerateSessionID()
players := []int{ 0, 1, 2 }  // This assumes the key was generated among Node 0, 1, 2
sessionConfig := tsm.NewSessionConfig(sessionID, players, nil)

Then run the MPC session by calling this method on all SDKs:

Go

ctx := context.Background()
err := client.ECDSA().Reshare(ctx, sessionConfig, keyID)

If the MPC session succeeds, the secret sharing of the key in the TSM will be replaced by a fresh random secret sharing (of the same key).

Note the following about resharing:

Self-contained code examples showing how to reshare a key can be found in our demo repository (Go, Java, node.js). After resharing, the key will be the same, but it will be shared with a fresh, randomized secret sharing.

Key Copy

You can create a copy of a key that already exists in the Builder Vault. This is done as follows:

Go

newKeyID, err = client.ECDSA().CopyKey(ctx, sessionConfig, keyID, curveName, newThreshold, desiredKeyID)

This call instructs the MPC node to participate in an MPC session that creates a copy of a key. The copy will represent the same key as the original key but with a new random and independent secret sharing. The copy will be saved under a new key ID, and the existing key will not be affected.

The MPC session may include MPC nodes that do not hold shares of the original key. For these MPC nodes, the key ID must be empty and curveName must be the curve name for the original key, e.g., secp256k1, or ED-25519. MPC nodes that hold shares of the original key must provide keyID and use an empty curveName. The desiredKeyID is optional, and if provided, it will be used as the key ID for the new copy.

The MPC session only succeeds if all MPC nodes agree on keyID, newThreshold, and desiredKeyID. In addition, it will only succeed if threshold + 1 or more MPC nodes, who all hold key shares of the original key, participate in the session.

Use cases:

You can find a code example of how to use key copy in our demo repository (Go). In the example, we first generate a (2,1) key is among two MPC nodes. It is then copied to a (3,2) sharing among these two MPC nodes and a third node.