@ocap/mcrypto 1.31.8 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/esm/bridge-governance/evm-abi.d.mts +179 -0
  2. package/esm/bridge-governance/evm-abi.mjs +344 -0
  3. package/esm/bridge-governance/evm-proposals.d.mts +39 -0
  4. package/esm/bridge-governance/evm-proposals.mjs +345 -0
  5. package/esm/bridge-governance/evm-sync.d.mts +45 -0
  6. package/esm/bridge-governance/evm-sync.mjs +120 -0
  7. package/esm/bridge-governance/index.d.mts +8 -0
  8. package/esm/bridge-governance/index.mjs +9 -0
  9. package/esm/bridge-governance/keys.d.mts +60 -0
  10. package/esm/bridge-governance/keys.mjs +224 -0
  11. package/esm/bridge-governance/membership.d.mts +116 -0
  12. package/esm/bridge-governance/membership.mjs +175 -0
  13. package/esm/bridge-governance/ocap-proposals.d.mts +132 -0
  14. package/esm/bridge-governance/ocap-proposals.mjs +481 -0
  15. package/esm/bridge-governance/strict-json.d.mts +8 -0
  16. package/esm/bridge-governance/strict-json.mjs +102 -0
  17. package/esm/bridge-governance.d.mts +9 -116
  18. package/esm/bridge-governance.mjs +8 -174
  19. package/esm/envelope.mjs +28 -1
  20. package/esm/index.d.mts +10 -2
  21. package/esm/index.mjs +8 -2
  22. package/esm/signer/ethereum.mjs +2 -2
  23. package/esm/signer/secp256k1.d.mts +5 -0
  24. package/esm/signer/secp256k1.mjs +18 -0
  25. package/lib/_vendor/@noble/hashes/utils.cjs +19 -1
  26. package/lib/bridge-governance/evm-abi.cjs +362 -0
  27. package/lib/bridge-governance/evm-abi.d.cts +179 -0
  28. package/lib/bridge-governance/evm-proposals.cjs +353 -0
  29. package/lib/bridge-governance/evm-proposals.d.cts +39 -0
  30. package/lib/bridge-governance/evm-sync.cjs +130 -0
  31. package/lib/bridge-governance/evm-sync.d.cts +45 -0
  32. package/lib/bridge-governance/index.cjs +129 -0
  33. package/lib/bridge-governance/index.d.cts +8 -0
  34. package/lib/bridge-governance/keys.cjs +273 -0
  35. package/lib/bridge-governance/keys.d.cts +60 -0
  36. package/lib/bridge-governance/membership.cjs +195 -0
  37. package/lib/bridge-governance/membership.d.cts +116 -0
  38. package/lib/bridge-governance/ocap-proposals.cjs +491 -0
  39. package/lib/bridge-governance/ocap-proposals.d.cts +132 -0
  40. package/lib/bridge-governance/strict-json.cjs +103 -0
  41. package/lib/bridge-governance/strict-json.d.cts +8 -0
  42. package/lib/bridge-governance.cjs +128 -194
  43. package/lib/bridge-governance.d.cts +8 -116
  44. package/lib/envelope.cjs +28 -1
  45. package/lib/index.cjs +128 -21
  46. package/lib/index.d.cts +9 -2
  47. package/lib/signer/secp256k1.cjs +18 -0
  48. package/lib/signer/secp256k1.d.cts +5 -0
  49. package/package.json +2 -2
@@ -1,116 +1,9 @@
1
- import { BytesType } from "@ocap/util";
2
-
3
- //#region src/bridge-governance.d.ts
4
-
5
- /**
6
- * EIP-712 structs the on-chain bridge governance (bridge/docs/ocap-protocols.md §v2.2) verifies on the OCAP side:
7
- * `BridgeMembership` (operator consent / join / leave) and `BridgeOwnerAttestation` (Ethereum owner proof).
8
- *
9
- * This is a port of `membership.ts` in `@arcblock/bridge-types` (bridge/types/src/membership.ts). Core packages cannot
10
- * depend on the private bridge workspace, so the logic is duplicated on purpose and a parity test
11
- * (core/mcrypto/tests/bridge-governance.spec.ts) runs this port against the vector file
12
- * bridge/types/vectors/membership.json, which is generated from viem (what wallets run). Change both together.
13
- *
14
- * Domain: `{ name: "ArcBridgeOcap", version: "1" }` with NO chainId / verifyingContract; the OCAP chain and the bridge
15
- * are carried inside the struct (`ocapChainId`, `bridge`), so an approval cannot be replayed across chains or bridges.
16
- */
17
- declare const BRIDGE_GOV_DOMAIN_NAME = "ArcBridgeOcap";
18
- declare const BRIDGE_GOV_DOMAIN_VERSION = "1";
19
- declare const BRIDGE_MEMBERSHIP_TYPE_STRING = "BridgeMembership(string ocapChainId,string bridge,uint64 epoch,address[] validators,uint32 threshold,uint64 activeFrom,uint64 voucherValidity,bytes32 endpointsHash,uint8 action)";
20
- declare const BRIDGE_OWNER_ATTESTATION_TYPE_STRING = "BridgeOwnerAttestation(string ocapChainId,bytes32 salt,string ocapToken,uint256 ethChainId,address gateway,address ethToken)";
21
- /** `action` of a BridgeMembership: CREATE = epoch 1 consent, JOIN / LEAVE = epoch change. */
22
- declare const BRIDGE_MEMBERSHIP_ACTION: {
23
- readonly CREATE: 0;
24
- readonly JOIN: 1;
25
- readonly LEAVE: 2;
26
- };
27
- interface BridgeMembershipMessage {
28
- ocapChainId: string;
29
- bridge: string;
30
- epoch: bigint | number | string;
31
- /** Strictly ascending (numeric) and unique: the signer signs exactly this order. */
32
- validators: string[];
33
- threshold: number;
34
- activeFrom: bigint | number | string;
35
- voucherValidity: bigint | number | string;
36
- /** `computeBridgeEndpointsHash` of the endpoints of `validators`, in the same order */
37
- endpointsHash: string;
38
- action: number;
39
- }
40
- interface BridgeOwnerAttestationMessage {
41
- ocapChainId: string;
42
- salt: string;
43
- ocapToken: string;
44
- ethChainId: bigint | number | string;
45
- gateway: string;
46
- ethToken: string;
47
- }
48
- /**
49
- * `keccak256(keccak256(endpoint_0) || keccak256(endpoint_1) || ...)` over the endpoints of the validators in the order
50
- * of the signed `validators` array. It binds every listed operator to the URL it is reachable at, so a creator cannot
51
- * pair a victim operator with another URL.
52
- */
53
- declare function computeBridgeEndpointsHash(endpoints: string[]): string;
54
- declare function computeBridgeMembershipDigest(m: BridgeMembershipMessage): Uint8Array;
55
- declare function computeBridgeOwnerAttestationDigest(m: BridgeOwnerAttestationMessage): Uint8Array;
56
- /** Ethereum address (lowercase 0x) of an uncompressed (64/65 bytes) or compressed secp256k1 public key. */
57
- declare function ethAddressOfPublicKey(pk: BytesType): string;
58
- interface RecoveredBridgeSigner {
59
- /** lowercase 0x address */
60
- address: string;
61
- /** 65-byte uncompressed public key, 0x04 prefixed */
62
- publicKey: Uint8Array;
63
- }
64
- /**
65
- * Recover the signer of a canonical 65-byte `r || s || v` signature (`v` in {27, 28}, low-S). Returns null on anything
66
- * else, so a malleable or malformed signature never recovers to an address.
67
- */
68
- declare function recoverBridgeSigner(digest: Uint8Array, signature: string): RecoveredBridgeSigner | null;
69
- /** Sign a governance digest with a secp256k1 secret key; returns the 65-byte `0x{r}{s}{v}` signature. */
70
- declare function signBridgeDigest(digest: Uint8Array, sk: BytesType): string;
71
- declare const toHexDigest: (digest: Uint8Array) => string;
72
- type BridgeKeyPart = {
73
- uint: bigint | number | string;
74
- } | {
75
- address: string;
76
- } | {
77
- bytes32: string;
78
- } | {
79
- text: string;
80
- };
81
- /**
82
- * keccak256 of `utf8(prefix) || words`: the key preimage helper for the `arc-bridge:*` evidence keys. Every dynamic part
83
- * is a fixed-width word (uint256 / address / bytes32) or the trailing DID string, so two different tuples never share a
84
- * preimage. Returns a `0x` + 64 hex string (the evidence table key shape).
85
- */
86
- declare function bridgeEvidenceKey(prefix: string, parts: BridgeKeyPart[]): string;
87
- /**
88
- * Evidence keys of a bridge release (`deposit_token_v2` kind 1/2/3) are SELF-IDENTIFYING: a 3-character tag (`rt:` tombstone, `rb:` bucket) and the
89
- * first 63 hex digits of the keccak digest of the `bridgeEvidenceKey` preimage, 66 characters in total.
90
- *
91
- * Legacy rollup v1 protocols store evidence rows at a caller-chosen key validated only by `patterns.txHash`
92
- * (`^(0x)?[0-9a-fA-F]{64}$`). `r` and `:` are not hex digits, so no key a v1 tx (or any other `txHash`-validated input) can
93
- * carry ever lands in this key space, and the gate can tell a release row by its key alone. 66 characters is exactly the
94
- * width of a `0x` + 64 hex key, so every statedb backend that stores today's evidence keys stores these. The `:` also
95
- * keeps the key from ever parsing as a DID (base58 has no `:`). 252 bits of keccak keep collision resistance at 2^126.
96
- */
97
- declare const BRIDGE_RELEASE_TOMBSTONE_TAG = "rt:";
98
- declare const BRIDGE_RELEASE_BUCKET_TAG = "rb:";
99
- /** a canonical release key: tag + 63 lowercase hex */
100
- declare const BRIDGE_RELEASE_KEY_PATTERN: RegExp;
101
- /**
102
- * Tombstone key of a release: `rt:` + keccak256("arc-bridge:release:" || uint kind || bytes32 evidence || uint ordinal ||
103
- * bridge). `evidence` is a `0x` bytes32 (lowercased here); `bridge` the canonical bridge address.
104
- */
105
- declare function bridgeReleaseTombstoneKey(bridge: string, kind: number | bigint | string, evidence: string, ordinal: number | bigint | string): string;
106
- /** Key of slot `slot` of ring `ring` (0 = deposit, 1 = refund) of `bridge`: `rb:` + keccak256("arc-bridge:release-bucket:" || uint ring || uint slot || bridge). */
107
- declare function bridgeReleaseBucketKey(bridge: string, ring: number, slot: number): string;
108
- /** Whether `key` is a canonical release key (tombstone or bucket). */
109
- declare const isBridgeReleaseKey: (key: unknown) => boolean;
110
- /**
111
- * Whether `key` is in the release key space in ANY spelling (case, surrounding whitespace): what the gate refuses to any
112
- * tx type but a bridge release.
113
- */
114
- declare const inBridgeReleaseKeySpace: (key: unknown) => boolean;
115
- //#endregion
116
- export { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest };
1
+ import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance/membership.mjs";
2
+ import { BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeGovDocKey, bridgeGovIndexKey, canonicalJson, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, ethAddressFromUncompressedPk, inBridgeGovKeySpace, isBridgeGovKey, normalizeUncompressedSecp256k1Pk, parseDecimalBigInt, sortStrictChecksumAddresses, toJsonSafeValue, utf8ByteLength } from "./bridge-governance/keys.mjs";
3
+ import { parseStrictJson } from "./bridge-governance/strict-json.mjs";
4
+ import { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, CertRequest, EvmDeployment, EvmGatewayParams, EvmWithdrawVoucher, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, GovernanceCert, GovernedAction, GovernedContract, SECP256K1_HALF_N, SECP256K1_N, assertDistinctDeploymentAddresses, buildGovernanceCert, computeGovernanceCertDigest, computeWithdrawVoucherDigest, defaultCertExpiresAt, normalizeEcdsaSignature, orderGovernanceSignatures, paramsHashOf, recoverGovernanceCertSigner, selectorOf, signGovernanceCert, signerManagerFor, validateGovernedRequest } from "./bridge-governance/evm-abi.mjs";
5
+ import { BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BridgeEvmGovernanceSyncMessage, EvmGovernanceRosterConfig, EvmSignerManagerRoster, bridgeEvmGovernanceSyncDigest, computeBridgeEvmGovernanceSyncDigest, computeEvmGovernanceConfigHash, parseEvmGovernanceRosterConfig, recoverBridgeEvmGovernanceSyncSigner, serializeEvmGovernanceRosterConfig, signBridgeEvmGovernanceSync, validateEvmGovernanceRosterConfig } from "./bridge-governance/evm-sync.mjs";
6
+ import { EvmGovernanceProposal, ExpectedEvmProposalContext, RefundContext, buildCertFromProposal, certRequestFromProposal, claimLargeCertExpiresAt, coerceEvmProposal, computeEvmProposalHash, parseEvmProposal, serializeEvmProposal, validateEvmProposal, verifyProposalMatchesCert } from "./bridge-governance/evm-proposals.mjs";
7
+ import { ArcBlockTransactionEnvelopeFields, OcapGovernanceProposal, OcapGovernedAction, OcapMultiSigLockstep, OcapProposeOwner, OcapRollupPatch, OcapSignerRosterEntry, OcapSingleSignerMetadata, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeOcapProposalId, formatArcBlockTxEip191Text, membershipFromOcapProposal, parseOcapProposal, recoverArcBlockTxEnvelopeSigner, recoverOcapMembershipProposalSigner, serializeOcapProposal, validateOcapProposal } from "./bridge-governance/ocap-proposals.mjs";
8
+ import "./bridge-governance/index.mjs";
9
+ export { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, ArcBlockTransactionEnvelopeFields, BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeEvmGovernanceSyncMessage, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, CertRequest, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, EvmDeployment, EvmGatewayParams, EvmGovernanceProposal, EvmGovernanceRosterConfig, EvmSignerManagerRoster, EvmWithdrawVoucher, ExpectedEvmProposalContext, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, GovernanceCert, GovernedAction, GovernedContract, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, OcapGovernanceProposal, OcapGovernedAction, OcapMultiSigLockstep, OcapProposeOwner, OcapRollupPatch, OcapSignerRosterEntry, OcapSingleSignerMetadata, RecoveredBridgeSigner, RefundContext, SECP256K1_HALF_N, SECP256K1_N, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertDistinctDeploymentAddresses, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeEvidenceKey, bridgeEvmGovernanceSyncDigest, bridgeGovDocKey, bridgeGovIndexKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildCertFromProposal, buildGovernanceCert, canonicalJson, certRequestFromProposal, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, claimLargeCertExpiresAt, coerceEvmProposal, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeBridgeEndpointsHash, computeBridgeEvmGovernanceSyncDigest, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEvmGovernanceConfigHash, computeEvmProposalHash, computeGovernanceCertDigest, computeOcapProposalId, computeWithdrawVoucherDigest, defaultCertExpiresAt, ethAddressFromUncompressedPk, ethAddressOfPublicKey, formatArcBlockTxEip191Text, inBridgeGovKeySpace, inBridgeReleaseKeySpace, isBridgeGovKey, isBridgeReleaseKey, membershipFromOcapProposal, normalizeEcdsaSignature, normalizeUncompressedSecp256k1Pk, orderGovernanceSignatures, paramsHashOf, parseDecimalBigInt, parseEvmGovernanceRosterConfig, parseEvmProposal, parseOcapProposal, parseStrictJson, recoverArcBlockTxEnvelopeSigner, recoverBridgeEvmGovernanceSyncSigner, recoverBridgeSigner, recoverGovernanceCertSigner, recoverOcapMembershipProposalSigner, selectorOf, serializeEvmGovernanceRosterConfig, serializeEvmProposal, serializeOcapProposal, signBridgeDigest, signBridgeEvmGovernanceSync, signGovernanceCert, signerManagerFor, sortStrictChecksumAddresses, toHexDigest, toJsonSafeValue, utf8ByteLength, validateEvmGovernanceRosterConfig, validateEvmProposal, validateGovernedRequest, validateOcapProposal, verifyProposalMatchesCert };
@@ -1,175 +1,9 @@
1
- import { secp256k1 } from "@noble/curves/secp256k1.js";
2
- import { keccak_256 } from "@noble/hashes/sha3.js";
3
- import { bytesToHex } from "@noble/hashes/utils.js";
4
- import { toUint8Array } from "@ocap/util";
1
+ import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance/membership.mjs";
2
+ import { BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeGovDocKey, bridgeGovIndexKey, canonicalJson, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, ethAddressFromUncompressedPk, inBridgeGovKeySpace, isBridgeGovKey, normalizeUncompressedSecp256k1Pk, parseDecimalBigInt, sortStrictChecksumAddresses, toJsonSafeValue, utf8ByteLength } from "./bridge-governance/keys.mjs";
3
+ import { parseStrictJson } from "./bridge-governance/strict-json.mjs";
4
+ import { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, SECP256K1_HALF_N, SECP256K1_N, assertDistinctDeploymentAddresses, buildGovernanceCert, computeGovernanceCertDigest, computeWithdrawVoucherDigest, defaultCertExpiresAt, normalizeEcdsaSignature, orderGovernanceSignatures, paramsHashOf, recoverGovernanceCertSigner, selectorOf, signGovernanceCert, signerManagerFor, validateGovernedRequest } from "./bridge-governance/evm-abi.mjs";
5
+ import { BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, bridgeEvmGovernanceSyncDigest, computeBridgeEvmGovernanceSyncDigest, computeEvmGovernanceConfigHash, parseEvmGovernanceRosterConfig, recoverBridgeEvmGovernanceSyncSigner, serializeEvmGovernanceRosterConfig, signBridgeEvmGovernanceSync, validateEvmGovernanceRosterConfig } from "./bridge-governance/evm-sync.mjs";
6
+ import { buildCertFromProposal, certRequestFromProposal, claimLargeCertExpiresAt, coerceEvmProposal, computeEvmProposalHash, parseEvmProposal, serializeEvmProposal, validateEvmProposal, verifyProposalMatchesCert } from "./bridge-governance/evm-proposals.mjs";
7
+ import { coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeOcapProposalId, formatArcBlockTxEip191Text, membershipFromOcapProposal, parseOcapProposal, recoverArcBlockTxEnvelopeSigner, recoverOcapMembershipProposalSigner, serializeOcapProposal, validateOcapProposal } from "./bridge-governance/ocap-proposals.mjs";
5
8
 
6
- //#region src/bridge-governance.ts
7
- /**
8
- * EIP-712 structs the on-chain bridge governance (bridge/docs/ocap-protocols.md §v2.2) verifies on the OCAP side:
9
- * `BridgeMembership` (operator consent / join / leave) and `BridgeOwnerAttestation` (Ethereum owner proof).
10
- *
11
- * This is a port of `membership.ts` in `@arcblock/bridge-types` (bridge/types/src/membership.ts). Core packages cannot
12
- * depend on the private bridge workspace, so the logic is duplicated on purpose and a parity test
13
- * (core/mcrypto/tests/bridge-governance.spec.ts) runs this port against the vector file
14
- * bridge/types/vectors/membership.json, which is generated from viem (what wallets run). Change both together.
15
- *
16
- * Domain: `{ name: "ArcBridgeOcap", version: "1" }` with NO chainId / verifyingContract; the OCAP chain and the bridge
17
- * are carried inside the struct (`ocapChainId`, `bridge`), so an approval cannot be replayed across chains or bridges.
18
- */
19
- const BRIDGE_GOV_DOMAIN_NAME = "ArcBridgeOcap";
20
- const BRIDGE_GOV_DOMAIN_VERSION = "1";
21
- const BRIDGE_MEMBERSHIP_TYPE_STRING = "BridgeMembership(string ocapChainId,string bridge,uint64 epoch,address[] validators,uint32 threshold,uint64 activeFrom,uint64 voucherValidity,bytes32 endpointsHash,uint8 action)";
22
- const BRIDGE_OWNER_ATTESTATION_TYPE_STRING = "BridgeOwnerAttestation(string ocapChainId,bytes32 salt,string ocapToken,uint256 ethChainId,address gateway,address ethToken)";
23
- /** `action` of a BridgeMembership: CREATE = epoch 1 consent, JOIN / LEAVE = epoch change. */
24
- const BRIDGE_MEMBERSHIP_ACTION = {
25
- CREATE: 0,
26
- JOIN: 1,
27
- LEAVE: 2
28
- };
29
- const utf8 = (s) => new Uint8Array(Buffer.from(s, "utf8"));
30
- const keccakUtf8 = (s) => keccak_256(utf8(s));
31
- const concat = (...parts) => new Uint8Array(Buffer.concat(parts));
32
- const DOMAIN_TYPEHASH = keccakUtf8("EIP712Domain(string name,string version)");
33
- const MEMBERSHIP_TYPEHASH = keccakUtf8(BRIDGE_MEMBERSHIP_TYPE_STRING);
34
- const ATTESTATION_TYPEHASH = keccakUtf8(BRIDGE_OWNER_ATTESTATION_TYPE_STRING);
35
- const DOMAIN_SEPARATOR = keccak_256(concat(DOMAIN_TYPEHASH, keccakUtf8(BRIDGE_GOV_DOMAIN_NAME), keccakUtf8(BRIDGE_GOV_DOMAIN_VERSION)));
36
- function uintWord(value, bits, name) {
37
- let n;
38
- try {
39
- n = typeof value === "bigint" ? value : BigInt(value);
40
- } catch {
41
- throw new Error(`${name} is not an integer`);
42
- }
43
- if (n < 0n || n >= 1n << BigInt(bits)) throw new Error(`${name} does not fit uint${bits}`);
44
- return new Uint8Array(Buffer.from(n.toString(16).padStart(64, "0"), "hex"));
45
- }
46
- function addressWord(value, name) {
47
- if (typeof value !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(value)) throw new Error(`${name} is not an address`);
48
- return new Uint8Array(Buffer.from(value.slice(2).toLowerCase().padStart(64, "0"), "hex"));
49
- }
50
- function bytes32Word(value, name) {
51
- if (typeof value !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(value)) throw new Error(`${name} is not a bytes32`);
52
- return new Uint8Array(Buffer.from(value.slice(2), "hex"));
53
- }
54
- function digestOf(structHash) {
55
- return keccak_256(concat(new Uint8Array([25, 1]), DOMAIN_SEPARATOR, structHash));
56
- }
57
- /**
58
- * `keccak256(keccak256(endpoint_0) || keccak256(endpoint_1) || ...)` over the endpoints of the validators in the order
59
- * of the signed `validators` array. It binds every listed operator to the URL it is reachable at, so a creator cannot
60
- * pair a victim operator with another URL.
61
- */
62
- function computeBridgeEndpointsHash(endpoints) {
63
- if (!Array.isArray(endpoints)) throw new Error("endpoints is not an array");
64
- return `0x${bytesToHex(keccak_256(concat(...endpoints.map((e) => keccakUtf8(String(e))))))}`;
65
- }
66
- function computeBridgeMembershipDigest(m) {
67
- if (!Array.isArray(m.validators)) throw new Error("validators is not an array");
68
- const validators = keccak_256(concat(...m.validators.map((a, i) => addressWord(a, `validators[${i}]`))));
69
- return digestOf(keccak_256(concat(MEMBERSHIP_TYPEHASH, keccakUtf8(m.ocapChainId), keccakUtf8(m.bridge), uintWord(m.epoch, 64, "epoch"), validators, uintWord(m.threshold, 32, "threshold"), uintWord(m.activeFrom, 64, "activeFrom"), uintWord(m.voucherValidity, 64, "voucherValidity"), bytes32Word(m.endpointsHash, "endpointsHash"), uintWord(m.action, 8, "action"))));
70
- }
71
- function computeBridgeOwnerAttestationDigest(m) {
72
- return digestOf(keccak_256(concat(ATTESTATION_TYPEHASH, keccakUtf8(m.ocapChainId), bytes32Word(m.salt, "salt"), keccakUtf8(m.ocapToken), uintWord(m.ethChainId, 256, "ethChainId"), addressWord(m.gateway, "gateway"), addressWord(m.ethToken, "ethToken"))));
73
- }
74
- /** Ethereum address (lowercase 0x) of an uncompressed (64/65 bytes) or compressed secp256k1 public key. */
75
- function ethAddressOfPublicKey(pk) {
76
- const bytes = toUint8Array(pk);
77
- return `0x${bytesToHex(keccak_256(bytes.byteLength === 64 ? bytes : bytes.byteLength === 65 ? bytes.slice(1) : secp256k1.Point.fromBytes(bytes).toBytes(false).slice(1)).slice(12))}`;
78
- }
79
- /**
80
- * Recover the signer of a canonical 65-byte `r || s || v` signature (`v` in {27, 28}, low-S). Returns null on anything
81
- * else, so a malleable or malformed signature never recovers to an address.
82
- */
83
- function recoverBridgeSigner(digest, signature) {
84
- if (typeof signature !== "string" || !/^0x[0-9a-fA-F]{130}$/.test(signature)) return null;
85
- const hex = signature.slice(2);
86
- const v = Number.parseInt(hex.slice(128, 130), 16);
87
- if (v !== 27 && v !== 28) return null;
88
- try {
89
- const sig = secp256k1.Signature.fromHex(hex.slice(0, 128), "compact").addRecoveryBit(v - 27);
90
- if (sig.hasHighS()) return null;
91
- const publicKey = sig.recoverPublicKey(digest).toBytes(false);
92
- return {
93
- address: ethAddressOfPublicKey(publicKey),
94
- publicKey
95
- };
96
- } catch {
97
- return null;
98
- }
99
- }
100
- /** Sign a governance digest with a secp256k1 secret key; returns the 65-byte `0x{r}{s}{v}` signature. */
101
- function signBridgeDigest(digest, sk) {
102
- const recovered = secp256k1.sign(digest, toUint8Array(sk), {
103
- prehash: false,
104
- format: "recovered"
105
- });
106
- const sig = secp256k1.Signature.fromBytes(recovered, "recovered");
107
- const v = (27 + sig.recovery).toString(16).padStart(2, "0");
108
- return `0x${sig.toHex("compact")}${v}`;
109
- }
110
- const toHexDigest = (digest) => `0x${bytesToHex(digest)}`;
111
- /**
112
- * keccak256 of `utf8(prefix) || words`: the key preimage helper for the `arc-bridge:*` evidence keys. Every dynamic part
113
- * is a fixed-width word (uint256 / address / bytes32) or the trailing DID string, so two different tuples never share a
114
- * preimage. Returns a `0x` + 64 hex string (the evidence table key shape).
115
- */
116
- function bridgeEvidenceKey(prefix, parts) {
117
- const chunks = [utf8(prefix)];
118
- parts.forEach((p, i) => {
119
- if ("uint" in p) chunks.push(uintWord(p.uint, 256, `part[${i}]`));
120
- else if ("address" in p) chunks.push(addressWord(p.address, `part[${i}]`));
121
- else if ("bytes32" in p) chunks.push(bytes32Word(p.bytes32, `part[${i}]`));
122
- else {
123
- if (i !== parts.length - 1) throw new Error("text part must be last");
124
- chunks.push(utf8(p.text));
125
- }
126
- });
127
- return `0x${bytesToHex(keccak_256(concat(...chunks)))}`;
128
- }
129
- /**
130
- * Evidence keys of a bridge release (`deposit_token_v2` kind 1/2/3) are SELF-IDENTIFYING: a 3-character tag (`rt:` tombstone, `rb:` bucket) and the
131
- * first 63 hex digits of the keccak digest of the `bridgeEvidenceKey` preimage, 66 characters in total.
132
- *
133
- * Legacy rollup v1 protocols store evidence rows at a caller-chosen key validated only by `patterns.txHash`
134
- * (`^(0x)?[0-9a-fA-F]{64}$`). `r` and `:` are not hex digits, so no key a v1 tx (or any other `txHash`-validated input) can
135
- * carry ever lands in this key space, and the gate can tell a release row by its key alone. 66 characters is exactly the
136
- * width of a `0x` + 64 hex key, so every statedb backend that stores today's evidence keys stores these. The `:` also
137
- * keeps the key from ever parsing as a DID (base58 has no `:`). 252 bits of keccak keep collision resistance at 2^126.
138
- */
139
- const BRIDGE_RELEASE_TOMBSTONE_TAG = "rt:";
140
- const BRIDGE_RELEASE_BUCKET_TAG = "rb:";
141
- const RELEASE_TOMBSTONE_DOMAIN = "arc-bridge:release:";
142
- const RELEASE_BUCKET_DOMAIN = "arc-bridge:release-bucket:";
143
- /** a canonical release key: tag + 63 lowercase hex */
144
- const BRIDGE_RELEASE_KEY_PATTERN = /^r[tb]:[0-9a-f]{63}$/;
145
- const releaseKey = (tag, domain, parts) => `${tag}${bridgeEvidenceKey(domain, parts).slice(2, 65)}`;
146
- /**
147
- * Tombstone key of a release: `rt:` + keccak256("arc-bridge:release:" || uint kind || bytes32 evidence || uint ordinal ||
148
- * bridge). `evidence` is a `0x` bytes32 (lowercased here); `bridge` the canonical bridge address.
149
- */
150
- function bridgeReleaseTombstoneKey(bridge, kind, evidence, ordinal) {
151
- return releaseKey(BRIDGE_RELEASE_TOMBSTONE_TAG, RELEASE_TOMBSTONE_DOMAIN, [
152
- { uint: kind },
153
- { bytes32: String(evidence).toLowerCase() },
154
- { uint: ordinal },
155
- { text: bridge }
156
- ]);
157
- }
158
- /** Key of slot `slot` of ring `ring` (0 = deposit, 1 = refund) of `bridge`: `rb:` + keccak256("arc-bridge:release-bucket:" || uint ring || uint slot || bridge). */
159
- function bridgeReleaseBucketKey(bridge, ring, slot) {
160
- return releaseKey(BRIDGE_RELEASE_BUCKET_TAG, RELEASE_BUCKET_DOMAIN, [
161
- { uint: ring },
162
- { uint: slot },
163
- { text: bridge }
164
- ]);
165
- }
166
- /** Whether `key` is a canonical release key (tombstone or bucket). */
167
- const isBridgeReleaseKey = (key) => typeof key === "string" && BRIDGE_RELEASE_KEY_PATTERN.test(key);
168
- /**
169
- * Whether `key` is in the release key space in ANY spelling (case, surrounding whitespace): what the gate refuses to any
170
- * tx type but a bridge release.
171
- */
172
- const inBridgeReleaseKeySpace = (key) => typeof key === "string" && /^r[tb]:/i.test(key.trim());
173
-
174
- //#endregion
175
- export { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest };
9
+ export { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, SECP256K1_HALF_N, SECP256K1_N, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertDistinctDeploymentAddresses, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeEvidenceKey, bridgeEvmGovernanceSyncDigest, bridgeGovDocKey, bridgeGovIndexKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildCertFromProposal, buildGovernanceCert, canonicalJson, certRequestFromProposal, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, claimLargeCertExpiresAt, coerceEvmProposal, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeBridgeEndpointsHash, computeBridgeEvmGovernanceSyncDigest, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEvmGovernanceConfigHash, computeEvmProposalHash, computeGovernanceCertDigest, computeOcapProposalId, computeWithdrawVoucherDigest, defaultCertExpiresAt, ethAddressFromUncompressedPk, ethAddressOfPublicKey, formatArcBlockTxEip191Text, inBridgeGovKeySpace, inBridgeReleaseKeySpace, isBridgeGovKey, isBridgeReleaseKey, membershipFromOcapProposal, normalizeEcdsaSignature, normalizeUncompressedSecp256k1Pk, orderGovernanceSignatures, paramsHashOf, parseDecimalBigInt, parseEvmGovernanceRosterConfig, parseEvmProposal, parseOcapProposal, parseStrictJson, recoverArcBlockTxEnvelopeSigner, recoverBridgeEvmGovernanceSyncSigner, recoverBridgeSigner, recoverGovernanceCertSigner, recoverOcapMembershipProposalSigner, selectorOf, serializeEvmGovernanceRosterConfig, serializeEvmProposal, serializeOcapProposal, signBridgeDigest, signBridgeEvmGovernanceSync, signGovernanceCert, signerManagerFor, sortStrictChecksumAddresses, toHexDigest, toJsonSafeValue, utf8ByteLength, validateEvmGovernanceRosterConfig, validateEvmProposal, validateGovernedRequest, validateOcapProposal, verifyProposalMatchesCert };
package/esm/envelope.mjs CHANGED
@@ -137,6 +137,13 @@ const WITHDRAW_FIELDS = [
137
137
  ];
138
138
  /** The one tx type an `ArcBridgeWithdraw` envelope may name. */
139
139
  const BRIDGE_WITHDRAW_ACTION = "withdraw_token_v2";
140
+ const ROLLUP_GOVERNANCE_ACTIONS = new Set([
141
+ "pause_rollup",
142
+ "resume_rollup",
143
+ "close_rollup",
144
+ "update_rollup",
145
+ "migrate_rollup"
146
+ ]);
140
147
  const DECIMAL_AMOUNT = /^(0|[1-9][0-9]{0,77})$/;
141
148
  function hasAnyWithdrawField(meta) {
142
149
  return WITHDRAW_FIELDS.some((f) => meta[f] !== void 0);
@@ -199,12 +206,32 @@ function assertEnvelopeMatchesTxContext(extra, expected) {
199
206
  if (parsed.token !== withdraw.token) throw new Error(`Envelope token "${parsed.token}" does not match transaction token "${withdraw.token}"`);
200
207
  if (String(parsed.ethRecipient).toLowerCase() !== String(withdraw.ethRecipient).toLowerCase()) throw new Error(`Envelope ethRecipient "${parsed.ethRecipient}" does not match transaction recipient "${withdraw.ethRecipient}"`);
201
208
  } else if (hasAnyWithdrawField(parsed)) throw new Error("Envelope carries bridge withdraw fields but the transaction is not a bridge withdraw");
209
+ const normalizedExpectedAction = typeof expected.action === "string" ? expected.action.replace(/^fg:t:/, "") : "";
210
+ const normalizedParsedAction = typeof parsed.action === "string" ? parsed.action.replace(/^fg:t:/, "") : "";
211
+ if ((ROLLUP_GOVERNANCE_ACTIONS.has(normalizedExpectedAction) || ROLLUP_GOVERNANCE_ACTIONS.has(normalizedParsedAction)) && ETHEREUM_ENVELOPES.has(parsed.envelope)) {
212
+ if (!normalizedExpectedAction) throw new Error("Rollup governance envelope requires expected.action in transaction context");
213
+ if (parsed.domainName !== void 0 && parsed.domainName !== EIP712_ENVELOPE_DEFAULT_DOMAIN.name || parsed.domainVersion !== void 0 && parsed.domainVersion !== EIP712_ENVELOPE_DEFAULT_DOMAIN.version) throw new Error(`Rollup governance envelope domain must be ${EIP712_ENVELOPE_DEFAULT_DOMAIN.name} / ${EIP712_ENVELOPE_DEFAULT_DOMAIN.version}`);
214
+ for (const field of [
215
+ "chainId",
216
+ "from",
217
+ "nonce",
218
+ "action"
219
+ ]) if (parsed[field] === void 0 || parsed[field].trim() === "") throw new Error(`Rollup governance envelope is missing "${field}"`);
220
+ if (!expected.chainId || !(expected.signer || expected.from) || expected.nonce === void 0 || String(expected.nonce) === "") throw new Error("Rollup governance envelope requires non-empty chainId, signer/from, and nonce in transaction context");
221
+ }
202
222
  if (parsed.chainId !== void 0 && expected.chainId !== void 0 && expected.chainId !== "") {
203
223
  if (parsed.chainId !== expected.chainId) throw new Error(`Envelope chainId "${parsed.chainId}" does not match transaction chainId "${expected.chainId}"`);
204
224
  }
205
225
  if (parsed.from !== void 0) {
206
226
  const allowedSigners = [expected.signer, expected.from].filter((v) => typeof v === "string" && v.length > 0);
207
- if (allowedSigners.length > 0 && !allowedSigners.includes(parsed.from)) throw new Error(`Envelope signer "${parsed.from}" does not match transaction signer "${allowedSigners[0]}"`);
227
+ const parsedEthFrom = parseStrictEthAddress(parsed.from);
228
+ const matchesSigner = allowedSigners.some((candidate) => {
229
+ if (candidate === parsed.from) return true;
230
+ if (!parsedEthFrom.ok) return false;
231
+ const candidateEth = parseStrictEthAddress(candidate);
232
+ return candidateEth.ok && candidateEth.lowercase === parsedEthFrom.lowercase;
233
+ });
234
+ if (allowedSigners.length > 0 && !matchesSigner) throw new Error(`Envelope signer "${parsed.from}" does not match transaction signer "${allowedSigners[0]}"`);
208
235
  }
209
236
  if (parsed.nonce !== void 0 && expected.nonce !== void 0 && String(expected.nonce) !== "") {
210
237
  if (parsed.nonce !== String(expected.nonce)) throw new Error(`Envelope nonce "${parsed.nonce}" does not match transaction nonce "${String(expected.nonce)}"`);
package/esm/index.d.mts CHANGED
@@ -1,4 +1,11 @@
1
- import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance.mjs";
1
+ import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance/membership.mjs";
2
+ import { BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeGovDocKey, bridgeGovIndexKey, canonicalJson, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, ethAddressFromUncompressedPk, inBridgeGovKeySpace, isBridgeGovKey, normalizeUncompressedSecp256k1Pk, parseDecimalBigInt, sortStrictChecksumAddresses, toJsonSafeValue, utf8ByteLength } from "./bridge-governance/keys.mjs";
3
+ import { parseStrictJson } from "./bridge-governance/strict-json.mjs";
4
+ import { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, CertRequest, EvmDeployment, EvmGatewayParams, EvmWithdrawVoucher, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, GovernanceCert, GovernedAction, GovernedContract, SECP256K1_HALF_N, SECP256K1_N, assertDistinctDeploymentAddresses, buildGovernanceCert, computeGovernanceCertDigest, computeWithdrawVoucherDigest, defaultCertExpiresAt, normalizeEcdsaSignature, orderGovernanceSignatures, paramsHashOf, recoverGovernanceCertSigner, selectorOf, signGovernanceCert, signerManagerFor, validateGovernedRequest } from "./bridge-governance/evm-abi.mjs";
5
+ import { BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BridgeEvmGovernanceSyncMessage, EvmGovernanceRosterConfig, EvmSignerManagerRoster, bridgeEvmGovernanceSyncDigest, computeBridgeEvmGovernanceSyncDigest, computeEvmGovernanceConfigHash, parseEvmGovernanceRosterConfig, recoverBridgeEvmGovernanceSyncSigner, serializeEvmGovernanceRosterConfig, signBridgeEvmGovernanceSync, validateEvmGovernanceRosterConfig } from "./bridge-governance/evm-sync.mjs";
6
+ import { EvmGovernanceProposal, ExpectedEvmProposalContext, RefundContext, buildCertFromProposal, certRequestFromProposal, claimLargeCertExpiresAt, coerceEvmProposal, computeEvmProposalHash, parseEvmProposal, serializeEvmProposal, validateEvmProposal, verifyProposalMatchesCert } from "./bridge-governance/evm-proposals.mjs";
7
+ import { ArcBlockTransactionEnvelopeFields, OcapGovernanceProposal, OcapGovernedAction, OcapMultiSigLockstep, OcapProposeOwner, OcapRollupPatch, OcapSignerRosterEntry, OcapSingleSignerMetadata, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeOcapProposalId, formatArcBlockTxEip191Text, membershipFromOcapProposal, parseOcapProposal, recoverArcBlockTxEnvelopeSigner, recoverOcapMembershipProposalSigner, serializeOcapProposal, validateOcapProposal } from "./bridge-governance/ocap-proposals.mjs";
8
+ import "./bridge-governance.mjs";
2
9
  import { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope } from "./envelope.mjs";
3
10
  import { StrictEthAddressFailure, StrictEthAddressResult, isStrictEthAddress, parseStrictEthAddress } from "./eth-address.mjs";
4
11
  import { KeccakHasher } from "./hasher/keccak.mjs";
@@ -44,6 +51,7 @@ interface SignerType {
44
51
  sign(data: BytesType, sk: BytesType, encoding?: EncodingType): BytesType;
45
52
  /** extra is JSON string for passkey signer containing {authenticatorData, clientDataJSON} */
46
53
  verify(data: BytesType, signature: BytesType, pk: BytesType, extra?: string): boolean;
54
+ toUncompressedPublicKey?(pk: BytesType): Uint8Array | null;
47
55
  ethHash?(data: string): string;
48
56
  ethSign?(data: string, sk: string): string;
49
57
  ethVerify?(data: string, pk: string, signature: BytesType): boolean;
@@ -243,4 +251,4 @@ declare function getRandomBytes(length: number, encoding?: 'Uint8Array'): Uint8A
243
251
  declare function getRandomBytes(length: number, encoding?: EncodingType): BytesType;
244
252
  declare const toTxHash: (buf: Buffer | Uint8Array) => string;
245
253
  //#endregion
246
- export { AddressType, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, ExpectedEnvelopeTxContext, HashFnType, HashType, Hasher, KeyType, RecoveredBridgeSigner, RoleType, Signer, SignerType, StrictEthAddressFailure, StrictEthAddressResult, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports as envelope, ethAddressOfPublicKey, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, inBridgeReleaseKeySpace, isBridgeReleaseKey, isCanonicalWalletEnvelopeExtra, isStrictEthAddress, normalizeChallengeHex, parseStrictEthAddress, parseWalletEnvelopeExtra, recoverBridgeSigner, signBridgeDigest, signEthereumEnvelope, toHexDigest, toTxHash, types, verifyEthereumEnvelope, webauthn_d_exports as webauthn };
254
+ export { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, AddressType, ArcBlockTransactionEnvelopeFields, BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, BridgeEvmGovernanceSyncMessage, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, CertRequest, EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, EvmDeployment, EvmGatewayParams, EvmGovernanceProposal, EvmGovernanceRosterConfig, EvmSignerManagerRoster, EvmWithdrawVoucher, ExpectedEnvelopeTxContext, ExpectedEvmProposalContext, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, GovernanceCert, GovernedAction, GovernedContract, HashFnType, HashType, Hasher, KeyType, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, OcapGovernanceProposal, OcapGovernedAction, OcapMultiSigLockstep, OcapProposeOwner, OcapRollupPatch, OcapSignerRosterEntry, OcapSingleSignerMetadata, RecoveredBridgeSigner, RefundContext, RoleType, SECP256K1_HALF_N, SECP256K1_N, Signer, SignerType, StrictEthAddressFailure, StrictEthAddressResult, WalletEnvelopeExtra, WalletEnvelopeType, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertDistinctDeploymentAddresses, assertEnvelopeMatchesTxContext, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeEvidenceKey, bridgeEvmGovernanceSyncDigest, bridgeGovDocKey, bridgeGovIndexKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildBridgeWithdrawEnvelopeExtra, buildCertFromProposal, buildEd25519EnvelopePayload, buildGovernanceCert, buildSolanaOffchainEnvelopeBytes, canonicalJson, certRequestFromProposal, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, claimLargeCertExpiresAt, coerceEvmProposal, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeBridgeEndpointsHash, computeBridgeEvmGovernanceSyncDigest, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, computeEvmGovernanceConfigHash, computeEvmProposalHash, computeGovernanceCertDigest, computeOcapProposalId, computeWithdrawVoucherDigest, defaultCertExpiresAt, envelope_d_exports as envelope, ethAddressFromUncompressedPk, ethAddressOfPublicKey, formatArcBlockTxEip191Text, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, inBridgeGovKeySpace, inBridgeReleaseKeySpace, isBridgeGovKey, isBridgeReleaseKey, isCanonicalWalletEnvelopeExtra, isStrictEthAddress, membershipFromOcapProposal, normalizeChallengeHex, normalizeEcdsaSignature, normalizeUncompressedSecp256k1Pk, orderGovernanceSignatures, paramsHashOf, parseDecimalBigInt, parseEvmGovernanceRosterConfig, parseEvmProposal, parseOcapProposal, parseStrictEthAddress, parseStrictJson, parseWalletEnvelopeExtra, recoverArcBlockTxEnvelopeSigner, recoverBridgeEvmGovernanceSyncSigner, recoverBridgeSigner, recoverGovernanceCertSigner, recoverOcapMembershipProposalSigner, selectorOf, serializeEvmGovernanceRosterConfig, serializeEvmProposal, serializeOcapProposal, signBridgeDigest, signBridgeEvmGovernanceSync, signEthereumEnvelope, signGovernanceCert, signerManagerFor, sortStrictChecksumAddresses, toHexDigest, toJsonSafeValue, toTxHash, types, utf8ByteLength, validateEvmGovernanceRosterConfig, validateEvmProposal, validateGovernedRequest, validateOcapProposal, verifyEthereumEnvelope, verifyProposalMatchesCert, webauthn_d_exports as webauthn };
package/esm/index.mjs CHANGED
@@ -1,4 +1,10 @@
1
- import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance.mjs";
1
+ import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, inBridgeReleaseKeySpace, isBridgeReleaseKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance/membership.mjs";
2
+ import { BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeGovDocKey, bridgeGovIndexKey, canonicalJson, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, ethAddressFromUncompressedPk, inBridgeGovKeySpace, isBridgeGovKey, normalizeUncompressedSecp256k1Pk, parseDecimalBigInt, sortStrictChecksumAddresses, toJsonSafeValue, utf8ByteLength } from "./bridge-governance/keys.mjs";
3
+ import { parseStrictJson } from "./bridge-governance/strict-json.mjs";
4
+ import { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, SECP256K1_HALF_N, SECP256K1_N, assertDistinctDeploymentAddresses, buildGovernanceCert, computeGovernanceCertDigest, computeWithdrawVoucherDigest, defaultCertExpiresAt, normalizeEcdsaSignature, orderGovernanceSignatures, paramsHashOf, recoverGovernanceCertSigner, selectorOf, signGovernanceCert, signerManagerFor, validateGovernedRequest } from "./bridge-governance/evm-abi.mjs";
5
+ import { BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, bridgeEvmGovernanceSyncDigest, computeBridgeEvmGovernanceSyncDigest, computeEvmGovernanceConfigHash, parseEvmGovernanceRosterConfig, recoverBridgeEvmGovernanceSyncSigner, serializeEvmGovernanceRosterConfig, signBridgeEvmGovernanceSync, validateEvmGovernanceRosterConfig } from "./bridge-governance/evm-sync.mjs";
6
+ import { buildCertFromProposal, certRequestFromProposal, claimLargeCertExpiresAt, coerceEvmProposal, computeEvmProposalHash, parseEvmProposal, serializeEvmProposal, validateEvmProposal, verifyProposalMatchesCert } from "./bridge-governance/evm-proposals.mjs";
7
+ import { coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeOcapProposalId, formatArcBlockTxEip191Text, membershipFromOcapProposal, parseOcapProposal, recoverArcBlockTxEnvelopeSigner, recoverOcapMembershipProposalSigner, serializeOcapProposal, validateOcapProposal } from "./bridge-governance/ocap-proposals.mjs";
2
8
  import { encode } from "./encode.mjs";
3
9
  import { isStrictEthAddress, parseStrictEthAddress } from "./eth-address.mjs";
4
10
  import { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope } from "./envelope.mjs";
@@ -186,4 +192,4 @@ function getRandomBytes(length = 32, encoding = "hex") {
186
192
  const toTxHash = (buf) => Hasher.SHA2.hash256(buf, 1, "hex").replace(/^0x/, "").toUpperCase();
187
193
 
188
194
  //#endregion
189
- export { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, Hasher, Signer, assertEnvelopeMatchesTxContext, bridgeEvidenceKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_exports as envelope, ethAddressOfPublicKey, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, inBridgeReleaseKeySpace, isBridgeReleaseKey, isCanonicalWalletEnvelopeExtra, isStrictEthAddress, normalizeChallengeHex, parseStrictEthAddress, parseWalletEnvelopeExtra, recoverBridgeSigner, signBridgeDigest, signEthereumEnvelope, toHexDigest, toTxHash, types, verifyEthereumEnvelope, webauthn_exports as webauthn };
195
+ export { ARC_BRIDGE_EIP712_NAME, ARC_BRIDGE_EIP712_VERSION, BRIDGE_EVM_GOV_SYNC_DOMAIN_NAME, BRIDGE_EVM_GOV_SYNC_DOMAIN_VERSION, BRIDGE_EVM_GOV_SYNC_TYPE_STRING, BRIDGE_GOV_DOC_TAG, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_GOV_INDEX_TAG, BRIDGE_GOV_KEY_PATTERN, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BRIDGE_RELEASE_BUCKET_TAG, BRIDGE_RELEASE_KEY_PATTERN, BRIDGE_RELEASE_TOMBSTONE_TAG, EIP712_BRIDGE_WITHDRAW_TYPE_STRING, EIP712_ENVELOPE_DEFAULT_DOMAIN, EVM_GOV_CONFIG_HASH_PREFIX, EVM_PROPOSAL_HASH_PREFIX, GOVERNANCE_CERT_TYPE_STRING, GOVERNED_FUNCTIONS, Hasher, MAX_EVM_GOV_ROSTER_JSON_BYTES, MAX_EVM_SIGNERS, MAX_GOV_DOC_JSON_BYTES, MAX_OCAP_DELAY_SEC, MAX_OCAP_PAUSERS, MAX_OCAP_VALIDATORS, MAX_PROPOSAL_JSON_BYTES, MAX_PROPOSAL_RATIONALE_URL_BYTES, MAX_PROPOSAL_SUMMARY_BYTES, MAX_PROPOSAL_TITLE_CHARS, MAX_SAFE_BIGINT, MAX_U256, MAX_U64, MIN_OCAP_VALIDATORS, OCAP_PROPOSAL_HASH_PREFIX, SECP256K1_HALF_N, SECP256K1_N, Signer, ZERO_ADDRESS, ZERO_BYTES32, assertAllowedKeys, assertBareBridgeDid, assertBigIntRange, assertBoundedPlainText, assertDistinctDeploymentAddresses, assertEnvelopeMatchesTxContext, assertHttpUrl, assertPlainObject, assertSafeChainId, assertSafeUint, assertTrimmedSingleLine, assertValidProposalTitle, assertValidRationaleUrl, assertWellFormedString, bridgeEvidenceKey, bridgeEvmGovernanceSyncDigest, bridgeGovDocKey, bridgeGovIndexKey, bridgeReleaseBucketKey, bridgeReleaseTombstoneKey, buildBridgeWithdrawEnvelopeExtra, buildCertFromProposal, buildEd25519EnvelopePayload, buildGovernanceCert, buildSolanaOffchainEnvelopeBytes, canonicalJson, certRequestFromProposal, checkedBytes32, checkedBytes4, checkedNonEmptyHex, checkedNonZeroAddress, checksumEthAddress, claimLargeCertExpiresAt, coerceEvmProposal, coerceOcapProposal, computeArcBlockTxEip191Digest, computeArcBlockTxEip712Digest, computeBridgeEndpointsHash, computeBridgeEvmGovernanceSyncDigest, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, computeEvmGovernanceConfigHash, computeEvmProposalHash, computeGovernanceCertDigest, computeOcapProposalId, computeWithdrawVoucherDigest, defaultCertExpiresAt, envelope_exports as envelope, ethAddressFromUncompressedPk, ethAddressOfPublicKey, formatArcBlockTxEip191Text, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, inBridgeGovKeySpace, inBridgeReleaseKeySpace, isBridgeGovKey, isBridgeReleaseKey, isCanonicalWalletEnvelopeExtra, isStrictEthAddress, membershipFromOcapProposal, normalizeChallengeHex, normalizeEcdsaSignature, normalizeUncompressedSecp256k1Pk, orderGovernanceSignatures, paramsHashOf, parseDecimalBigInt, parseEvmGovernanceRosterConfig, parseEvmProposal, parseOcapProposal, parseStrictEthAddress, parseStrictJson, parseWalletEnvelopeExtra, recoverArcBlockTxEnvelopeSigner, recoverBridgeEvmGovernanceSyncSigner, recoverBridgeSigner, recoverGovernanceCertSigner, recoverOcapMembershipProposalSigner, selectorOf, serializeEvmGovernanceRosterConfig, serializeEvmProposal, serializeOcapProposal, signBridgeDigest, signBridgeEvmGovernanceSync, signEthereumEnvelope, signGovernanceCert, signerManagerFor, sortStrictChecksumAddresses, toHexDigest, toJsonSafeValue, toTxHash, types, utf8ByteLength, validateEvmGovernanceRosterConfig, validateEvmProposal, validateGovernedRequest, validateOcapProposal, verifyEthereumEnvelope, verifyProposalMatchesCert, webauthn_exports as webauthn };
@@ -2,7 +2,7 @@ import { Secp256k1Signer } from "./secp256k1.mjs";
2
2
  import { secp256k1 } from "@noble/curves/secp256k1.js";
3
3
  import { keccak_256 } from "@noble/hashes/sha3.js";
4
4
  import { bytesToHex } from "@noble/hashes/utils.js";
5
- import { hexToBytes, isHexStrict, utf8ToHex } from "@ocap/util";
5
+ import { hexToBytes as hexToBytes$1, isHexStrict, utf8ToHex } from "@ocap/util";
6
6
 
7
7
  //#region src/signer/ethereum.ts
8
8
  function toChecksumAddress(address) {
@@ -23,7 +23,7 @@ var EthereumSigner = class extends Secp256k1Signer {
23
23
  this.pkHasFormatPrefix = false;
24
24
  }
25
25
  ethHash(data) {
26
- const messageBytes = hexToBytes(isHexStrict(data) ? data : utf8ToHex(data));
26
+ const messageBytes = hexToBytes$1(isHexStrict(data) ? data : utf8ToHex(data));
27
27
  const preamble = `\x19Ethereum Signed Message:\n${messageBytes.length}`;
28
28
  const ethMessage = Buffer.concat([Buffer.from(preamble), Buffer.from(messageBytes)]);
29
29
  return `0x${bytesToHex(keccak_256(new Uint8Array(ethMessage)))}`;
@@ -28,6 +28,11 @@ declare class Secp256k1Signer extends _default$1 {
28
28
  * Get publicKey from secretKey
29
29
  */
30
30
  getPublicKey(sk: BytesType, encoding?: EncodingType): BytesType;
31
+ /**
32
+ * Decompress / validate a secp256k1 public key (33B compressed, 65B 0x04 uncompressed, or 64B raw X||Y)
33
+ * into canonical 65-byte uncompressed form (`0x04 || X || Y`), or `null` if not a valid curve point.
34
+ */
35
+ toUncompressedPublicKey(pk: BytesType): Uint8Array | null;
31
36
  /**
32
37
  * Sign a message and get the signature hex
33
38
  */
@@ -54,6 +54,24 @@ var Secp256k1Signer = class extends signer_default {
54
54
  return encode(`0x${pk}`, encoding);
55
55
  }
56
56
  /**
57
+ * Decompress / validate a secp256k1 public key (33B compressed, 65B 0x04 uncompressed, or 64B raw X||Y)
58
+ * into canonical 65-byte uncompressed form (`0x04 || X || Y`), or `null` if not a valid curve point.
59
+ */
60
+ toUncompressedPublicKey(pk) {
61
+ try {
62
+ let pkBytes = toUint8Array(pk);
63
+ if (pkBytes.byteLength === 64) {
64
+ const prefixed = new Uint8Array(65);
65
+ prefixed[0] = 4;
66
+ prefixed.set(pkBytes, 1);
67
+ pkBytes = prefixed;
68
+ } else if (!(pkBytes.byteLength === 33 && (pkBytes[0] === 2 || pkBytes[0] === 3)) && !(pkBytes.byteLength === 65 && pkBytes[0] === 4)) return null;
69
+ return secp256k1.Point.fromBytes(pkBytes).toBytes(false);
70
+ } catch {
71
+ return null;
72
+ }
73
+ }
74
+ /**
57
75
  * Sign a message and get the signature hex
58
76
  */
59
77
  sign(message, sk, encoding = "hex") {
@@ -289,6 +289,23 @@ function hexToBytes(hex) {
289
289
  return array;
290
290
  }
291
291
  /**
292
+ * Converts string to bytes using UTF8 encoding.
293
+ * Built-in doesn't validate input to be string: we do the check.
294
+ * Non-ASCII details are delegated to the platform `TextEncoder`.
295
+ * @param str - string to encode
296
+ * @returns UTF-8 encoded bytes.
297
+ * @throws On wrong argument types. {@link TypeError}
298
+ * @example
299
+ * Encode a string as UTF-8 bytes.
300
+ * ```ts
301
+ * utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])
302
+ * ```
303
+ */
304
+ function utf8ToBytes(str) {
305
+ if (typeof str !== "string") throw new TypeError("string expected");
306
+ return new Uint8Array(new TextEncoder().encode(str));
307
+ }
308
+ /**
292
309
  * Copies several Uint8Arrays into one.
293
310
  * @param arrays - arrays to concatenate
294
311
  * @returns Concatenated byte array.
@@ -407,4 +424,5 @@ exports.oidNist = oidNist;
407
424
  exports.randomBytes = randomBytes;
408
425
  exports.rotr = rotr;
409
426
  exports.swap32IfBE = swap32IfBE;
410
- exports.u32 = u32;
427
+ exports.u32 = u32;
428
+ exports.utf8ToBytes = utf8ToBytes;