Authenticate mainnet identity on local network

I am trying to use stoic identity to call local canister with following code

      const identity = await stoic.connect();
      const stoicActor = Actor.createActor(idlFactory, {
        canisterId: "ajuq4-ruaaa-aaaaa-qaaga-cai",
        agent: new HttpAgent({
          identity: identity,
          host: "http://127.0.0.1:8000",
        }),
      });

I got below error

mutation.mjs:158 Error: Server returned an error:
  Code: 403 (Forbidden)
  Body: Failed to authenticate request 0xbc23f03982e68ef7e9b4abd8dd305a9bce6de708bd5893634c198554c702d4a1 due to: Invalid delegation: Invalid canister signature: IcCanisterSignature signature could not be verified: public key 0a0000000000000007010126da01ad62fda27628ef6789a9901675eeb55f51b0615dfdb2d17f4e4337c42a, signature d9d9f7a26b6...

error: certificate verification failed: failed to verify threshold signature: certificate_tree_hash=CryptoHash(0x9c6a48be567b65ffb626517e8573dc43c0d28523c58830a7521bc64a2f179648), sig=Blob{48 bytes;8627b5fa90cfc2f861e1a19625c9efba4107215fb95070e3a2de6d674488ad3d1113d3645ce044796096457a78b128e8}, pk=ThresholdSigPublicKey { internal: ThresBls12_381(0xad61e320799037500ca548376d4e850ff620b5d6ccdbbfcd0ec8e63a7dfbc2592716205dea1feef79e4e31e180dc14dd0b179d6e34b7561d0c9e0202e2788341cbd680a44bfff12766c7184c25b8daa6a8250a89b96dd62405bee8f406e16d55) }, 

error=ThresBls12_381 signature could not be verified: public key ad61e320799037500ca548376d4e850ff620b5d6ccdbbfcd0ec8e63a7dfbc2592716205dea1feef79e4e31e180dc14dd0b179d6e34b7561d0c9e0202e2788341cbd680a44bfff12766c7184c25b8daa6a8250a89b96dd62405bee8f406e16d55, 

signature 8627b5fa90cfc2f861e1a19625c9efba4107215fb95070e3a2de6d674488ad3d1113d3645ce044796096457a78b128e8, error: Invalid combined threshold signature

Does it mean I cannot use mainnet identity to call local canister? Is there a way around?

Yes, it means exactly that. The root key for your local machine and mainnet are different, this is why the signature check fails locally. You need to deploy a stoic instance locally as well to develop against that.

Please reach out to the stoic developers for support on that matter.

1 Like