@metamask-previews/profile-sync-controller 29.0.0-preview-6b4bcdab3 → 29.0.0-preview-0b5bfc2
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.
- package/CHANGELOG.md +5 -2
- package/dist/controllers/authentication/AuthenticationController.cjs +39 -22
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +2 -3
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +2 -3
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +39 -22
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +18 -14
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +18 -14
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs +0 -1
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +0 -1
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +0 -1
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs +0 -1
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
- package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.mjs +45 -0
- package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
- package/dist/shared/utils/message-signing.cjs +147 -0
- package/dist/shared/utils/message-signing.cjs.map +1 -0
- package/dist/shared/utils/message-signing.d.cts +73 -0
- package/dist/shared/utils/message-signing.d.cts.map +1 -0
- package/dist/shared/utils/message-signing.d.mts +73 -0
- package/dist/shared/utils/message-signing.d.mts.map +1 -0
- package/dist/shared/utils/message-signing.mjs +140 -0
- package/dist/shared/utils/message-signing.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/controllers/authentication/auth-snap-requests.cjs +0 -44
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.cts +0 -21
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.mts +0 -21
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +0 -39
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signMessageWithMessageSigningKey = exports.getMessageSigningPublicKey = exports.deriveMessageSigningPrivateKey = exports.deriveSip6PrivateKey = exports.MESSAGE_SIGNING_SNAP_ID = void 0;
|
|
4
|
+
const key_tree_1 = require("@metamask/key-tree");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
7
|
+
const hmac_1 = require("@noble/hashes/hmac");
|
|
8
|
+
const sha2_1 = require("@noble/hashes/sha2");
|
|
9
|
+
const sha3_1 = require("@noble/hashes/sha3");
|
|
10
|
+
/**
|
|
11
|
+
* Native SIP-6 message-signing helpers for AuthenticationController /
|
|
12
|
+
* UserStorageController.
|
|
13
|
+
*
|
|
14
|
+
* These are intentional copies of the message-signing snap crypto path so auth
|
|
15
|
+
* and user-storage can derive/sign without booting
|
|
16
|
+
* `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:
|
|
17
|
+
*
|
|
18
|
+
* - SIP-6 derivation:
|
|
19
|
+
* `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /
|
|
20
|
+
* `getEntropyDerivationPath` / `getDerivationPathArray`
|
|
21
|
+
* (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)
|
|
22
|
+
* - Magic constant:
|
|
23
|
+
* `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
24
|
+
* - Pubkey + `metamask:…` signing:
|
|
25
|
+
* `@metamask/message-signing-snap` `getPublicEntropyKey` /
|
|
26
|
+
* `signMessageWithEntropyKey`
|
|
27
|
+
* (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)
|
|
28
|
+
*
|
|
29
|
+
* `deriveEntropyFromSeed` is not a public export of
|
|
30
|
+
* `@metamask/snaps-rpc-methods` today (and no core package depends on that
|
|
31
|
+
* package), so the SIP-6 math is vendored here rather than imported.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Snap ID used as the SIP-6 `input` so derived keys match
|
|
35
|
+
* `@metamask/message-signing-snap` (`snap_getEntropy` origin).
|
|
36
|
+
*/
|
|
37
|
+
exports.MESSAGE_SIGNING_SNAP_ID = 'npm:@metamask/message-signing-snap';
|
|
38
|
+
/**
|
|
39
|
+
* Copy of `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
40
|
+
* (`0xd36e6170 - 0x80000000`).
|
|
41
|
+
*
|
|
42
|
+
* @see https://metamask.github.io/SIPs/SIPS/sip-6
|
|
43
|
+
*/
|
|
44
|
+
const SIP_6_MAGIC_VALUE = `1399742832'`;
|
|
45
|
+
const HARDENED_VALUE = 0x80000000;
|
|
46
|
+
/**
|
|
47
|
+
* HMAC-SHA-512 for `@metamask/key-tree`.
|
|
48
|
+
*
|
|
49
|
+
* Passed into `SLIP10Node.fromSeed` so SIP-6 never uses Web Crypto.
|
|
50
|
+
* `@metamask/key-tree` treats any `crypto.subtle` as complete and then HMAC
|
|
51
|
+
* via `importKey` / `sign`. React Native only implements `digest`; its
|
|
52
|
+
* SubtleCrypto cannot HMAC. Noble HMAC is byte-identical without SubtleCrypto.
|
|
53
|
+
*/
|
|
54
|
+
const NOBLE_HMAC_SHA512 = {
|
|
55
|
+
hmacSha512: async (key, data) => (0, hmac_1.hmac)(sha2_1.sha512, key, data),
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Copy of `@metamask/snaps-rpc-methods` `getDerivationPathArray`.
|
|
59
|
+
*
|
|
60
|
+
* Maps a 32-byte hash to eight hardened BIP-32 indices for `@metamask/key-tree`.
|
|
61
|
+
*
|
|
62
|
+
* @param hash - 32-byte hash.
|
|
63
|
+
* @returns Hardened BIP-32 path nodes.
|
|
64
|
+
*/
|
|
65
|
+
function getDerivationPathArray(hash) {
|
|
66
|
+
const array = [];
|
|
67
|
+
const view = (0, utils_1.createDataView)(hash);
|
|
68
|
+
for (let index = 0; index < 8; index++) {
|
|
69
|
+
const uint32 = view.getUint32(index * 4);
|
|
70
|
+
// eslint-disable-next-line no-bitwise
|
|
71
|
+
const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
|
|
72
|
+
array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
|
|
73
|
+
}
|
|
74
|
+
return array;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),
|
|
78
|
+
* returning raw private-key bytes instead of a `0x`-prefixed hex string.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Derivation options.
|
|
81
|
+
* @param options.seed - BIP-39 mnemonic seed.
|
|
82
|
+
* @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).
|
|
83
|
+
* @param options.salt - Optional salt. Internal auth uses `''`.
|
|
84
|
+
* @returns 32-byte private key.
|
|
85
|
+
*/
|
|
86
|
+
async function deriveSip6PrivateKey({ seed, input, salt = '', }) {
|
|
87
|
+
const hash = (0, sha3_1.keccak_256)((0, utils_1.concatBytes)([(0, utils_1.stringToBytes)(input), (0, sha3_1.keccak_256)((0, utils_1.stringToBytes)(salt))]));
|
|
88
|
+
const computedDerivationPath = getDerivationPathArray(hash);
|
|
89
|
+
const { privateKey } = await key_tree_1.SLIP10Node.fromSeed({
|
|
90
|
+
derivationPath: [
|
|
91
|
+
seed,
|
|
92
|
+
`bip32:${SIP_6_MAGIC_VALUE}`,
|
|
93
|
+
...computedDerivationPath,
|
|
94
|
+
],
|
|
95
|
+
curve: 'secp256k1',
|
|
96
|
+
}, NOBLE_HMAC_SHA512);
|
|
97
|
+
(0, utils_1.assert)(privateKey, 'Failed to derive SIP-6 entropy.');
|
|
98
|
+
return (0, utils_1.hexToBytes)(privateKey);
|
|
99
|
+
}
|
|
100
|
+
exports.deriveSip6PrivateKey = deriveSip6PrivateKey;
|
|
101
|
+
/**
|
|
102
|
+
* Derives the message-signing private key via SIP-6, matching
|
|
103
|
+
* `snap_getEntropy` for the message-signing snap with empty salt
|
|
104
|
+
* (internal `metamask` origin).
|
|
105
|
+
*
|
|
106
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
107
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
108
|
+
* @returns 32-byte private key.
|
|
109
|
+
*/
|
|
110
|
+
async function deriveMessageSigningPrivateKey(seed, salt = '') {
|
|
111
|
+
return deriveSip6PrivateKey({
|
|
112
|
+
seed,
|
|
113
|
+
input: exports.MESSAGE_SIGNING_SNAP_ID,
|
|
114
|
+
salt,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.deriveMessageSigningPrivateKey = deriveMessageSigningPrivateKey;
|
|
118
|
+
/**
|
|
119
|
+
* Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex
|
|
120
|
+
* for the SIP-6 message-signing private key.
|
|
121
|
+
*
|
|
122
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
123
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
124
|
+
* @returns Public key hex with `0x` prefix.
|
|
125
|
+
*/
|
|
126
|
+
async function getMessageSigningPublicKey(seed, salt = '') {
|
|
127
|
+
const privateKey = await deriveMessageSigningPrivateKey(seed, salt);
|
|
128
|
+
return (0, utils_1.bytesToHex)(secp256k1_1.secp256k1.getPublicKey(privateKey));
|
|
129
|
+
}
|
|
130
|
+
exports.getMessageSigningPublicKey = getMessageSigningPublicKey;
|
|
131
|
+
/**
|
|
132
|
+
* Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)
|
|
133
|
+
* then compact secp256k1 signature.
|
|
134
|
+
*
|
|
135
|
+
* @param message - Message to sign (must be validated by the caller).
|
|
136
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
137
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
138
|
+
* @returns Compact secp256k1 signature hex with `0x` prefix.
|
|
139
|
+
*/
|
|
140
|
+
async function signMessageWithMessageSigningKey(message, seed, salt = '') {
|
|
141
|
+
const privateKey = await deriveMessageSigningPrivateKey(seed, salt);
|
|
142
|
+
const digest = (0, sha2_1.sha256)(message);
|
|
143
|
+
const signature = secp256k1_1.secp256k1.sign(digest, privateKey);
|
|
144
|
+
return `0x${signature.toCompactHex()}`;
|
|
145
|
+
}
|
|
146
|
+
exports.signMessageWithMessageSigningKey = signMessageWithMessageSigningKey;
|
|
147
|
+
//# sourceMappingURL=message-signing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-signing.cjs","sourceRoot":"","sources":["../../../src/shared/utils/message-signing.ts"],"names":[],"mappings":"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","sourcesContent":["import type { HardenedBIP32Node } from '@metamask/key-tree';\nimport { SLIP10Node } from '@metamask/key-tree';\nimport {\n assert,\n bytesToHex,\n concatBytes,\n createDataView,\n hexToBytes,\n stringToBytes,\n} from '@metamask/utils';\nimport { secp256k1 } from '@noble/curves/secp256k1';\nimport { hmac } from '@noble/hashes/hmac';\nimport { sha256, sha512 } from '@noble/hashes/sha2';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\n\n/**\n * Native SIP-6 message-signing helpers for AuthenticationController /\n * UserStorageController.\n *\n * These are intentional copies of the message-signing snap crypto path so auth\n * and user-storage can derive/sign without booting\n * `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:\n *\n * - SIP-6 derivation:\n * `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /\n * `getEntropyDerivationPath` / `getDerivationPathArray`\n * (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)\n * - Magic constant:\n * `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`\n * - Pubkey + `metamask:…` signing:\n * `@metamask/message-signing-snap` `getPublicEntropyKey` /\n * `signMessageWithEntropyKey`\n * (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)\n *\n * `deriveEntropyFromSeed` is not a public export of\n * `@metamask/snaps-rpc-methods` today (and no core package depends on that\n * package), so the SIP-6 math is vendored here rather than imported.\n */\n\n/**\n * Snap ID used as the SIP-6 `input` so derived keys match\n * `@metamask/message-signing-snap` (`snap_getEntropy` origin).\n */\nexport const MESSAGE_SIGNING_SNAP_ID = 'npm:@metamask/message-signing-snap';\n\n/**\n * Copy of `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`\n * (`0xd36e6170 - 0x80000000`).\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-6\n */\nconst SIP_6_MAGIC_VALUE = `1399742832'` as `${number}'`;\n\nconst HARDENED_VALUE = 0x80000000;\n\n/**\n * HMAC-SHA-512 for `@metamask/key-tree`.\n *\n * Passed into `SLIP10Node.fromSeed` so SIP-6 never uses Web Crypto.\n * `@metamask/key-tree` treats any `crypto.subtle` as complete and then HMAC\n * via `importKey` / `sign`. React Native only implements `digest`; its\n * SubtleCrypto cannot HMAC. Noble HMAC is byte-identical without SubtleCrypto.\n */\nconst NOBLE_HMAC_SHA512 = {\n hmacSha512: async (key: Uint8Array, data: Uint8Array): Promise<Uint8Array> =>\n hmac(sha512, key, data),\n};\n\n/**\n * Copy of `@metamask/snaps-rpc-methods` `getDerivationPathArray`.\n *\n * Maps a 32-byte hash to eight hardened BIP-32 indices for `@metamask/key-tree`.\n *\n * @param hash - 32-byte hash.\n * @returns Hardened BIP-32 path nodes.\n */\nfunction getDerivationPathArray(hash: Uint8Array): HardenedBIP32Node[] {\n const array: HardenedBIP32Node[] = [];\n const view = createDataView(hash);\n\n for (let index = 0; index < 8; index++) {\n const uint32 = view.getUint32(index * 4);\n // eslint-disable-next-line no-bitwise\n const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;\n array.push(`bip32:${pathIndex - HARDENED_VALUE}'` as const);\n }\n\n return array;\n}\n\n/**\n * Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),\n * returning raw private-key bytes instead of a `0x`-prefixed hex string.\n *\n * @param options - Derivation options.\n * @param options.seed - BIP-39 mnemonic seed.\n * @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).\n * @param options.salt - Optional salt. Internal auth uses `''`.\n * @returns 32-byte private key.\n */\nexport async function deriveSip6PrivateKey({\n seed,\n input,\n salt = '',\n}: {\n seed: Uint8Array;\n input: string;\n salt?: string;\n}): Promise<Uint8Array> {\n const hash = keccak256(\n concatBytes([stringToBytes(input), keccak256(stringToBytes(salt))]),\n );\n const computedDerivationPath = getDerivationPathArray(hash);\n\n const { privateKey } = await SLIP10Node.fromSeed(\n {\n derivationPath: [\n seed,\n `bip32:${SIP_6_MAGIC_VALUE}`,\n ...computedDerivationPath,\n ],\n curve: 'secp256k1',\n },\n NOBLE_HMAC_SHA512,\n );\n\n assert(privateKey, 'Failed to derive SIP-6 entropy.');\n return hexToBytes(privateKey);\n}\n\n/**\n * Derives the message-signing private key via SIP-6, matching\n * `snap_getEntropy` for the message-signing snap with empty salt\n * (internal `metamask` origin).\n *\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns 32-byte private key.\n */\nexport async function deriveMessageSigningPrivateKey(\n seed: Uint8Array,\n salt = '',\n): Promise<Uint8Array> {\n return deriveSip6PrivateKey({\n seed,\n input: MESSAGE_SIGNING_SNAP_ID,\n salt,\n });\n}\n\n/**\n * Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex\n * for the SIP-6 message-signing private key.\n *\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns Public key hex with `0x` prefix.\n */\nexport async function getMessageSigningPublicKey(\n seed: Uint8Array,\n salt = '',\n): Promise<string> {\n const privateKey = await deriveMessageSigningPrivateKey(seed, salt);\n return bytesToHex(secp256k1.getPublicKey(privateKey));\n}\n\n/**\n * Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)\n * then compact secp256k1 signature.\n *\n * @param message - Message to sign (must be validated by the caller).\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns Compact secp256k1 signature hex with `0x` prefix.\n */\nexport async function signMessageWithMessageSigningKey(\n message: string,\n seed: Uint8Array,\n salt = '',\n): Promise<string> {\n const privateKey = await deriveMessageSigningPrivateKey(seed, salt);\n const digest = sha256(message);\n const signature = secp256k1.sign(digest, privateKey);\n return `0x${signature.toCompactHex()}`;\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native SIP-6 message-signing helpers for AuthenticationController /
|
|
3
|
+
* UserStorageController.
|
|
4
|
+
*
|
|
5
|
+
* These are intentional copies of the message-signing snap crypto path so auth
|
|
6
|
+
* and user-storage can derive/sign without booting
|
|
7
|
+
* `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:
|
|
8
|
+
*
|
|
9
|
+
* - SIP-6 derivation:
|
|
10
|
+
* `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /
|
|
11
|
+
* `getEntropyDerivationPath` / `getDerivationPathArray`
|
|
12
|
+
* (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)
|
|
13
|
+
* - Magic constant:
|
|
14
|
+
* `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
15
|
+
* - Pubkey + `metamask:…` signing:
|
|
16
|
+
* `@metamask/message-signing-snap` `getPublicEntropyKey` /
|
|
17
|
+
* `signMessageWithEntropyKey`
|
|
18
|
+
* (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)
|
|
19
|
+
*
|
|
20
|
+
* `deriveEntropyFromSeed` is not a public export of
|
|
21
|
+
* `@metamask/snaps-rpc-methods` today (and no core package depends on that
|
|
22
|
+
* package), so the SIP-6 math is vendored here rather than imported.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Snap ID used as the SIP-6 `input` so derived keys match
|
|
26
|
+
* `@metamask/message-signing-snap` (`snap_getEntropy` origin).
|
|
27
|
+
*/
|
|
28
|
+
export declare const MESSAGE_SIGNING_SNAP_ID = "npm:@metamask/message-signing-snap";
|
|
29
|
+
/**
|
|
30
|
+
* Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),
|
|
31
|
+
* returning raw private-key bytes instead of a `0x`-prefixed hex string.
|
|
32
|
+
*
|
|
33
|
+
* @param options - Derivation options.
|
|
34
|
+
* @param options.seed - BIP-39 mnemonic seed.
|
|
35
|
+
* @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).
|
|
36
|
+
* @param options.salt - Optional salt. Internal auth uses `''`.
|
|
37
|
+
* @returns 32-byte private key.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deriveSip6PrivateKey({ seed, input, salt, }: {
|
|
40
|
+
seed: Uint8Array;
|
|
41
|
+
input: string;
|
|
42
|
+
salt?: string;
|
|
43
|
+
}): Promise<Uint8Array>;
|
|
44
|
+
/**
|
|
45
|
+
* Derives the message-signing private key via SIP-6, matching
|
|
46
|
+
* `snap_getEntropy` for the message-signing snap with empty salt
|
|
47
|
+
* (internal `metamask` origin).
|
|
48
|
+
*
|
|
49
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
50
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
51
|
+
* @returns 32-byte private key.
|
|
52
|
+
*/
|
|
53
|
+
export declare function deriveMessageSigningPrivateKey(seed: Uint8Array, salt?: string): Promise<Uint8Array>;
|
|
54
|
+
/**
|
|
55
|
+
* Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex
|
|
56
|
+
* for the SIP-6 message-signing private key.
|
|
57
|
+
*
|
|
58
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
59
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
60
|
+
* @returns Public key hex with `0x` prefix.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getMessageSigningPublicKey(seed: Uint8Array, salt?: string): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)
|
|
65
|
+
* then compact secp256k1 signature.
|
|
66
|
+
*
|
|
67
|
+
* @param message - Message to sign (must be validated by the caller).
|
|
68
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
69
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
70
|
+
* @returns Compact secp256k1 signature hex with `0x` prefix.
|
|
71
|
+
*/
|
|
72
|
+
export declare function signMessageWithMessageSigningKey(message: string, seed: Uint8Array, salt?: string): Promise<string>;
|
|
73
|
+
//# sourceMappingURL=message-signing.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-signing.d.cts","sourceRoot":"","sources":["../../../src/shared/utils/message-signing.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,uCAAuC,CAAC;AA+C5E;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,KAAK,EACL,IAAS,GACV,EAAE;IACD,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native SIP-6 message-signing helpers for AuthenticationController /
|
|
3
|
+
* UserStorageController.
|
|
4
|
+
*
|
|
5
|
+
* These are intentional copies of the message-signing snap crypto path so auth
|
|
6
|
+
* and user-storage can derive/sign without booting
|
|
7
|
+
* `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:
|
|
8
|
+
*
|
|
9
|
+
* - SIP-6 derivation:
|
|
10
|
+
* `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /
|
|
11
|
+
* `getEntropyDerivationPath` / `getDerivationPathArray`
|
|
12
|
+
* (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)
|
|
13
|
+
* - Magic constant:
|
|
14
|
+
* `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
15
|
+
* - Pubkey + `metamask:…` signing:
|
|
16
|
+
* `@metamask/message-signing-snap` `getPublicEntropyKey` /
|
|
17
|
+
* `signMessageWithEntropyKey`
|
|
18
|
+
* (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)
|
|
19
|
+
*
|
|
20
|
+
* `deriveEntropyFromSeed` is not a public export of
|
|
21
|
+
* `@metamask/snaps-rpc-methods` today (and no core package depends on that
|
|
22
|
+
* package), so the SIP-6 math is vendored here rather than imported.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Snap ID used as the SIP-6 `input` so derived keys match
|
|
26
|
+
* `@metamask/message-signing-snap` (`snap_getEntropy` origin).
|
|
27
|
+
*/
|
|
28
|
+
export declare const MESSAGE_SIGNING_SNAP_ID = "npm:@metamask/message-signing-snap";
|
|
29
|
+
/**
|
|
30
|
+
* Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),
|
|
31
|
+
* returning raw private-key bytes instead of a `0x`-prefixed hex string.
|
|
32
|
+
*
|
|
33
|
+
* @param options - Derivation options.
|
|
34
|
+
* @param options.seed - BIP-39 mnemonic seed.
|
|
35
|
+
* @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).
|
|
36
|
+
* @param options.salt - Optional salt. Internal auth uses `''`.
|
|
37
|
+
* @returns 32-byte private key.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deriveSip6PrivateKey({ seed, input, salt, }: {
|
|
40
|
+
seed: Uint8Array;
|
|
41
|
+
input: string;
|
|
42
|
+
salt?: string;
|
|
43
|
+
}): Promise<Uint8Array>;
|
|
44
|
+
/**
|
|
45
|
+
* Derives the message-signing private key via SIP-6, matching
|
|
46
|
+
* `snap_getEntropy` for the message-signing snap with empty salt
|
|
47
|
+
* (internal `metamask` origin).
|
|
48
|
+
*
|
|
49
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
50
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
51
|
+
* @returns 32-byte private key.
|
|
52
|
+
*/
|
|
53
|
+
export declare function deriveMessageSigningPrivateKey(seed: Uint8Array, salt?: string): Promise<Uint8Array>;
|
|
54
|
+
/**
|
|
55
|
+
* Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex
|
|
56
|
+
* for the SIP-6 message-signing private key.
|
|
57
|
+
*
|
|
58
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
59
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
60
|
+
* @returns Public key hex with `0x` prefix.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getMessageSigningPublicKey(seed: Uint8Array, salt?: string): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)
|
|
65
|
+
* then compact secp256k1 signature.
|
|
66
|
+
*
|
|
67
|
+
* @param message - Message to sign (must be validated by the caller).
|
|
68
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
69
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
70
|
+
* @returns Compact secp256k1 signature hex with `0x` prefix.
|
|
71
|
+
*/
|
|
72
|
+
export declare function signMessageWithMessageSigningKey(message: string, seed: Uint8Array, salt?: string): Promise<string>;
|
|
73
|
+
//# sourceMappingURL=message-signing.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-signing.d.mts","sourceRoot":"","sources":["../../../src/shared/utils/message-signing.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,uCAAuC,CAAC;AA+C5E;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,KAAK,EACL,IAAS,GACV,EAAE;IACD,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,EAChB,IAAI,SAAK,GACR,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { SLIP10Node } from "@metamask/key-tree";
|
|
2
|
+
import { assert, bytesToHex, concatBytes, createDataView, hexToBytes, stringToBytes } from "@metamask/utils";
|
|
3
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
4
|
+
import { hmac } from "@noble/hashes/hmac";
|
|
5
|
+
import { sha256, sha512 } from "@noble/hashes/sha2";
|
|
6
|
+
import { keccak_256 as keccak256 } from "@noble/hashes/sha3";
|
|
7
|
+
/**
|
|
8
|
+
* Native SIP-6 message-signing helpers for AuthenticationController /
|
|
9
|
+
* UserStorageController.
|
|
10
|
+
*
|
|
11
|
+
* These are intentional copies of the message-signing snap crypto path so auth
|
|
12
|
+
* and user-storage can derive/sign without booting
|
|
13
|
+
* `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:
|
|
14
|
+
*
|
|
15
|
+
* - SIP-6 derivation:
|
|
16
|
+
* `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /
|
|
17
|
+
* `getEntropyDerivationPath` / `getDerivationPathArray`
|
|
18
|
+
* (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)
|
|
19
|
+
* - Magic constant:
|
|
20
|
+
* `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
21
|
+
* - Pubkey + `metamask:…` signing:
|
|
22
|
+
* `@metamask/message-signing-snap` `getPublicEntropyKey` /
|
|
23
|
+
* `signMessageWithEntropyKey`
|
|
24
|
+
* (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)
|
|
25
|
+
*
|
|
26
|
+
* `deriveEntropyFromSeed` is not a public export of
|
|
27
|
+
* `@metamask/snaps-rpc-methods` today (and no core package depends on that
|
|
28
|
+
* package), so the SIP-6 math is vendored here rather than imported.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Snap ID used as the SIP-6 `input` so derived keys match
|
|
32
|
+
* `@metamask/message-signing-snap` (`snap_getEntropy` origin).
|
|
33
|
+
*/
|
|
34
|
+
export const MESSAGE_SIGNING_SNAP_ID = 'npm:@metamask/message-signing-snap';
|
|
35
|
+
/**
|
|
36
|
+
* Copy of `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`
|
|
37
|
+
* (`0xd36e6170 - 0x80000000`).
|
|
38
|
+
*
|
|
39
|
+
* @see https://metamask.github.io/SIPs/SIPS/sip-6
|
|
40
|
+
*/
|
|
41
|
+
const SIP_6_MAGIC_VALUE = `1399742832'`;
|
|
42
|
+
const HARDENED_VALUE = 0x80000000;
|
|
43
|
+
/**
|
|
44
|
+
* HMAC-SHA-512 for `@metamask/key-tree`.
|
|
45
|
+
*
|
|
46
|
+
* Passed into `SLIP10Node.fromSeed` so SIP-6 never uses Web Crypto.
|
|
47
|
+
* `@metamask/key-tree` treats any `crypto.subtle` as complete and then HMAC
|
|
48
|
+
* via `importKey` / `sign`. React Native only implements `digest`; its
|
|
49
|
+
* SubtleCrypto cannot HMAC. Noble HMAC is byte-identical without SubtleCrypto.
|
|
50
|
+
*/
|
|
51
|
+
const NOBLE_HMAC_SHA512 = {
|
|
52
|
+
hmacSha512: async (key, data) => hmac(sha512, key, data),
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Copy of `@metamask/snaps-rpc-methods` `getDerivationPathArray`.
|
|
56
|
+
*
|
|
57
|
+
* Maps a 32-byte hash to eight hardened BIP-32 indices for `@metamask/key-tree`.
|
|
58
|
+
*
|
|
59
|
+
* @param hash - 32-byte hash.
|
|
60
|
+
* @returns Hardened BIP-32 path nodes.
|
|
61
|
+
*/
|
|
62
|
+
function getDerivationPathArray(hash) {
|
|
63
|
+
const array = [];
|
|
64
|
+
const view = createDataView(hash);
|
|
65
|
+
for (let index = 0; index < 8; index++) {
|
|
66
|
+
const uint32 = view.getUint32(index * 4);
|
|
67
|
+
// eslint-disable-next-line no-bitwise
|
|
68
|
+
const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
|
|
69
|
+
array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
|
|
70
|
+
}
|
|
71
|
+
return array;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),
|
|
75
|
+
* returning raw private-key bytes instead of a `0x`-prefixed hex string.
|
|
76
|
+
*
|
|
77
|
+
* @param options - Derivation options.
|
|
78
|
+
* @param options.seed - BIP-39 mnemonic seed.
|
|
79
|
+
* @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).
|
|
80
|
+
* @param options.salt - Optional salt. Internal auth uses `''`.
|
|
81
|
+
* @returns 32-byte private key.
|
|
82
|
+
*/
|
|
83
|
+
export async function deriveSip6PrivateKey({ seed, input, salt = '', }) {
|
|
84
|
+
const hash = keccak256(concatBytes([stringToBytes(input), keccak256(stringToBytes(salt))]));
|
|
85
|
+
const computedDerivationPath = getDerivationPathArray(hash);
|
|
86
|
+
const { privateKey } = await SLIP10Node.fromSeed({
|
|
87
|
+
derivationPath: [
|
|
88
|
+
seed,
|
|
89
|
+
`bip32:${SIP_6_MAGIC_VALUE}`,
|
|
90
|
+
...computedDerivationPath,
|
|
91
|
+
],
|
|
92
|
+
curve: 'secp256k1',
|
|
93
|
+
}, NOBLE_HMAC_SHA512);
|
|
94
|
+
assert(privateKey, 'Failed to derive SIP-6 entropy.');
|
|
95
|
+
return hexToBytes(privateKey);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Derives the message-signing private key via SIP-6, matching
|
|
99
|
+
* `snap_getEntropy` for the message-signing snap with empty salt
|
|
100
|
+
* (internal `metamask` origin).
|
|
101
|
+
*
|
|
102
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
103
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
104
|
+
* @returns 32-byte private key.
|
|
105
|
+
*/
|
|
106
|
+
export async function deriveMessageSigningPrivateKey(seed, salt = '') {
|
|
107
|
+
return deriveSip6PrivateKey({
|
|
108
|
+
seed,
|
|
109
|
+
input: MESSAGE_SIGNING_SNAP_ID,
|
|
110
|
+
salt,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex
|
|
115
|
+
* for the SIP-6 message-signing private key.
|
|
116
|
+
*
|
|
117
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
118
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
119
|
+
* @returns Public key hex with `0x` prefix.
|
|
120
|
+
*/
|
|
121
|
+
export async function getMessageSigningPublicKey(seed, salt = '') {
|
|
122
|
+
const privateKey = await deriveMessageSigningPrivateKey(seed, salt);
|
|
123
|
+
return bytesToHex(secp256k1.getPublicKey(privateKey));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)
|
|
127
|
+
* then compact secp256k1 signature.
|
|
128
|
+
*
|
|
129
|
+
* @param message - Message to sign (must be validated by the caller).
|
|
130
|
+
* @param seed - BIP-39 mnemonic seed from an HD keyring.
|
|
131
|
+
* @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.
|
|
132
|
+
* @returns Compact secp256k1 signature hex with `0x` prefix.
|
|
133
|
+
*/
|
|
134
|
+
export async function signMessageWithMessageSigningKey(message, seed, salt = '') {
|
|
135
|
+
const privateKey = await deriveMessageSigningPrivateKey(seed, salt);
|
|
136
|
+
const digest = sha256(message);
|
|
137
|
+
const signature = secp256k1.sign(digest, privateKey);
|
|
138
|
+
return `0x${signature.toCompactHex()}`;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=message-signing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-signing.mjs","sourceRoot":"","sources":["../../../src/shared/utils/message-signing.ts"],"names":[],"mappings":"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","sourcesContent":["import type { HardenedBIP32Node } from '@metamask/key-tree';\nimport { SLIP10Node } from '@metamask/key-tree';\nimport {\n assert,\n bytesToHex,\n concatBytes,\n createDataView,\n hexToBytes,\n stringToBytes,\n} from '@metamask/utils';\nimport { secp256k1 } from '@noble/curves/secp256k1';\nimport { hmac } from '@noble/hashes/hmac';\nimport { sha256, sha512 } from '@noble/hashes/sha2';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\n\n/**\n * Native SIP-6 message-signing helpers for AuthenticationController /\n * UserStorageController.\n *\n * These are intentional copies of the message-signing snap crypto path so auth\n * and user-storage can derive/sign without booting\n * `npm:@metamask/message-signing-snap`. Behavior must stay byte-identical to:\n *\n * - SIP-6 derivation:\n * `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` /\n * `getEntropyDerivationPath` / `getDerivationPathArray`\n * (https://github.com/MetaMask/snaps/blob/main/packages/snaps-rpc-methods/src/utils.ts)\n * - Magic constant:\n * `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`\n * - Pubkey + `metamask:…` signing:\n * `@metamask/message-signing-snap` `getPublicEntropyKey` /\n * `signMessageWithEntropyKey`\n * (https://github.com/MetaMask/message-signing-snap/blob/main/src/entropy-keys.ts)\n *\n * `deriveEntropyFromSeed` is not a public export of\n * `@metamask/snaps-rpc-methods` today (and no core package depends on that\n * package), so the SIP-6 math is vendored here rather than imported.\n */\n\n/**\n * Snap ID used as the SIP-6 `input` so derived keys match\n * `@metamask/message-signing-snap` (`snap_getEntropy` origin).\n */\nexport const MESSAGE_SIGNING_SNAP_ID = 'npm:@metamask/message-signing-snap';\n\n/**\n * Copy of `@metamask/snaps-utils` `SIP_6_MAGIC_VALUE`\n * (`0xd36e6170 - 0x80000000`).\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-6\n */\nconst SIP_6_MAGIC_VALUE = `1399742832'` as `${number}'`;\n\nconst HARDENED_VALUE = 0x80000000;\n\n/**\n * HMAC-SHA-512 for `@metamask/key-tree`.\n *\n * Passed into `SLIP10Node.fromSeed` so SIP-6 never uses Web Crypto.\n * `@metamask/key-tree` treats any `crypto.subtle` as complete and then HMAC\n * via `importKey` / `sign`. React Native only implements `digest`; its\n * SubtleCrypto cannot HMAC. Noble HMAC is byte-identical without SubtleCrypto.\n */\nconst NOBLE_HMAC_SHA512 = {\n hmacSha512: async (key: Uint8Array, data: Uint8Array): Promise<Uint8Array> =>\n hmac(sha512, key, data),\n};\n\n/**\n * Copy of `@metamask/snaps-rpc-methods` `getDerivationPathArray`.\n *\n * Maps a 32-byte hash to eight hardened BIP-32 indices for `@metamask/key-tree`.\n *\n * @param hash - 32-byte hash.\n * @returns Hardened BIP-32 path nodes.\n */\nfunction getDerivationPathArray(hash: Uint8Array): HardenedBIP32Node[] {\n const array: HardenedBIP32Node[] = [];\n const view = createDataView(hash);\n\n for (let index = 0; index < 8; index++) {\n const uint32 = view.getUint32(index * 4);\n // eslint-disable-next-line no-bitwise\n const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;\n array.push(`bip32:${pathIndex - HARDENED_VALUE}'` as const);\n }\n\n return array;\n}\n\n/**\n * Copy of `@metamask/snaps-rpc-methods` `deriveEntropyFromSeed` (SIP-6),\n * returning raw private-key bytes instead of a `0x`-prefixed hex string.\n *\n * @param options - Derivation options.\n * @param options.seed - BIP-39 mnemonic seed.\n * @param options.input - SIP-6 input (snap ID for `snap_getEntropy`).\n * @param options.salt - Optional salt. Internal auth uses `''`.\n * @returns 32-byte private key.\n */\nexport async function deriveSip6PrivateKey({\n seed,\n input,\n salt = '',\n}: {\n seed: Uint8Array;\n input: string;\n salt?: string;\n}): Promise<Uint8Array> {\n const hash = keccak256(\n concatBytes([stringToBytes(input), keccak256(stringToBytes(salt))]),\n );\n const computedDerivationPath = getDerivationPathArray(hash);\n\n const { privateKey } = await SLIP10Node.fromSeed(\n {\n derivationPath: [\n seed,\n `bip32:${SIP_6_MAGIC_VALUE}`,\n ...computedDerivationPath,\n ],\n curve: 'secp256k1',\n },\n NOBLE_HMAC_SHA512,\n );\n\n assert(privateKey, 'Failed to derive SIP-6 entropy.');\n return hexToBytes(privateKey);\n}\n\n/**\n * Derives the message-signing private key via SIP-6, matching\n * `snap_getEntropy` for the message-signing snap with empty salt\n * (internal `metamask` origin).\n *\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns 32-byte private key.\n */\nexport async function deriveMessageSigningPrivateKey(\n seed: Uint8Array,\n salt = '',\n): Promise<Uint8Array> {\n return deriveSip6PrivateKey({\n seed,\n input: MESSAGE_SIGNING_SNAP_ID,\n salt,\n });\n}\n\n/**\n * Copy of message-signing-snap `getPublicEntropyKey`: secp256k1 pubkey hex\n * for the SIP-6 message-signing private key.\n *\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns Public key hex with `0x` prefix.\n */\nexport async function getMessageSigningPublicKey(\n seed: Uint8Array,\n salt = '',\n): Promise<string> {\n const privateKey = await deriveMessageSigningPrivateKey(seed, salt);\n return bytesToHex(secp256k1.getPublicKey(privateKey));\n}\n\n/**\n * Copy of message-signing-snap `signMessageWithEntropyKey`: sha256(message)\n * then compact secp256k1 signature.\n *\n * @param message - Message to sign (must be validated by the caller).\n * @param seed - BIP-39 mnemonic seed from an HD keyring.\n * @param salt - Optional SIP-6 salt. Auth / user-storage use `''`.\n * @returns Compact secp256k1 signature hex with `0x` prefix.\n */\nexport async function signMessageWithMessageSigningKey(\n message: string,\n seed: Uint8Array,\n salt = '',\n): Promise<string> {\n const privateKey = await deriveMessageSigningPrivateKey(seed, salt);\n const digest = sha256(message);\n const signature = secp256k1.sign(digest, privateKey);\n return `0x${signature.toCompactHex()}`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/profile-sync-controller",
|
|
3
|
-
"version": "29.0.0-preview-
|
|
3
|
+
"version": "29.0.0-preview-0b5bfc2",
|
|
4
4
|
"description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -110,14 +110,13 @@
|
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@metamask/address-book-controller": "^7.1.2",
|
|
112
112
|
"@metamask/base-controller": "^9.1.0",
|
|
113
|
+
"@metamask/key-tree": "^10.1.1",
|
|
113
114
|
"@metamask/keyring-controller": "^27.1.1",
|
|
114
115
|
"@metamask/messenger": "^2.0.0",
|
|
115
116
|
"@metamask/seedless-onboarding-controller": "^10.1.1",
|
|
116
|
-
"@metamask/snaps-controllers": "^19.0.0",
|
|
117
|
-
"@metamask/snaps-sdk": "^11.0.0",
|
|
118
|
-
"@metamask/snaps-utils": "^12.1.2",
|
|
119
117
|
"@metamask/utils": "^11.11.0",
|
|
120
118
|
"@noble/ciphers": "^1.3.0",
|
|
119
|
+
"@noble/curves": "^1.9.2",
|
|
121
120
|
"@noble/hashes": "^1.8.0",
|
|
122
121
|
"immer": "^9.0.6",
|
|
123
122
|
"loglevel": "^1.8.1",
|
|
@@ -127,6 +126,7 @@
|
|
|
127
126
|
"@lavamoat/allow-scripts": "^3.0.4",
|
|
128
127
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
129
128
|
"@metamask/auto-changelog": "^6.1.0",
|
|
129
|
+
"@metamask/eth-hd-keyring": "^15.0.0",
|
|
130
130
|
"@metamask/keyring-api": "^24.0.0",
|
|
131
131
|
"@metamask/keyring-internal-api": "^12.0.0",
|
|
132
132
|
"@metamask/providers": "^22.1.0",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSnapSignMessageRequest = exports.createSnapPublicKeyRequest = void 0;
|
|
4
|
-
const snapId = 'npm:@metamask/message-signing-snap';
|
|
5
|
-
/**
|
|
6
|
-
* Constructs Request to Message Signing Snap to get Public Key
|
|
7
|
-
*
|
|
8
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
9
|
-
* when multiple sources are available (Multi-SRP).
|
|
10
|
-
* @returns Snap Public Key Request
|
|
11
|
-
*/
|
|
12
|
-
function createSnapPublicKeyRequest(entropySourceId) {
|
|
13
|
-
return {
|
|
14
|
-
snapId,
|
|
15
|
-
origin: 'metamask',
|
|
16
|
-
handler: 'onRpcRequest',
|
|
17
|
-
request: {
|
|
18
|
-
method: 'getPublicKey',
|
|
19
|
-
...(entropySourceId ? { params: { entropySourceId } } : {}),
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.createSnapPublicKeyRequest = createSnapPublicKeyRequest;
|
|
24
|
-
/**
|
|
25
|
-
* Constructs Request to get Message Signing Snap to sign a message.
|
|
26
|
-
*
|
|
27
|
-
* @param message - message to sign
|
|
28
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
29
|
-
* when multiple sources are available (Multi-SRP).
|
|
30
|
-
* @returns Snap Sign Message Request
|
|
31
|
-
*/
|
|
32
|
-
function createSnapSignMessageRequest(message, entropySourceId) {
|
|
33
|
-
return {
|
|
34
|
-
snapId,
|
|
35
|
-
origin: 'metamask',
|
|
36
|
-
handler: 'onRpcRequest',
|
|
37
|
-
request: {
|
|
38
|
-
method: 'signMessage',
|
|
39
|
-
params: { message, ...(entropySourceId ? { entropySourceId } : {}) },
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
exports.createSnapSignMessageRequest = createSnapSignMessageRequest;
|
|
44
|
-
//# sourceMappingURL=auth-snap-requests.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":";;;AAQA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC;AAZD,gEAYC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,OAA6B,EAC7B,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACrE;KACF,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<\n SnapControllerHandleRequestAction['handler']\n>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message, ...(entropySourceId ? { entropySourceId } : {}) },\n },\n };\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { SnapControllerHandleRequestAction } from "@metamask/snaps-controllers";
|
|
2
|
-
type SnapRPCRequest = Parameters<SnapControllerHandleRequestAction['handler']>[0];
|
|
3
|
-
/**
|
|
4
|
-
* Constructs Request to Message Signing Snap to get Public Key
|
|
5
|
-
*
|
|
6
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
7
|
-
* when multiple sources are available (Multi-SRP).
|
|
8
|
-
* @returns Snap Public Key Request
|
|
9
|
-
*/
|
|
10
|
-
export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
|
|
11
|
-
/**
|
|
12
|
-
* Constructs Request to get Message Signing Snap to sign a message.
|
|
13
|
-
*
|
|
14
|
-
* @param message - message to sign
|
|
15
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
16
|
-
* when multiple sources are available (Multi-SRP).
|
|
17
|
-
* @returns Snap Sign Message Request
|
|
18
|
-
*/
|
|
19
|
-
export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=auth-snap-requests.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,oCAAoC;AAGrF,KAAK,cAAc,GAAG,UAAU,CAC9B,iCAAiC,CAAC,SAAS,CAAC,CAC7C,CAAC,CAAC,CAAC,CAAC;AAIL;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { SnapControllerHandleRequestAction } from "@metamask/snaps-controllers";
|
|
2
|
-
type SnapRPCRequest = Parameters<SnapControllerHandleRequestAction['handler']>[0];
|
|
3
|
-
/**
|
|
4
|
-
* Constructs Request to Message Signing Snap to get Public Key
|
|
5
|
-
*
|
|
6
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
7
|
-
* when multiple sources are available (Multi-SRP).
|
|
8
|
-
* @returns Snap Public Key Request
|
|
9
|
-
*/
|
|
10
|
-
export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
|
|
11
|
-
/**
|
|
12
|
-
* Constructs Request to get Message Signing Snap to sign a message.
|
|
13
|
-
*
|
|
14
|
-
* @param message - message to sign
|
|
15
|
-
* @param entropySourceId - The source of entropy to use for key generation,
|
|
16
|
-
* when multiple sources are available (Multi-SRP).
|
|
17
|
-
* @returns Snap Sign Message Request
|
|
18
|
-
*/
|
|
19
|
-
export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=auth-snap-requests.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,oCAAoC;AAGrF,KAAK,cAAc,GAAG,UAAU,CAC9B,iCAAiC,CAAC,SAAS,CAAC,CAC7C,CAAC,CAAC,CAAC,CAAC;AAIL;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
|