# \[Archive\] Data ethAddress does not match response address

**URL:** <https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [August 18, 2023, 7:42am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793 "2023-08-18T07:42:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 18, 2023, 7:42am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/1 "2023-08-18T07:42:25Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **noelc** on 8/18/2023.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

The torus service provider has recently started throwing this `data ethAddress does not match response address` error and it is blocking some of our users from authenticating with TKey. We’re not providing any sort of address during authentication, so I have no idea how we can fix this issue from our end. Please assist

```auto
export async function initializeServiceProviderShare(
  jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
  try {
    // @ts-expect-error Tkey types lacks the 'serviceProvider' property
    await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
    // @ts-expect-error Tkey types lacks the 'serviceProvider' property
    const loginDetails = await tKey.serviceProvider.triggerLogin({
      typeOfLogin: LOGIN_PROVIDER.JWT,
      verifier: env.web3AuthVerifier,
      clientId: env.web3AuthClientId,
      jwtParams: {
        id_token: jwt,
        verifierIdField: "email",
      },
    });
const pbKey = new BN(loginDetails.privateKey, "hex");
// The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
// Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
tKey.serviceProvider.postboxKey = pbKey;
return loginDetails;

```

**Please provide the following details too when asking for help in this category:**

- SDK Version:  
“@tkey/common-types”: “7.2.0”,  
“@tkey/default”: “7.2.0”,  
“@tkey/service-provider-torus”: “^7.3.0”,  
“@tkey/share-serialization”: “^7.3.0”,  
“@tkey/storage-layer-torus”: “^7.3.0”,

- Verifier Details:

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [August 18, 2023, 8:01am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/2 "2023-08-18T08:01:38Z")

</div>

@noelc Thanks for your recent communication.

Your issue has been forwarded to our team and we will get back with further updates once more information becomes available.

---

<div class="post-metadata">

**Author:** ![gsnova29](https://avatars.discourse-cdn.com/v4/letter/g/bcef8e/32.png) [@gsnova29](https://builder.metamask.io/u/gsnova29)\
**Post date:** [August 19, 2023, 2:01am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/3 "2023-08-19T02:01:43Z")

</div>

@vjgee  
Please help us as soon as possible, as we have many users facing this issue, they cannot do anything with their balance and they started to blame and report us.

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [August 19, 2023, 10:45am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/4 "2023-08-19T10:45:52Z")

</div>

Can you update to the latest version of the SDK and check once?

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 19, 2023, 1:22pm UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/5 "2023-08-19T13:22:58Z")

</div>

Upgrading to the latest SDK requires a complete overhaul of how we’re initializing TKey. I’m afraid doing so would also put our users further at risk of losing their private key because the latest SDK requires reconfiguring how we retrieve the user’s private key (we’d have to replace `TorusServiceProvider` with `SfaServiceProvider`, which requires a `chainConfig`. Our current implementation does not require a `chainConfig` and it was working just fine until recently).

Is there any less riskier solution? Preferably using the same SDK version we’re currently using?

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 21, 2023, 4:30am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/6 "2023-08-21T04:30:33Z")

</div>

I get `Unable to resolve enough promises` if I were to continue using `TorusServiceProvider`.

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 23, 2023, 11:20am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/7 "2023-08-23T11:20:23Z")

</div>

@yashovardhan @vjgee We are currently facing a critical issue affecting every user with TKey. A sudden, unannounced change on your end has resulted in severe consequences, blocking our users from accessing their funds because TKey is now unable to authorize their social share.

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [August 23, 2023, 11:35am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/8 "2023-08-23T11:35:58Z")

</div>

It does not require you to replace the service provider, the TorusServiceProvider will work as usual. There has been no change in the way our tKey SDK works. SFA Service Provider is a new option, but not a necessary upgradation.

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [August 23, 2023, 11:38am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/9 "2023-08-23T11:38:43Z")

</div>

Please share your code snippets after upgrading to the latest version of tKey. Also share your console log for error details.

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 23, 2023, 1:10pm UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/10 "2023-08-23T13:10:58Z")

</div>

I’ll start by sharing the code snippets and log details after the upgrade. Then after, I’ll share the code snippets and log details before the upgrade, the code that was working just fine the past few months.

## Code snippets after upgrading:

```ts
function createTKey() {
  const directParams = {
    baseUrl: "http://localhost:3000",
    enableLogging: true,
    network: isTestnet ? OPENLOGIN_NETWORK.TESTNET : OPENLOGIN_NETWORK.MAINNET,
    web3AuthClientId: env.web3AuthClientId,
  };
const serviceProvider = new ServiceProviderTorus({
customAuthArgs: directParams,
});
const storageLayer = new TorusStorageLayer({
hostUrl: “https://metadata.tor.us”,
serverTimeOffset: 3600000,
});
return new ThresholdKey({
serviceProvider,
storageLayer,
modules: {
[MOBILE_DEVICE_SHARE_MODULE]: new MobileDeviceShareModule(),
},
manualSync: false,
});
}
const tKey = createTKey();
export async function initializeServiceProviderShare(
jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
try {
await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
const loginDetails = await tKey.serviceProvider.triggerLogin({
typeOfLogin: LOGIN_PROVIDER.JWT,
verifier: env.web3AuthVerifier,
clientId: env.web3AuthClientId,
jwtParams: {
id_token: jwt,
verifierIdField: “email”,
},
});
const pbKey = new BN(loginDetails.privateKey, "hex");
// The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
// Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
tKey.serviceProvider.postboxKey = pbKey;
return loginDetails;

} catch (error: any) {
if (
error.message?.includes(
“Error occurred while verifying paramstimesigned is more than 1m0s ago”
)
) {
throw new ExpiredTokenError();
}
if (error.message === “Duplicate token found”) {
throw new DuplicateTokenError();
}
console.error(“[initializeServiceProviderShare]”, error.stack);
throw error;
}
}

```

## Console log with error details:

```auto
 INFO {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO Verifier: nft5-verifier-testnet
 LOG torus-direct/getTorusKey {"torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"]}
 ERROR [initializeServiceProviderShare] Unable to resolve enough promises.
    at construct (native)
    at apply (native)
    at _construct (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:3261:28)
    at Wrapper (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:3223:25)
    at construct (native)
    at _createSuperInternal (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:429741:294)
    at call (native)
    at SomeError (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:430411:29)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:430479:39)
    at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:418:28)
    at tryCallOne (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29567:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at _callReactNativeMicrotasksPass (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29516:17)
    at callReactNativeMicrotasks (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29679:44)
    at __callReactNativeMicrotasks (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2688:46)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2500:45)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at flushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2499:21)
    at invokeCallbackAndReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2493:33)

```

## Patch file we have to change due to the ‘document’ error on mobile for customauth:

```patch
// patches/@toruslabs+customauth+16.0.0.patch
diff --git a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
index 2da94ca..09161cf 100644
--- a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
@@ -260,18 +260,19 @@ function storageAvailable(type) {
 }
 function getPopupFeatures() {
   // Fixes dual-screen position Most browsers Firefox
- const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
- const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
- const w = 1200;
- const h = 700;
- const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
- const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
- const systemZoom = 1; // No reliable estimate
-
- const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
- const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
- const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
- return features;
+ // const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
+ // const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
+ // const w = 1200;
+ // const h = 700;
+ // const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
+ // const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
+ // const systemZoom = 1; // No reliable estimate
+
+ // const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
+ // const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
+ // const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
+ // return features;
+ return "";
 }
 const isFirefox = () => {
   var _window;

```

## Code snippets before upgrading:

```auto
function createTKey() {
  const directParams = {
    baseUrl: "http://localhost:3000",
    enableLogging: true,
    network: isTestnet ? OPENLOGIN_NETWORK.TESTNET : OPENLOGIN_NETWORK.MAINNET,
  };
const serviceProvider = new ServiceProviderTorus({
customAuthArgs: directParams,
});
const storageLayer = new TorusStorageLayer({
hostUrl: “https://metadata.tor.us”,
serverTimeOffset: 3600000,
});
return new ThresholdKey({
serviceProvider,
storageLayer,
modules: {
[MOBILE_DEVICE_SHARE_MODULE]: new MobileDeviceShareModule(),
},
manualSync: false,
});
}
const tKey = createTKey();
export async function initializeServiceProviderShare(
jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
try {
await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
const loginDetails = await tKey.serviceProvider.triggerLogin({
typeOfLogin: LOGIN_PROVIDER.JWT,
verifier: env.web3AuthVerifier,
clientId: env.web3AuthClientId,
jwtParams: {
id_token: jwt,
verifierIdField: “email”,
},
});
const pbKey = new BN(loginDetails.privateKey, "hex");
// The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
// Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
tKey.serviceProvider.postboxKey = pbKey;
return loginDetails;

```

## Console log with error details (this is what I’m currently getting with 1 account)

```auto
 INFO {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO Verifier: nft5-verifier-testnet
 LOG torus-direct/getTorusKey {"torusIndexes": [1, 2, 3, 4, 5], "torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"], "torusNodePub": [{"X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"}, {"X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"}, {"X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"}, {"X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"}, {"X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4"}]}
 LOG torus-direct/getTorusKey {"getPublicAddress": {"X": "93d4ff5b8d1096bd3f03ec576ed67b92195266cde9a7fef01b1ce99328ba2a70", "Y": "2b1ca1e48e53d7ca95424bb01ab873be8980fbf24210cd554acb519cddcecb3a", "address": "0xBcEac6E8eEb53D8348aBdE56678Fc44f186D1A97", "metadataNonce": "00", "pubNonce": undefined, "typeOfUser": "v1", "upgraded": undefined}}
 LOG torus-direct/getTorusKey {"retrieveShares": {"ethAddress": "0xBcEac6E8eEb53D8348aBdE56678Fc44f186D1A97", "metadataNonce": "00", "privKey": "a6b86d25dea539f8daa7fdcb9ff1bd3f532d5b158f8ac787b4f71fdc68f36ee6"}}
 ERROR [setupDeviceShare] {"errorMessage": "setMetadata errored Assertion failed", "errorStack": "{\"name\":\"CoreError\",\"code\":1103,\"message\":\"setMetadata errored Assertion failed\"}
    at fromCode (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425657:31)
    at metadataPostFailed (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425687:36)
    at ?anon_0_ (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:426866:46)
    at throw (native)
    at asyncGeneratorStep (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4556:26)
    at _throw (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4578:29)
    at invokeCallback (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446832:27)
    at publish (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446818:25)
    at publishRejection (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446774:14)
    at flush (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446631:17)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29547:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at callTimers (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29642:19)
    at apply (native)
    at __callFunction (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2721:36)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2482:31)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at callFunctionReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2481:21)"}
 LOG 8:04:51 PM | [useTKeyInitializationFlow] | ERROR : [setupDeviceShare] An occurred with TKey storage layer

```

The code for setupDeviceShare is:

```ts
export async function setupDeviceShare() {
  try {
    const keyDetails = await tKey.initialize(); // 2/3 flow - NOTE: This will create the device share if it does not exist
    const { requiredShares } = keyDetails;
    Logger.debug("[setupDeviceShare]", { requiredShares });
    if (requiredShares > 0) {
      // This means the user setup 2FA from Web3Auth flow and we need to recover it.
      throw new InsufficientSharesError(`Required shares: ${requiredShares}`);
    }
  } catch (error: any) {
    console.error("[setupDeviceShare]", {
      errorMessage: error.message,
      errorStack: error.stack,
    });
    if (
      METADATA_RELATED_ERROR_MESSAGES.some((message) =>
        error.message.includes(message)
      )
    ) {
      throw new MetadataError(error.message);
    }
  }
}

```

## This is the console log with error details using a different account:

```auto
 INFO {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO Verifier: nft5-verifier-testnet
 LOG torus-direct/getTorusKey {"torusIndexes": [1, 2, 3, 4, 5], "torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"], "torusNodePub": [{"X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"}, {"X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"}, {"X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"}, {"X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"}, {"X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4"}]}
 LOG torus-direct/getTorusKey {"getPublicAddress": {"X": "1843e2f416d6370096c7950fa99c0c7bcf80dba8117720365bf14711386bb4db", "Y": "8a8085da380db3d2e627d2b9284a6c24a3acc2bc067dff90120b75113971949d", "address": "0x82973543270490057653D32a602FaDA93E4EdC23", "metadataNonce": "00", "pubNonce": undefined, "typeOfUser": "v1", "upgraded": undefined}}
 LOG torus-direct/getTorusKey {"retrieveShares": {"ethAddress": "0x82973543270490057653D32a602FaDA93E4EdC23", "metadataNonce": "00", "privKey": "8b2badbe99445c8e51232fc0301faabf52315604b038c52191666e4e0960cece"}}
 ERROR [setupDeviceShare] {"errorMessage": "setMetadata errored Assertion failed", "errorStack": "{\"name\":\"CoreError\",\"code\":1103,\"message\":\"setMetadata errored Assertion failed\"}
    at fromCode (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425657:31)
    at metadataPostFailed (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425687:36)
    at ?anon_0_ (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:426866:46)
    at throw (native)
    at asyncGeneratorStep (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4556:26)
    at _throw (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4578:29)
    at invokeCallback (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446832:27)
    at publish (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446818:25)
    at publishRejection (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446774:14)
    at flush (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446631:17)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29547:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at callTimers (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29642:19)
    at apply (native)
    at __callFunction (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2721:36)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2482:31)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at callFunctionReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2481:21)"}
 LOG 8:08:33 PM | [useTKeyInitializationFlow] | ERROR : [setupDeviceShare] An occurred with TKey storage layer

```

## Patch file we have to change due to the ‘document’ error on mobile for customauth (and has been working for several months):

```patch
// patches/@toruslabs+customauth+11.5.0.patch
diff --git a/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
index 6caceb7..d5ba346 100644
— a/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
@@ -44277,19 +44277,7 @@ function storageAvailable(type) {
}
}
function getPopupFeatures() {

// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
const w = 1200;
const h = 700;
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
const systemZoom = 1; // No reliable estimate

const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
const features = titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left};
return features;

return “”;
}
const isFirefox = () => {
var _window, _window$navigator;
diff --git a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
index 6fec82a..1fa7e57 100644
— a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
@@ -273,19 +273,7 @@ function storageAvailable(type) {
}
}
function getPopupFeatures() {

// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
const w = 1200;
const h = 700;
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
const systemZoom = 1; // No reliable estimate

const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
const features = titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left};
return features;

return “”;
}
const isFirefox = () => {
var _window, _window$navigator;
diff --git a/node_modules/@toruslabs/customauth/src/utils/helpers.ts b/node_modules/@toruslabs/customauth/src/utils/helpers.ts
index fd76e86..b8bf338 100644
— a/node_modules/@toruslabs/customauth/src/utils/helpers.ts
+++ b/node_modules/@toruslabs/customauth/src/utils/helpers.ts
@@ -129,31 +129,7 @@ export function storageAvailable(type: REDIRECT_PARAMS_STORAGE_METHOD_TYPE): boo
}

export function getPopupFeatures(): string {

// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;

const w = 1200;
const h = 700;

const width = window.innerWidth
? window.innerWidth
: document.documentElement.clientWidth
? document.documentElement.clientWidth
: window.screen.width;

const height = window.innerHeight
? window.innerHeight
: document.documentElement.clientHeight
? document.documentElement.clientHeight
: window.screen.height;

const systemZoom = 1; // No reliable estimate

const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
const features = titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left};
return features;

return “”;
}

```

---

<div class="post-metadata">

**Author:** ![yashovardhan](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/yashovardhan/32/1526_2.png) [@yashovardhan](https://builder.metamask.io/u/yashovardhan)\
**Post date:** [August 23, 2023, 3:00pm UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/11 "2023-08-23T15:00:46Z")

</div>

@noelc can you additionally upgrade @toruslabs/customauth package to v16? Please delete your package.lock and then try so that all the web3auth packages are updated. @tkey packages are good to go on v11.

Let me know if that solves the issue.

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [August 24, 2023, 3:27am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/12 "2023-08-24T03:27:11Z")

</div>

I already tried using `@toruslabs/customauth` v16 and it doesn’t help. You can also see the associated patch file in the code snippet I provided above for the post-upgrade.

[![Screenshot 2023-08-24 at 10.25.20 AM copy](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/2X/1/13efc9b4c93f0d4bb90cb4185d11d1b8201b1fba.png)
Screenshot 2023-08-24 at 10.25.20 AM copy834×248 31.6 KB
](https://web3auth.io/community/uploads/default/original/2X/b/bc198aed218166c5f90eb557a9a9bf1877a4ab61.png "Screenshot 2023-08-24 at 10.25.20 AM copy")

---

<div class="post-metadata">

**Author:** ![noelc](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@noelc](https://builder.metamask.io/u/noelc)\
**Post date:** [September 13, 2023, 7:26am UTC](https://builder.metamask.io/t/archive-data-ethaddress-does-not-match-response-address/1793/13 "2023-09-13T07:26:01Z")

</div>

After consulting with the Web3Auth team, we discovered that the root cause of the issue was linked to [this problem](https://github.com/margelo/react-native-bignumber/issues/60). We had been using it as an alternative for `bn.js`, which led to BN formatting problems that subsequently affected TKey. We would like to extend our gratitude to [cherngwoei@tor.us](mailto:cherngwoei@tor.us) for helping us identify this problem.

Additionally, I recommend the TKey team to enhance their error response and handling within the TKey SDK. This is crucial, as several network-related errors make debugging challenging.

Since implementing the fix, we’ve observed no further instances of the `data ethAddress does not match response address` errors in our production environment. Consequently, this issue can now be marked as resolved.
