Repository navigation
Allow genesis hash prefixes as the network in Concordium DIDs - #986
Merged
Merged
Conversation
DIDs can now identify the network by the first 16 bytes of its genesis block hash, e.g. did:ccd:4221332d34e1694168c2a0c0b3fd0f27:idp:0, matching ccd:<prefix> chain IDs. This works for any chain, not only testnet and mainnet. - Add GenesisHashPrefix and the Network::Genesis variant; mark Network #[non_exhaustive]. - Network equality, ordering and hashing compare the chain, so the named and genesis forms of the same network are equal and verification accepts either. - Existing string, JSON and binary forms are unchanged; the genesis form serializes as 32 lowercase hex characters or tag 2 + 16 bytes. - The DID parser rejects malformed genesis prefixes instead of reading them as a missing network.
andynelson
requested review from
allanbrondum,
limemloh and
soerenbf
and removed request for
allanbrondum
November 11, 2026 10:07
limemloh
approved these changes
Nov 11, 2026
allanbrondum
approved these changes
Nov 12, 2026
andynelson
marked this pull request as ready for review
November 12, 2026 12:45
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix, with helpers for DIDs, chain IDs and key derivation (mainnet derives as Mainnet, every other network as Testnet); add a DID module that builds and parses every Concordium DID type; route the DID classes, create*DID helpers and credential metadata parsing through it; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the mainnet CryptoX deep-link schemes.
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add parseDID/formatDID helpers for every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through them; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the mainnet CryptoX deep-link schemes.
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add parseDID/formatDID helpers for every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through them; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the mainnet CryptoX deep-link schemes.
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add parseDID/formatDID helpers for every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through them; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the mainnet CryptoX deep-link schemes.
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add a ConcordiumDID class covering every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through it; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the mainnet CryptoX deep-link schemes.
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add a ConcordiumDID class covering every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through it; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the CryptoX deep-link schemes (mainnet, and Android testnet).
andynelson
added a commit
to Concordium/concordium-node-sdk-js
that referenced
this pull request
Nov 12, 2026
Bump concordium-base to main (Concordium/concordium-base#986), which accepts did:ccd:<genesis hash prefix>:..., and adopt it across the SDK packages. Existing DIDs, chain IDs and stored settings are unchanged; the genesis form is opt-in. - sdk: widen Network to 'Testnet' | 'Mainnet' | GenesisHashPrefix.Type; add the GenesisHashPrefix module and network helpers (chain IDs, chain equality, key derivation: mainnet derives as Mainnet, every other network as Testnet); add a ConcordiumDID class covering every Concordium DID type and route the DID classes, create*DID helpers and credential metadata parsing through it; compare networks by chain when verifying. - wallet-connectors: opt-in chainIdFormat: 'genesis' / withGenesisChainId for ccd:<genesis hash prefix> chain IDs. - verification-web-ui: accept a custom network ({ chainId, walletDeepLinks }), resolve the network in one place, and fix the CryptoX deep-link schemes (mainnet, and Android testnet).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Chain IDs can already name a Concordium network in two ways,
ccd:testnetorccd:<first 32 hex chars of the genesis hash>. DIDs only accepttestnet/mainnet, so a network without a well-known name can't appear in a DID at all.This PR lets the network segment of every DID type (
acc,cred,sci,pkc,idp,encidcred) be a genesis hash prefix, for exampledid:ccd:4221332d34e1694168c2a0c0b3fd0f27:idp:0. Any 32-character lowercase hex prefix is accepted; there is no registry.Changes
web3id::did: addGenesisHashPrefix(withTESTNET/MAINNETconstants andfrom_genesis_hash) and aNetwork::Genesis(GenesisHashPrefix)variant, plusNetwork::genesis_hash_prefixandNetwork::same_chain.Networkequality, ordering and hashing compare the chain the value refers to. SoNetwork::Testnet == Network::Genesis(GenesisHashPrefix::TESTNET), and the existing network checks in verification (verify_network, the issuer match) accept either form with no call-site changes. ForTestnet/Mainneton their own, behaviour is identical to before; ordering is stillTestnet < Mainnet.testnet/mainnetkeep their string, JSON and binary (tags0/1) encodings, so existing proofs, requests and anchors hash and verify exactly as before. The genesis form is written as the 32 hex characters, or as binary tag2followed by the 16 prefix bytes.Effect on code that matches on
NetworkNetworkgains aGenesisvariant and is marked#[non_exhaustive]. Code outside this crate that matches onNetworkvariant by variant, like this:will no longer compile and needs a wildcard arm (
_ => …). Because of#[non_exhaustive], any future network forms won't require that again.Code that only passes
Networkvalues around or compares them (==,!=) is unaffected. Comparisons now match by chain, so they accept either form automatically. I found no variant-by-variant matches in this repo, in the JS SDK's Rust bindings, or in concordium-rust-sdk, which only passes the value through and compares it. So I don't expect this to affect anyone in practice and haven't proposed a version bump; the CHANGELOG entry describes the change for anyone who does match on it.Compatibility notes
Wallets, verifiers and indexers on an older concordium-base will reject
did:ccd:<prefix>DIDs and binary tag2. The genesis form should therefore be adopted per integration once counterparties have upgraded, not used as a default.Testing
cargo test --workspace --all-featurespasses. Existing test vectors are unchanged.did.rs: string/JSON round trips for every form, binary encodings (including that tags 0/1 are byte-for-byte unchanged), chain equality includingHashSetlookups, every DID type with a genesis prefix, and rejection of malformed prefixes.v1/anchor/verify.rs: a presentation proved withtestnetDIDs verifies against a verification context given as the testnet genesis prefix, and fails against a different chain.Related
A companion PR in concordium-node-sdk-js adopts this in the JS SDK, wallet-connectors and verification-web-ui. It depends on this PR and will be opened as a draft.