---
# System prepended metadata

title: Torus.js sapphire changes

---

# Torus.js sapphire changes



1. Latest code with sapphire (v9.x.x)
    - https://github.com/torusresearch/torus.js


2. Old code without sapphire (v8.x.x)
    - https://github.com/torusresearch/torus.js/tree/242e45e4d834855a70f8d975821ec3790ae4ecd5



3. Versioning strategy updates
    - Torus.js sdk starting from v9.x doesn't support any legacy networks. 
    - Legacy network support will be maintained by updating version 8.x.x if required
    - V9.x.x only supports sapphire mainnet, sapphire testnet and sapphire devnet


4. Code changes
    - Fetch node details package is updated to fetch sapphire node details (test cases and types)
    - ClientId mandatory field is added to constructor
    - metadataHost field is removed from constructor, metadata is returned from nodes so no need to pass external metadata
    - enableOneKey field is removed from constructor, onekey flow is default now so no need of this field.
    - `getUserTypeAndAddress` function is removed, only `getPublicAddress` is required in sapphire since oneKey flow is enabled by default
    - `setCustomKey` function is removed and a new `importKey` function is added. 
    - All functions which were setting or getting data from metadata are removed. For ex: setMetadata, getMetadata, getOrSetNonce etc
    - Strategy for fetching shares is changed, explained below in details
    - Now we return more data along with shares for ex: node_indexes,session key session tokens and session signatures, all this new data is required for tss
    - getPublicAddress now takes a new field `extendedVerifierId` which is required to set tss pub key. You cannot fetch shares of a extendedVerifierId for all verifiers except torus-health verifier which is a exception for testing purposes, you can only assign a key to a extendedVerifierId.
    - Signer is removed, previously we used to sign every key assign request but that is not required anymore. 
    

5. How import key works?

    - Import key basically takes a external private key as input and imports the key in to sapphire nodes.
    - This function first splits the key in to two parts, oauth key and nonce.
    - After splitting it generated 5 shares from oauth key and then send each share along with nonce to every node.
    - It also take a id token of the verifier and get the commitments from nodes before sending the shares to nodes.
    - Then it waits for threshold number of nodes to resolve before considering key import as successfull
        - refer to this function here: https://github.com/torusresearch/torus.js/blob/d2aa9894611ac58739ec09ab5b08b99795bc8825/src/torus.ts#L172

6. What changed in retrieve shares?

    - Retrieve share works exactly same as before except following change:-
        - Now it also expects a nonce from nodes along with shares before resolving
        - Nonce is not required for tss verifier ids
        - Now nodes also returns enc session token and session data, so
          this function also decrypts new data along with decrypting shares.
        


8. What changed in getPublicAddress?
    - Previously to fetch public key of user we used to do 2 api calls.
    - first to check if key exists if yes then return the key.
    - second if key doesn't exist we used to call a key assign api.
    - Now both of these api calls are combined in to one get or set api call
    - Also to do key assign we used to call node endpoints randomly one by one
      till we get success result from any of the node
    - Now we call all nodes parallely and wait for threshold of them to resolve before returning pub key.