@ocap/mcrypto 1.31.1 → 1.31.2

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.
@@ -0,0 +1,88 @@
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
+ //#endregion
88
+ export { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, recoverBridgeSigner, signBridgeDigest, toHexDigest };
@@ -0,0 +1,131 @@
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";
5
+
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
+ //#endregion
131
+ export { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, bridgeEvidenceKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, recoverBridgeSigner, signBridgeDigest, toHexDigest };
@@ -2,7 +2,7 @@ import { BytesType } from "@ocap/util";
2
2
 
3
3
  //#region src/envelope.d.ts
4
4
  declare namespace envelope_d_exports {
5
- export { ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
5
+ export { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
6
6
  }
7
7
  type WalletEnvelopeType = 'eip191' | 'eip712' | 'solana-message' | 'solana-offchain';
8
8
  interface WalletEnvelopeExtra {
@@ -17,6 +17,14 @@ interface WalletEnvelopeExtra {
17
17
  applicationDomain?: string;
18
18
  messageFormat?: number;
19
19
  challenge?: string;
20
+ /**
21
+ * Bridge withdraw clear-signing fields (#1465). All four present selects the `ArcBridgeWithdraw` EIP-712 primary type
22
+ * (and adds Bridge/Amount/Token/Recipient lines to the EIP-191 text); partially present is invalid.
23
+ */
24
+ bridge?: string;
25
+ amount?: string;
26
+ token?: string;
27
+ ethRecipient?: string;
20
28
  }
21
29
  /**
22
30
  * Normalize a challenge input (hex string or bytes) into a canonical lowercase `0x`-prefixed hex string.
@@ -27,6 +35,25 @@ declare function normalizeChallengeHex(challenge: BytesType): string;
27
35
  * When `keyType` is provided (0 = ED25519, 1 = SECP256K1, 2 = ETHEREUM), also enforces curve compatibility.
28
36
  */
29
37
  declare function isCanonicalWalletEnvelopeExtra(extra: unknown, keyType?: number): boolean;
38
+ /**
39
+ * Build the `extra` object a wallet passes to `signEnvelope` for a bridge withdraw (#1465).
40
+ * `bridge` is the OCAP bridge (rollup) address whose reserve is `itx.to`, `amount` the decimal base-unit string, `token` the bridge token address, `ethRecipient` the Ethereum recipient
41
+ * exactly as written in `itx.data`.
42
+ */
43
+ declare function buildBridgeWithdrawEnvelopeExtra(input: {
44
+ envelope?: 'eip191' | 'eip712';
45
+ chainId: string;
46
+ from: string;
47
+ nonce: string | number | bigint;
48
+ bridge: string;
49
+ amount: string | number | bigint;
50
+ token: string;
51
+ ethRecipient: string;
52
+ action?: string;
53
+ domainName?: string;
54
+ domainVersion?: string;
55
+ statement?: string;
56
+ }): WalletEnvelopeExtra;
30
57
  declare function parseWalletEnvelopeExtra(extra: string, expectedKeyType?: number): WalletEnvelopeExtra;
31
58
  interface ExpectedEnvelopeTxContext {
32
59
  chainId?: string;
@@ -34,6 +61,17 @@ interface ExpectedEnvelopeTxContext {
34
61
  from?: string;
35
62
  nonce?: string | number | bigint;
36
63
  action?: string;
64
+ /**
65
+ * Decoded bridge withdraw (transfer_v2 into the reserve), or null/undefined for any other tx.
66
+ * When set, the envelope MUST carry matching `amount`, `token` and `ethRecipient` (absent = rejected).
67
+ * When not set, an envelope carrying any of those fields is rejected.
68
+ */
69
+ withdraw?: {
70
+ bridge: string;
71
+ amount: string;
72
+ token: string;
73
+ ethRecipient: string;
74
+ } | null;
37
75
  }
38
76
  /**
39
77
  * Verifies that any human-readable metadata field present in a signed wallet envelope
@@ -50,6 +88,8 @@ declare function formatWalletEnvelopeText(challenge: BytesType, meta?: Partial<W
50
88
  * Compute the EIP-191 (`personal_sign`) 32-byte keccak256 digest over the canonical envelope text.
51
89
  */
52
90
  declare function computeEip191EnvelopeDigest(challenge: BytesType, meta?: Partial<WalletEnvelopeExtra>): Uint8Array;
91
+ /** Primary type for the bridge withdraw clear-signing envelope (bridge/docs/ocap-protocols.md §2). */
92
+ declare const EIP712_BRIDGE_WITHDRAW_TYPE_STRING = "ArcBridgeWithdraw(string chainId,string from,string nonce,string bridge,string amount,string token,address ethRecipient,string challenge)";
53
93
  /**
54
94
  * Compute the EIP-712 (`eth_signTypedData_v4`) 32-byte digest for an ArcBlockTransaction envelope.
55
95
  */
@@ -73,4 +113,4 @@ declare function verifyEthereumEnvelope(challenge: BytesType, signature: BytesTy
73
113
  */
74
114
  declare function buildEd25519EnvelopePayload(challenge: BytesType, pk: BytesType, extra: string): Uint8Array;
75
115
  //#endregion
76
- export { ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
116
+ export { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
package/esm/envelope.mjs CHANGED
@@ -1,12 +1,15 @@
1
1
  import { __exportAll } from "./_virtual/rolldown_runtime.mjs";
2
- import { toHex, toUint8Array } from "@ocap/util";
2
+ import { parseStrictEthAddress } from "./eth-address.mjs";
3
3
  import { secp256k1 } from "@noble/curves/secp256k1.js";
4
4
  import { keccak_256 } from "@noble/hashes/sha3.js";
5
5
  import { bytesToHex } from "@noble/hashes/utils.js";
6
+ import { toHex, toUint8Array } from "@ocap/util";
6
7
 
7
8
  //#region src/envelope.ts
8
9
  var envelope_exports = /* @__PURE__ */ __exportAll({
10
+ EIP712_BRIDGE_WITHDRAW_TYPE_STRING: () => EIP712_BRIDGE_WITHDRAW_TYPE_STRING,
9
11
  assertEnvelopeMatchesTxContext: () => assertEnvelopeMatchesTxContext,
12
+ buildBridgeWithdrawEnvelopeExtra: () => buildBridgeWithdrawEnvelopeExtra,
10
13
  buildEd25519EnvelopePayload: () => buildEd25519EnvelopePayload,
11
14
  buildSolanaOffchainEnvelopeBytes: () => buildSolanaOffchainEnvelopeBytes,
12
15
  computeEip191EnvelopeDigest: () => computeEip191EnvelopeDigest,
@@ -39,7 +42,11 @@ const ALLOWED_ENVELOPE_KEYS = new Set([
39
42
  "domainVersion",
40
43
  "applicationDomain",
41
44
  "messageFormat",
42
- "challenge"
45
+ "challenge",
46
+ "bridge",
47
+ "amount",
48
+ "token",
49
+ "ethRecipient"
43
50
  ]);
44
51
  const SOLANA_OFFCHAIN_SIGNING_DOMAIN = new Uint8Array([
45
52
  255,
@@ -103,12 +110,51 @@ function isCanonicalWalletEnvelopeExtra(extra, keyType) {
103
110
  "applicationDomain",
104
111
  "challenge"
105
112
  ]) if (parsed[field] !== void 0 && !isSafeSingleLine(parsed[field])) return false;
113
+ if (hasAnyWithdrawField(parsed)) {
114
+ if (!ETHEREUM_ENVELOPES.has(envelope) || !isWithdrawFieldSetValid(parsed)) return false;
115
+ }
106
116
  if (parsed.messageFormat !== void 0 && parsed.messageFormat !== 0 && parsed.messageFormat !== 1 && parsed.messageFormat !== 2) return false;
107
117
  return true;
108
118
  } catch {
109
119
  return false;
110
120
  }
111
121
  }
122
+ const WITHDRAW_FIELDS = [
123
+ "bridge",
124
+ "amount",
125
+ "token",
126
+ "ethRecipient"
127
+ ];
128
+ const DECIMAL_AMOUNT = /^(0|[1-9][0-9]{0,77})$/;
129
+ function hasAnyWithdrawField(meta) {
130
+ return WITHDRAW_FIELDS.some((f) => meta[f] !== void 0);
131
+ }
132
+ function isWithdrawFieldSetValid(meta) {
133
+ return isSafeSingleLine(meta.bridge) && meta.bridge.length > 0 && typeof meta.amount === "string" && DECIMAL_AMOUNT.test(meta.amount) && isSafeSingleLine(meta.token) && meta.token.length > 0 && parseStrictEthAddress(meta.ethRecipient).ok;
134
+ }
135
+ /**
136
+ * Build the `extra` object a wallet passes to `signEnvelope` for a bridge withdraw (#1465).
137
+ * `bridge` is the OCAP bridge (rollup) address whose reserve is `itx.to`, `amount` the decimal base-unit string, `token` the bridge token address, `ethRecipient` the Ethereum recipient
138
+ * exactly as written in `itx.data`.
139
+ */
140
+ function buildBridgeWithdrawEnvelopeExtra(input) {
141
+ const extra = {
142
+ envelope: input.envelope || "eip712",
143
+ chainId: input.chainId,
144
+ action: input.action || "transfer_v2",
145
+ from: input.from,
146
+ nonce: String(input.nonce),
147
+ bridge: input.bridge,
148
+ amount: String(input.amount),
149
+ token: input.token,
150
+ ethRecipient: input.ethRecipient
151
+ };
152
+ if (input.domainName) extra.domainName = input.domainName;
153
+ if (input.domainVersion) extra.domainVersion = input.domainVersion;
154
+ if (input.statement) extra.statement = input.statement;
155
+ if (!isWithdrawFieldSetValid(extra)) throw new Error("Invalid bridge withdraw envelope fields");
156
+ return extra;
157
+ }
112
158
  function parseWalletEnvelopeExtra(extra, expectedKeyType) {
113
159
  if (!isCanonicalWalletEnvelopeExtra(extra, expectedKeyType)) throw new Error("Invalid or non-canonical wallet signature envelope extra");
114
160
  return JSON.parse(extra);
@@ -120,6 +166,21 @@ function parseWalletEnvelopeExtra(extra, expectedKeyType) {
120
166
  */
121
167
  function assertEnvelopeMatchesTxContext(extra, expected) {
122
168
  const parsed = typeof extra === "string" ? parseWalletEnvelopeExtra(extra) : extra;
169
+ const withdraw = expected.withdraw;
170
+ if (withdraw) {
171
+ if (!hasAnyWithdrawField(parsed) || !isWithdrawFieldSetValid(parsed)) throw new Error("Bridge withdraw requires an envelope carrying bridge, amount, token and ethRecipient");
172
+ if (!ETHEREUM_ENVELOPES.has(parsed.envelope)) throw new Error("Bridge withdraw requires an Ethereum envelope");
173
+ for (const field of [
174
+ "chainId",
175
+ "from",
176
+ "nonce"
177
+ ]) if (parsed[field] === void 0 || parsed[field] === "") throw new Error(`Bridge withdraw envelope is missing "${field}"`);
178
+ if (parsed.action !== "transfer_v2" && parsed.action !== "fg:t:transfer_v2") throw new Error(`Bridge withdraw envelope action must be transfer_v2, got "${parsed.action ?? ""}"`);
179
+ if (parsed.bridge !== withdraw.bridge) throw new Error(`Envelope bridge "${parsed.bridge}" does not match transaction bridge "${withdraw.bridge}"`);
180
+ if (parsed.amount !== withdraw.amount) throw new Error(`Envelope amount "${parsed.amount}" does not match transaction amount "${withdraw.amount}"`);
181
+ if (parsed.token !== withdraw.token) throw new Error(`Envelope token "${parsed.token}" does not match transaction token "${withdraw.token}"`);
182
+ if (String(parsed.ethRecipient).toLowerCase() !== String(withdraw.ethRecipient).toLowerCase()) throw new Error(`Envelope ethRecipient "${parsed.ethRecipient}" does not match transaction recipient "${withdraw.ethRecipient}"`);
183
+ } else if (hasAnyWithdrawField(parsed)) throw new Error("Envelope carries bridge withdraw fields but the transaction is not a bridge withdraw");
123
184
  if (parsed.chainId !== void 0 && expected.chainId !== void 0 && expected.chainId !== "") {
124
185
  if (parsed.chainId !== expected.chainId) throw new Error(`Envelope chainId "${parsed.chainId}" does not match transaction chainId "${expected.chainId}"`);
125
186
  }
@@ -142,19 +203,28 @@ function assertEnvelopeMatchesTxContext(extra, expected) {
142
203
  function formatWalletEnvelopeText(challenge, meta = {}) {
143
204
  const challengeHex = normalizeChallengeHex(challenge);
144
205
  if (meta.challenge !== void 0 && normalizeChallengeHex(meta.challenge) !== challengeHex) throw new Error("challenge mismatch in wallet signature envelope");
145
- for (const field of [
206
+ const optionalStringFields = [
146
207
  "statement",
147
208
  "chainId",
148
209
  "action",
149
210
  "from",
150
- "nonce"
151
- ]) if (meta[field] !== void 0 && !isSafeSingleLine(meta[field])) throw new Error(`Invalid character in wallet envelope field "${field}"`);
211
+ "nonce",
212
+ ...WITHDRAW_FIELDS
213
+ ];
214
+ for (const field of optionalStringFields) if (meta[field] !== void 0 && !isSafeSingleLine(meta[field])) throw new Error(`Invalid character in wallet envelope field "${field}"`);
215
+ if (hasAnyWithdrawField(meta) && !isWithdrawFieldSetValid(meta)) throw new Error("Invalid bridge withdraw envelope fields");
152
216
  const lines = ["ArcBlock Transaction v1"];
153
217
  if (meta.statement) lines.push(`Statement: ${meta.statement}`);
154
218
  if (meta.chainId) lines.push(`Chain: ${meta.chainId}`);
155
219
  if (meta.action) lines.push(`Action: ${meta.action}`);
156
220
  if (meta.from) lines.push(`Signer: ${meta.from}`);
157
221
  if (meta.nonce) lines.push(`Nonce: ${meta.nonce}`);
222
+ if (hasAnyWithdrawField(meta)) {
223
+ lines.push(`Bridge: ${meta.bridge}`);
224
+ lines.push(`Amount: ${meta.amount}`);
225
+ lines.push(`Token: ${meta.token}`);
226
+ lines.push(`Recipient: ${meta.ethRecipient}`);
227
+ }
158
228
  lines.push(`Challenge: ${challengeHex}`);
159
229
  return lines.join("\n");
160
230
  }
@@ -169,6 +239,9 @@ function computeEip191EnvelopeDigest(challenge, meta = {}) {
169
239
  }
170
240
  const EIP712_DOMAIN_TYPEHASH = keccak_256(new Uint8Array(Buffer.from("EIP712Domain(string name,string version)", "utf8")));
171
241
  const EIP712_TX_TYPEHASH = keccak_256(new Uint8Array(Buffer.from("ArcBlockTransaction(string chainId,string action,string from,string nonce,string challenge)", "utf8")));
242
+ /** Primary type for the bridge withdraw clear-signing envelope (bridge/docs/ocap-protocols.md §2). */
243
+ const EIP712_BRIDGE_WITHDRAW_TYPE_STRING = "ArcBridgeWithdraw(string chainId,string from,string nonce,string bridge,string amount,string token,address ethRecipient,string challenge)";
244
+ const EIP712_BRIDGE_WITHDRAW_TYPEHASH = keccak_256(new Uint8Array(Buffer.from(EIP712_BRIDGE_WITHDRAW_TYPE_STRING, "utf8")));
172
245
  function keccakUtf8(value) {
173
246
  return keccak_256(new Uint8Array(Buffer.from(value, "utf8")));
174
247
  }
@@ -178,14 +251,16 @@ function keccakUtf8(value) {
178
251
  function computeEip712EnvelopeDigest(challenge, meta = {}) {
179
252
  const challengeHex = normalizeChallengeHex(challenge);
180
253
  if (meta.challenge !== void 0 && normalizeChallengeHex(meta.challenge) !== challengeHex) throw new Error("challenge mismatch in wallet signature envelope");
181
- for (const field of [
254
+ const fields = [
182
255
  "chainId",
183
256
  "action",
184
257
  "from",
185
258
  "nonce",
186
259
  "domainName",
187
- "domainVersion"
188
- ]) if (meta[field] !== void 0 && !isSafeSingleLine(meta[field])) throw new Error(`Invalid character in wallet envelope field "${field}"`);
260
+ "domainVersion",
261
+ ...WITHDRAW_FIELDS
262
+ ];
263
+ for (const field of fields) if (meta[field] !== void 0 && !isSafeSingleLine(meta[field])) throw new Error(`Invalid character in wallet envelope field "${field}"`);
189
264
  const domainName = meta.domainName || "ArcBlock";
190
265
  const domainVersion = meta.domainVersion || "1";
191
266
  const chainId = meta.chainId || "arcblock";
@@ -197,6 +272,27 @@ function computeEip712EnvelopeDigest(challenge, meta = {}) {
197
272
  keccakUtf8(domainName),
198
273
  keccakUtf8(domainVersion)
199
274
  ])));
275
+ if (hasAnyWithdrawField(meta)) {
276
+ if (!isWithdrawFieldSetValid(meta)) throw new Error("Invalid bridge withdraw envelope fields");
277
+ const recipient = parseStrictEthAddress(meta.ethRecipient);
278
+ if (!recipient.ok) throw new Error("Invalid bridge withdraw envelope fields");
279
+ const withdrawHash = keccak_256(new Uint8Array(Buffer.concat([
280
+ EIP712_BRIDGE_WITHDRAW_TYPEHASH,
281
+ keccakUtf8(chainId),
282
+ keccakUtf8(from),
283
+ keccakUtf8(nonce),
284
+ keccakUtf8(meta.bridge),
285
+ keccakUtf8(meta.amount),
286
+ keccakUtf8(meta.token),
287
+ Buffer.concat([Buffer.alloc(12), Buffer.from(recipient.lowercase.slice(2), "hex")]),
288
+ keccakUtf8(challengeHex)
289
+ ])));
290
+ return keccak_256(new Uint8Array(Buffer.concat([
291
+ Buffer.from([25, 1]),
292
+ domainSeparator,
293
+ withdrawHash
294
+ ])));
295
+ }
200
296
  const structHash = keccak_256(new Uint8Array(Buffer.concat([
201
297
  EIP712_TX_TYPEHASH,
202
298
  keccakUtf8(chainId),
@@ -303,4 +399,4 @@ function buildEd25519EnvelopePayload(challenge, pk, extra) {
303
399
  }
304
400
 
305
401
  //#endregion
306
- export { assertEnvelopeMatchesTxContext, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
402
+ export { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope };
@@ -0,0 +1,27 @@
1
+ //#region src/eth-address.d.ts
2
+ /**
3
+ * Strict Ethereum address parser for the OCAP bridge (bridge/docs/ocap-protocols.md §6).
4
+ *
5
+ * This is a port of `parseStrictEthAddress` in `@arcblock/bridge-types` (bridge/types/src/address.ts). Core packages
6
+ * cannot depend on the private bridge workspace, so the logic is duplicated on purpose and a parity test in
7
+ * bridge/types runs both implementations against the same vector file (bridge/types/vectors/eth-address.json).
8
+ * Change both together.
9
+ *
10
+ * Rules:
11
+ * - exactly `0x` + 40 hex digits, no whitespace, no `0X` prefix;
12
+ * - letters all lowercase: accepted; letters all uppercase: rejected; mixed case: must satisfy EIP-55;
13
+ * - the zero address is rejected.
14
+ */
15
+ type StrictEthAddressFailure = 'not-a-string' | 'format' | 'uppercase' | 'checksum' | 'zero-address';
16
+ type StrictEthAddressResult = {
17
+ ok: true;
18
+ address: string;
19
+ lowercase: string;
20
+ } | {
21
+ ok: false;
22
+ reason: StrictEthAddressFailure;
23
+ };
24
+ declare function parseStrictEthAddress(value: unknown): StrictEthAddressResult;
25
+ declare function isStrictEthAddress(value: unknown): value is string;
26
+ //#endregion
27
+ export { StrictEthAddressFailure, StrictEthAddressResult, isStrictEthAddress, parseStrictEthAddress };
@@ -0,0 +1,51 @@
1
+ import { keccak_256 } from "@noble/hashes/sha3.js";
2
+ import { bytesToHex } from "@noble/hashes/utils.js";
3
+
4
+ //#region src/eth-address.ts
5
+ const FORMAT = /^0x[0-9a-fA-F]{40}$/;
6
+ function eip55(bodyLower) {
7
+ const hash = bytesToHex(keccak_256(new Uint8Array(Buffer.from(bodyLower, "ascii"))));
8
+ let out = "";
9
+ for (let i = 0; i < 40; i++) {
10
+ const ch = bodyLower[i];
11
+ out += Number.parseInt(hash[i], 16) >= 8 ? ch.toUpperCase() : ch;
12
+ }
13
+ return out;
14
+ }
15
+ function parseStrictEthAddress(value) {
16
+ if (typeof value !== "string") return {
17
+ ok: false,
18
+ reason: "not-a-string"
19
+ };
20
+ if (!FORMAT.test(value)) return {
21
+ ok: false,
22
+ reason: "format"
23
+ };
24
+ const body = value.slice(2);
25
+ const lower = body.toLowerCase();
26
+ const hasLower = /[a-f]/.test(body);
27
+ const hasUpper = /[A-F]/.test(body);
28
+ if (hasUpper && !hasLower) return {
29
+ ok: false,
30
+ reason: "uppercase"
31
+ };
32
+ if (hasUpper && hasLower && eip55(lower) !== body) return {
33
+ ok: false,
34
+ reason: "checksum"
35
+ };
36
+ if (/^0+$/.test(lower)) return {
37
+ ok: false,
38
+ reason: "zero-address"
39
+ };
40
+ return {
41
+ ok: true,
42
+ address: value,
43
+ lowercase: `0x${lower}`
44
+ };
45
+ }
46
+ function isStrictEthAddress(value) {
47
+ return parseStrictEthAddress(value).ok;
48
+ }
49
+
50
+ //#endregion
51
+ export { isStrictEthAddress, parseStrictEthAddress };
@@ -1,7 +1,7 @@
1
1
  import { encode } from "../encode.mjs";
2
- import { toUint8Array } from "@ocap/util";
3
2
  import { keccak_224, keccak_256, keccak_384, keccak_512 } from "@noble/hashes/sha3.js";
4
3
  import { bytesToHex } from "@noble/hashes/utils.js";
4
+ import { toUint8Array } from "@ocap/util";
5
5
 
6
6
  //#region src/hasher/keccak.ts
7
7
  const hashFns = {
@@ -1,6 +1,6 @@
1
1
  import { encode } from "../encode.mjs";
2
- import { toUint8Array } from "@ocap/util";
3
2
  import { bytesToHex } from "@noble/hashes/utils.js";
3
+ import { toUint8Array } from "@ocap/util";
4
4
  import { hmac } from "@noble/hashes/hmac.js";
5
5
  import { sha224, sha256, sha384, sha512 } from "@noble/hashes/sha2.js";
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { encode } from "../encode.mjs";
2
- import { toUint8Array } from "@ocap/util";
3
2
  import { sha3_224, sha3_256, sha3_384, sha3_512 } from "@noble/hashes/sha3.js";
4
3
  import { bytesToHex } from "@noble/hashes/utils.js";
4
+ import { toUint8Array } from "@ocap/util";
5
5
 
6
6
  //#region src/hasher/sha3.ts
7
7
  const hashFns = {
package/esm/index.d.mts CHANGED
@@ -1,4 +1,6 @@
1
- import { ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope } from "./envelope.mjs";
1
+ import { BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, RecoveredBridgeSigner, bridgeEvidenceKey, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, ethAddressOfPublicKey, recoverBridgeSigner, signBridgeDigest, toHexDigest } from "./bridge-governance.mjs";
2
+ import { EIP712_BRIDGE_WITHDRAW_TYPE_STRING, ExpectedEnvelopeTxContext, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports, formatWalletEnvelopeText, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, verifyEthereumEnvelope } from "./envelope.mjs";
3
+ import { StrictEthAddressFailure, StrictEthAddressResult, isStrictEthAddress, parseStrictEthAddress } from "./eth-address.mjs";
2
4
  import { KeccakHasher } from "./hasher/keccak.mjs";
3
5
  import { Sha2Hasher, hmacSha256 } from "./hasher/sha2.mjs";
4
6
  import { Sha3Hasher } from "./hasher/sha3.mjs";
@@ -13,7 +15,7 @@ import { LiteralUnion } from "type-fest";
13
15
  //#region src/index.d.ts
14
16
  type KeyType = LiteralUnion<'ED25519' | 'SECP256K1' | 'ETHEREUM' | 'PASSKEY', string>;
15
17
  type HashType = LiteralUnion<'KECCAK' | 'SHA3' | 'KECCAK_384' | 'SHA3_384' | 'KECCAK_512' | 'SHA3_512' | 'SHA2', string>;
16
- type RoleType = LiteralUnion<'ROLE_ACCOUNT' | 'ROLE_NODE' | 'ROLE_DEVICE' | 'ROLE_APPLICATION' | 'ROLE_SMART_CONTRACT' | 'ROLE_BOT' | 'ROLE_ASSET' | 'ROLE_STAKE' | 'ROLE_VALIDATOR' | 'ROLE_GROUP' | 'ROLE_TX' | 'ROLE_TETHER' | 'ROLE_SWAP' | 'ROLE_DELEGATION' | 'ROLE_VC' | 'ROLE_BLOCKLET' | 'ROLE_STORE' | 'ROLE_TOKEN' | 'ROLE_FACTORY' | 'ROLE_ROLLUP' | 'ROLE_STORAGE' | 'ROLE_PROFILE' | 'ROLE_PASSKEY' | 'ROLE_TOKEN_FACTORY' | 'ROLE_PROVIDER' | 'ROLE_ANY', string>;
18
+ type RoleType = LiteralUnion<'ROLE_ACCOUNT' | 'ROLE_NODE' | 'ROLE_DEVICE' | 'ROLE_APPLICATION' | 'ROLE_SMART_CONTRACT' | 'ROLE_BOT' | 'ROLE_ASSET' | 'ROLE_STAKE' | 'ROLE_VALIDATOR' | 'ROLE_GROUP' | 'ROLE_TX' | 'ROLE_TETHER' | 'ROLE_SWAP' | 'ROLE_DELEGATION' | 'ROLE_VC' | 'ROLE_BLOCKLET' | 'ROLE_STORE' | 'ROLE_TOKEN' | 'ROLE_FACTORY' | 'ROLE_ROLLUP' | 'ROLE_STORAGE' | 'ROLE_PROFILE' | 'ROLE_PASSKEY' | 'ROLE_TOKEN_FACTORY' | 'ROLE_PROVIDER' | 'ROLE_BRIDGE_RESERVE' | 'ROLE_ANY', string>;
17
19
  type AddressType = LiteralUnion<'BASE16' | 'BASE58', string>;
18
20
  interface HashFnType {
19
21
  (data: BytesType, round: number, encoding?: 'hex'): string;
@@ -173,6 +175,7 @@ declare const types: {
173
175
  ROLE_PASSKEY: number;
174
176
  ROLE_TOKEN_FACTORY: number;
175
177
  ROLE_PROVIDER: number;
178
+ ROLE_BRIDGE_RESERVE: number;
176
179
  ROLE_ANY: number;
177
180
  };
178
181
  /**
@@ -240,4 +243,4 @@ declare function getRandomBytes(length: number, encoding?: 'Uint8Array'): Uint8A
240
243
  declare function getRandomBytes(length: number, encoding?: EncodingType): BytesType;
241
244
  declare const toTxHash: (buf: Buffer | Uint8Array) => string;
242
245
  //#endregion
243
- export { AddressType, ExpectedEnvelopeTxContext, HashFnType, HashType, Hasher, KeyType, RoleType, Signer, SignerType, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports as envelope, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, isCanonicalWalletEnvelopeExtra, normalizeChallengeHex, parseWalletEnvelopeExtra, signEthereumEnvelope, toTxHash, types, verifyEthereumEnvelope, webauthn_d_exports as webauthn };
246
+ export { AddressType, BRIDGE_GOV_DOMAIN_NAME, BRIDGE_GOV_DOMAIN_VERSION, BRIDGE_MEMBERSHIP_ACTION, BRIDGE_MEMBERSHIP_TYPE_STRING, BRIDGE_OWNER_ATTESTATION_TYPE_STRING, BridgeKeyPart, BridgeMembershipMessage, BridgeOwnerAttestationMessage, EIP712_BRIDGE_WITHDRAW_TYPE_STRING, ExpectedEnvelopeTxContext, HashFnType, HashType, Hasher, KeyType, RecoveredBridgeSigner, RoleType, Signer, SignerType, StrictEthAddressFailure, StrictEthAddressResult, WalletEnvelopeExtra, WalletEnvelopeType, assertEnvelopeMatchesTxContext, bridgeEvidenceKey, buildBridgeWithdrawEnvelopeExtra, buildEd25519EnvelopePayload, buildSolanaOffchainEnvelopeBytes, computeBridgeEndpointsHash, computeBridgeMembershipDigest, computeBridgeOwnerAttestationDigest, computeEip191EnvelopeDigest, computeEip712EnvelopeDigest, envelope_d_exports as envelope, ethAddressOfPublicKey, formatWalletEnvelopeText, getHasher, getRandomBytes, getSigner, hmacSha256, isCanonicalWalletEnvelopeExtra, isStrictEthAddress, normalizeChallengeHex, parseStrictEthAddress, parseWalletEnvelopeExtra, recoverBridgeSigner, signBridgeDigest, signEthereumEnvelope, toHexDigest, toTxHash, types, verifyEthereumEnvelope, webauthn_d_exports as webauthn };