Skip to content

feat(primitives): add Chain::Midnight and its epsilon derivation - #1075

Open
Pessina wants to merge 6 commits into
developfrom
feat/midnight-chain-identity
Open

feat(primitives): add Chain::Midnight and its epsilon derivation#1075
Pessina wants to merge 6 commits into
developfrom
feat/midnight-chain-identity

Conversation

@Pessina

@Pessina Pessina commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Carves Chain::Midnight and derive_epsilon_midnight out of #1059 so the one change in that stack that touches a wire format is reviewed on its own rather than inside a 7.5k-line diff. Adds the enum variant, the KDF wrapper and its re-export, the per-chain config arms, and epsilon plus sender_string routing on both bidirectional extension traits. The rest of #1059 rebases on top once this lands.

The chain id is midnight:mainnet. It is a chain-level constant here, not a per-environment one: Chain::Ethereum is eip155:1 while tests run against 31337, and NEAR and Solana pin mainnet the same way. It is also the most stable of the candidates. Midnight has no registered CAIP-2 namespace at all (MIP-0008 proposes midnight but is still Draft, with the reference format undecided), and its illustrative registry keeps midnight:mainnet while flagging midnight:testnet as pending a core decision on whether testnet stays distinct from preprod and preview.

Follow-up required before anything derives keys against this: @sig-net/midnight still exports MIDNIGHT_TESTNET_CHAIN_ID = "midnight:testnet" as the default third argument of deriveEpsilon. The golden fixture here passes the chain id explicitly so its values stay anchored to that package, but the constant in midnight-integration has to move with this commit or integrators calling the default will derive different addresses than the node does.

@Pessina
Pessina marked this pull request as ready for review July 28, 2026 14:58
@Pessina
Pessina requested review from ChaoticTempest, isSerge and ppca and removed request for isSerge July 28, 2026 15:13
Comment thread signet-primitives/src/chain.rs Outdated
// ChainAgnostic/namespaces. "canton:global" follows the
// namespace:reference format as a project-local identifier.
Chain::Canton => "canton:global",
Chain::Midnight => "midnight:testnet",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So midnight doesn't have a caip id either or is testnet actually expected for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have a draft proposal for the caip2id: https://github.com/midnightntwrk/midnight-improvement-proposals/blob/main/mips/mip-0008-caip-2-network-identifiers.md

I would say we can use midnight:mainnet for now (per #1075 (comment), cc @ppca)

Later when they settle we update it. Anyways we won't go live on mainnet before they release the new ledger version (expected to be released end of September)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: dca1a5e

Comment thread signet-primitives/src/chain.rs Outdated
Chain::Bitcoin => "bip122:000000000019d6689c085ae165831e93",
Chain::Hydration => "polkadot:2034",
Chain::Canton => "canton:global",
Chain::Midnight => "midnight:testnet",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MPC only uses caip2_id for the mainnet of the network, it does not differentiate testnet and mainnet because one node will only connect to either testnet or mainnet at the same time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions

Copy link
Copy Markdown

⚠️ Integration tests were re-run (attempt 2)

@Pessina
Pessina force-pushed the feat/midnight-chain-identity branch from dca1a5e to c6ea68a Compare July 31, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants