Skip to content

Latest commit

 

History

History
125 lines (90 loc) · 3.48 KB

js-sdk-dymanic-did.md

File metadata and controls

125 lines (90 loc) · 3.48 KB
id title sidebar_label description keywords
js-sdk-dynamic-did
Dynamic dids
Support of custom networks and dids
Ecosystem extension.
did
polygon id
ID holder
network
custom
registerDid

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

How to use custom did methods or networks with js-sdk

  1. Deploy contracts on custom chain.

    StateV2.sol - mandatory contract to transit identities states and getting global identity state root (GIST) during the authentication.

    IdentityTreeStore.sol - optional, this contract is responsible for storing revocation tree nodes and tree roots of Identity. Only needed in case onchain RHS ( Iden3OnchainSparseMerkleTreeProof2023 credential status) will be used for issuing credentials.

    Onchain Validators - optional, only in case you work on use cases with onchain verification. repository

  2. Register you network for PolygonID did method in the following way:

import { core } from "@0xpolygonid/js-sdk";

core.registerDidMethodNetwork({
  method: core.DidMethod.PolygonId,
  blockchain: "linea",
  chainId: 59140,
  network: "testnet",
  networkFlag: 0b0100_0000 | 0b0000_0001,
});

Also, eth provider must be defined for given network.

  const conf: EthConnectionConfig = defaultEthConnectionConfig;
  conf.contractAddress = contractAddress;
  conf.url = rpcUrl;

Where networkFlag is two bytes which will be used for generation of type of identity. It must be different from existing network flags. ChainId is identifier of network in ethereum ecosystem

:::info

Check an extension demo. or sdk examples.

:::

  1. Extend the setup of the verifier in the same way - by registering the supported did.
npm i @iden3/js-iden3-auth --save
const { core } = require("@iden3/js-iden3-auth");

core.registerDidMethodNetwork({
  method: core.DidMethod.PolygonId,
  blockchain: "linea",
  chainId: 59140,
  network: "testnet",
  networkFlag: 0b0100_0000 | 0b0000_0001,
});
    go get "github.com/iden3/go-iden3-core/v2"
    import (
        core "github.com/iden3/go-iden3-core/v2"
    )


    func registerDIDMethods() error {
        var err error

        params := core.DIDMethodNetworkParams{
            Method:      core.DIDMethodPolygonID,
            Blockchain:  "linea",
            Network:     "testnet",
            NetworkFlag: 0b0100_0000 | 0b0000_0001,
        }
        err = core.RegisterDIDMethodNetwork(params, core.WithChainID(59140))

        return err
    }

:::warning Custom Did methods / network registration is supported on core library level, js-sdk and verification libraries.

Not yet supported on issuer-node and mobile.

:::