Skip to main content

Technical Architecture

This document serves primarily as a guide to Torus Key Infrastructure, and not as a technical specification. It may become outdated. For the latest and greatest, check out our open-source code.

Components#

Torus nodes (or service provider)#

Torus nodes provide a user-specific key based on some form of attestation from the user. This attestation could come in the form of an OAuth login from an existing account, a traditional email account login, or even biometrics. Torus nodes need not return a private key, but need to fufill the interface:

  • retrievePubKey()retrievePubKey()
  • encrypt(msg,pubKey)encrypt(msg, pubKey)
  • decrypt(msg)decrypt(msg)
  • sign(msg)sign(msg)

For ease of illustration the rest of this document assumes that this is implemented with secp256k1 keys and ECIES. The key retrieved from the Torus nodes is refered to as an encryption key or encKeyencKey.

Storage layer#

The storage layer serves as a persistent data store for storing encrypted metadata. Examples of such systems include IPFS, Arweave, Sia, or even BFT layers. Data availability and cost are the main factors to consider but the choice of storage layer is ultimately up to the implementer.

TKI utilizes encKeyencKey from the torus nodes as an entry point to retrieve the private key. encKeyencKey is used to retrieve encrypted user-specific data from the storage layer, refered to as metadata. This data includes a user's threshold, polynomial commitments, associated devices, and so on.

User device#

TKI is dependent on user devices to store shares. The base flow accomodates a single device, but users can use multiple devices to increase the threshold once they have an initial setup. Access to device storage on the user's device is implementation specific. For example, for native applications on mobile, they can make use of the device keychain.

Recovery share#

This is generally not used during normal operation, and is intended for use in key recovery / share refresh if the user loses his/her device or shares.

Key initialization and reconstruction#

A key is initialized upon a user-triggered action (eg. login to Torus nodes). We then attempt to retrieve associated metadata for the user. If none exists, the user is a new one and we generate a corresponding SSS 2/3 polynomial with its respective key and shares. If it exists, we decrypt the metadata using the Torus nodes encKeyencKey and read the metadata to verify user information and associated secret sharing parameters.

Initialization#

We select a polynomial f(z)f(z) over ZqZ_q where: f(z)=a1z+σf(z) = a_1z + \sigma

  • f(0)=σf(0) = \sigma denotes the private key scalar to be used by the user
  • a1a_1 is a coefficient to zz
  • f(z1),f(z2)f(z_1),f(z_2) and f(z3)f(z_3) are ShareA, ShareB and ShareC respectively

ShareA is stored on the user's device, ShareB is encrypted with the encKeyencKey and stored on the storage layer for future retrieval, and ShareC dependent on user input or handled as a recovery share.

Reconstruction#

If a user has logged in previously, he/she reconstructs their key by decrypting ShareB (retrieved through the storage layer) and combining it with ShareA on the user's current device using Lagrange interpolation.

Key generation with deterministic share#

Provided with a user input, inputinput, we can pre-determine a single share in the generation of the SSS polynomial, where we peg ShareC or f(z3)f(z_3) to a users input. Let HH be a cryptographically secure hash function. Givenf(z3)=H(input)Select σ over Zq and solve a1=f(z3)σz3\text{Given} \, f(z_3)= H(input)\\ \text{Select } \sigma \text{ over } Z_q \text{ and solve } a_1= \frac{f(z_3) - \sigma}{z_3}

In the case of secret resharing, we can also conduct the deterministic generation of the f(z)f(z) polynomial with a given σ\sigma and inputinput. We are able to peg nn given values to the key or shares as long as nd+1n\le d + 1 where dd is the degree of the SSS polynomial f(z)f(z).

It is important that inputinput has sufficent entropy in its generation. A potential way to guarentee this is via using several security questions (for example three of them) with answers A,B,CA,B,C to derive input=ABCinput = A|B|C. This can be implemented with a repository of questions, of which order and index can be defined in metadata.

Candidate qualified questions are suggested to be ones with deterministic answers (i.e. "your parent's birthday" or "your city of birth"), rather than "what's your favorite singer?". To accomodate for cases that users tend to forget their answers. There is a further potential of splitting the answers themselves via SSS such that the user can answer 3/5 questions, giving redundancy.

Expanding the number of shares (adding a device)#

In the case of a new device the user needs to migrate a share to the device to reconstruct their key. This can be done user input or through a login to a current device.

On reconstruction of f(z)f(z) on the new device we set ShareD to f(z4)f(z_4).

Share resharing and revokability#

Utilizing the storage layer, we are able to generate new shares for all devices, regardless if they are online or offline. This allows us to remove devices from the sharing, allow the user to change their security questions and/or adjust their security threshold. The key concept here is utilizing published Share commitments as encryption keys to retrieve shares on the most updated SSS polynomial.

This is illustrated from a 2/4 SSS sharing f(z)f(z) with shares sa,sb,sc,sds_a, s_b, s_c, s_d kept on 3 user devices and the Torus nodes. Let gg be a generator of a multiplicative subgroup where the discrete log problem is assumed hard to solve. During initialization of the key we create share commitments gsa,gsb,gsc,gsdg^{s_a}, g^{s_b}, g^{s_c}, g^{s_d} to be stored on the storage layer. These share commitments are analgous to public keys derived from the share scalars.

Given the user loses device D holding sds_d, and wants to make that share redundant. He/she first reconstructs their key on device A. We utilize a public key based encryption scheme (eg. ECIES).

The user generates a new 2/3 SSS polynomial h(z)h(z) on the same σ\sigma with shares s1,s2,s3s_1, s_2, s_3 and encrypts the newly generated shares for each respective share commitment, except for the lost gsdg^{s_d} commitment.

for i={1,2,3} and v={a,b,c}encrypt(siu,gsv)cnvwhere nv={1a,2b,2c}\text{for }i = \{1,2,3\} \text{ and } v = \{a,b,c\} \\ encrypt(s_iu,g^{s_v}) \Rightarrow c_{nv} \\ \text{where } nv = \{1a,2b,2c\}

cnvc_{nv}, the resulting ciphertext from the encryption, is then stored on the storage layer for retrieval on other devices.

On login to device B, the user retrieves c2bc_{2b} is able to use sbs_b to decrypt the new s2s_2 and reconstruct their key with s1s_1 derived from the Torus nodes in a similar fashion. Using the h(z)h(z) allows sds^d to also be deprecated as a share.

Resharing allows us to share a key on a new polynomial with a different degree/threshold, allowing us to also increase a user's security/factor devices or inputs to reconstruct thier key as they require it. This can be incrementally done as needed.

Comparisons to existing key/asset management systems#

Compared to traditional key management, TKI improves on recoverability, usability, and flexibility. It also allows revocability of shares and edits of access structures to a user's key. Today, we do have multi-sigs and smart contract wallets (SCW) that hold assets which provide similar properties. They work well and TKI can be used as an external key to these contructions. Relative to these tools, because TKI revolves around managing a native private key it is far more composable.

While an onchain multi-sig/SCW can fufill most functions, there are nuances to consider implementation-wise. For example, being on-chain, they are limited to the layer-1 chain they are implemented on, limiting interoperability with other layer-2 scalability solutions or other blockchains. Deployment fees for smart contract wallets can also be expensive and slow, which increases user-friction.

The model is also flexible, and different configurations of SSS thresholds can help to balance convenience, security, and redundancy, according to the user's needs.

Future directions#

Proactive Secret Sharing with Threshold Signature Schemes#

TKI can be implemented with threshold signature schemes such that the key need not be constructed in an existing front-end when signing transactions, which helps to improve security. The initial private key can also be generated via distributed key generation, to ensure that the private key is never reconstructed at all. In this case resharing of shares for a new polynomial could be done through proactive secret sharing schemes with dynamic participants.