Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/validate-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
keyring-eth-ledger-bridge
keyring-eth-simple
keyring-eth-trezor
keyring-eth-mpc
keyring-internal-api
keyring-internal-snap-client
keyring-sdk
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This repository contains the following packages [^fn1]:
- [`@metamask/eth-hd-keyring`](packages/keyring-eth-hd)
- [`@metamask/eth-ledger-bridge-keyring`](packages/keyring-eth-ledger-bridge)
- [`@metamask/eth-money-keyring`](packages/keyring-eth-money)
- [`@metamask/eth-mpc-keyring`](packages/keyring-eth-mpc)
- [`@metamask/eth-qr-keyring`](packages/keyring-eth-qr)
- [`@metamask/eth-simple-keyring`](packages/keyring-eth-simple)
- [`@metamask/eth-snap-keyring`](packages/keyring-snap-bridge)
Expand Down Expand Up @@ -52,6 +53,7 @@ linkStyle default opacity:0.5
eth_hd_keyring(["@metamask/eth-hd-keyring"]);
eth_ledger_bridge_keyring(["@metamask/eth-ledger-bridge-keyring"]);
eth_money_keyring(["@metamask/eth-money-keyring"]);
eth_mpc_keyring(["@metamask/eth-mpc-keyring"]);
eth_qr_keyring(["@metamask/eth-qr-keyring"]);
eth_simple_keyring(["@metamask/eth-simple-keyring"]);
eth_trezor_keyring(["@metamask/eth-trezor-keyring"]);
Expand Down Expand Up @@ -79,6 +81,9 @@ linkStyle default opacity:0.5
eth_money_keyring --> keyring_api;
eth_money_keyring --> keyring_sdk;
eth_money_keyring --> keyring_utils;
eth_mpc_keyring --> keyring_api;
eth_mpc_keyring --> keyring_sdk;
eth_mpc_keyring --> keyring_utils;
eth_qr_keyring --> keyring_api;
eth_qr_keyring --> keyring_sdk;
eth_qr_keyring --> keyring_utils;
Expand Down
1 change: 1 addition & 0 deletions packages/keyring-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Includes an optional `scopes` field, since the scope cannot always be detected from the address alone (e.g. an EVM address is valid on every EVM chain). When omitted, the keyring decides the scopes.
- Add `address` capability to `KeyringCapabilities`, declaring whether a keyring supports importing watch-only accounts by address ([#643](https://github.com/MetaMask/accounts/pull/643))
- Add `KeyringType.WatchOnly` keyring type ([#644](https://github.com/MetaMask/accounts/pull/644))
- Add `KeyringType.Mpc` keyring type ([#641](https://github.com/MetaMask/accounts/pull/641))

## [24.1.0]

Expand Down
6 changes: 6 additions & 0 deletions packages/keyring-api/src/v2/api/keyring-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ export enum KeyringType {
* without any signing capability.
*/
WatchOnly = 'watch-only',

/**
* Represents a keyring that uses Multi-Party Computation (MPC) for key
* management and signing.
*/
Mpc = 'mpc',
}
1 change: 1 addition & 0 deletions packages/keyring-api/src/v2/api/keyring.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { ImportPrivateKeyFormat } from './private-key';
// Test KeyringType enum
expectAssignable<KeyringType>(KeyringType.Hd);
expectAssignable<KeyringType>(KeyringType.Money);
expectAssignable<KeyringType>(KeyringType.Mpc);
expectAssignable<KeyringType>(KeyringType.PrivateKey);
expectAssignable<KeyringType>(KeyringType.Qr);
expectAssignable<KeyringType>(KeyringType.Snap);
Expand Down
19 changes: 19 additions & 0 deletions packages/keyring-eth-mpc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Initial release of `@metamask/eth-mpc-keyring` ([#641](https://github.com/MetaMask/accounts/pull/641))
- The V1 MPC keyring implementation is not included yet.
- Add a V2 keyring implementation, available via the `./v2` export ([#641](https://github.com/MetaMask/accounts/pull/641))
- `MpcKeyring` (V2) implements the unified V2 `Keyring` interface with type `KeyringType.Mpc`.
- Account creation uses custom options: `{ type: 'custom', mode: 'create' | 'import' }`, and the keyring declares `custom.createAccounts` in its capabilities.
- Exposes `rotateKeyShares`, `checkKeyShare`, and `syncKeyShare` maintenance operations.

[Unreleased]: https://github.com/MetaMask/accounts/
15 changes: 15 additions & 0 deletions packages/keyring-eth-mpc/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2020 MetaMask

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 changes: 18 additions & 0 deletions packages/keyring-eth-mpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MPC Keyring

A Keyring for Ethereum accounts that uses Multi-Party Computation (MPC) for key management and signing, built on top of the [MFA Wallet SDK](https://github.com/MetaMask/mfa-wallet-sdk).

> [!NOTE]
> The full V1 MPC keyring implementation is not included yet. Implement the `MpcKeyringV1` contract yourself and pass it to the V2 keyring; the official implementation will be provided in a later release, once the MFA Wallet SDK packages are releasable.

## Installation

`yarn add @metamask/eth-mpc-keyring`

or

`npm install @metamask/eth-mpc-keyring`

## Contributing

This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/accounts#readme).
32 changes: 32 additions & 0 deletions packages/keyring-eth-mpc/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

const merge = require('deepmerge');
const path = require('path');

const baseConfig = require('../../jest.config.packages');

const displayName = path.basename(__dirname);

module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['./src/tests'],

// The glob patterns Jest uses to detect test files
testMatch: ['**/*.test.[jt]s?(x)'],

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
});
94 changes: 94 additions & 0 deletions packages/keyring-eth-mpc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"name": "@metamask/eth-mpc-keyring",
"version": "0.0.0",
"description": "A Keyring for Ethereum accounts that uses Multi-Party Computation (MPC) for key management and signing",
"keywords": [
"ethereum",
"keyring"
],
"homepage": "https://github.com/MetaMask/accounts/tree/main/packages/keyring-eth-mpc#readme",
"bugs": {
"url": "https://github.com/MetaMask/accounts/issues"
},
"license": "ISC",
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/accounts.git"
},
"files": [
"dist/",
"v2.js"
],
"sideEffects": false,
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./v2": {
"import": {
"types": "./dist/v2/index.d.mts",
"default": "./dist/v2/index.mjs"
},
"require": {
"types": "./dist/v2/index.d.cts",
"default": "./dist/v2/index.cjs"
}
},
"./package.json": "./package.json"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
"build:clean": "yarn build --clean",
"build:docs": "typedoc",
"changelog:update": "../../scripts/update-changelog.sh @metamask/eth-mpc-keyring",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/eth-mpc-keyring",
"publish:preview": "yarn npm publish --tag preview",
"test": "yarn test:source && yarn test:types",
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
"since-latest-release": "../../scripts/since-latest-release.sh",
"test:source": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
"test:types": "../../scripts/tsd-test.sh ./src",
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/keyring-api": "^24.1.0",
"@metamask/keyring-sdk": "^3.1.0",
"@metamask/keyring-utils": "^5.0.0",
"@metamask/utils": "^11.11.0"
},
"devDependencies": {
"@ethereumjs/tx": "^5.4.0",
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^6.1.0",
"@metamask/eth-sig-util": "^9.0.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^29.5.12",
"deepmerge": "^4.2.2",
"jest": "^29.5.0",
"typescript": "~5.3.3"
},
"engines": {
"node": ">=22"
},
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false
}
}
}
2 changes: 2 additions & 0 deletions packages/keyring-eth-mpc/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { MpcKeyringSetupMode } from './types';
export type { MpcKeyring } from './types';
38 changes: 38 additions & 0 deletions packages/keyring-eth-mpc/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { EthKeyring } from '@metamask/keyring-utils';

/** The MPC keyring setup modes. */
export const MpcKeyringSetupMode = {
Create: 'create',
Import: 'import',
} as const;
export type MpcKeyringSetupMode =
`${(typeof MpcKeyringSetupMode)[keyof typeof MpcKeyringSetupMode]}`;

/**
* The MPC keyring contract.
*/
export type MpcKeyring = EthKeyring & {
/**
* Run key generation or import.
*
* @param mode - The MPC setup mode.
*/
init(mode?: MpcKeyringSetupMode): Promise<void>;

/**
* Rotate the MPC key shares.
*/
rotateKeyShares(): Promise<void>;

/**
* Check the MPC key share state.
*
* @returns Whether the key share is up to date.
*/
checkKeyShare(): Promise<boolean>;

/**
* Synchronize the MPC key share.
*/
syncKeyShare(): Promise<void>;
};
5 changes: 5 additions & 0 deletions packages/keyring-eth-mpc/src/v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
MpcKeyring,
type MpcCreateAccountOptions,
type MpcKeyringOptions,
} from './mpc-keyring';
Loading
Loading