Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
095ec12
feat: upgrade node version
tuna1207 Feb 25, 2026
a931311
feat: add pr template
tuna1207 Feb 25, 2026
f035f5d
feat: upgrade deps
tuna1207 Feb 25, 2026
09876d4
feat: Buffer remove phase 1 before ecc to noble
tuna1207 Feb 26, 2026
775f6de
feat: update deps
hieu-w Feb 26, 2026
8eb42d7
fix: update common-types
hieu-w Feb 26, 2026
3e9b8dc
fix: update common utils
hieu-w Feb 26, 2026
90864cc
fix: refactor Point constructor to accept pure bigint
hieu-w Feb 26, 2026
dc395f3
refactor(common-types): replace bn.js/elliptic with bigint/@noble/curves
hieu-w Feb 26, 2026
463ff9a
fix: remove packages
hieu-w Feb 26, 2026
83b498f
refactor(core): migrate lagrangeInterpolatePolynomial to bigint/@nobl…
hieu-w Feb 26, 2026
bfc7a30
refactor(core): replace elliptic sign/verify with noble secp256k1 in …
hieu-w Feb 26, 2026
254429d
refactor(core): migrate metadata.ts from BN/elliptic to bigint/noble
hieu-w Feb 26, 2026
88f7f3b
refactor(core): migrate core.ts from BN/elliptic to bigint/noble
hieu-w Feb 26, 2026
3a3653b
refactor(service-providers): migrate base/torus/sfa from BN/elliptic …
hieu-w Feb 26, 2026
1dbc33f
refactor(modules): migrate storage-layer, security-questions, private…
hieu-w Feb 26, 2026
7829ba5
test: migrate test files from BN/elliptic to bigint/noble
hieu-w Feb 26, 2026
a916c5b
Update package-lock.json
hieu-w Feb 26, 2026
f59dbd3
fix: build
hieu-w Feb 26, 2026
1b93f8d
fix: test
hieu-w Feb 27, 2026
cc8ca5e
fix: remove tss package
hieu-w Feb 27, 2026
c46e1f4
chore: upgrade ci actions version
tuna1207 Feb 27, 2026
78b7ac2
fix: test
hieu-w Feb 27, 2026
8e0be90
fix: update readme
hieu-w Feb 27, 2026
3d83da8
fix: infura key in test as ci secret
hieu-w Feb 27, 2026
1cb640e
fix: update deps
hieu-w Feb 27, 2026
ab35965
fix: test
hieu-w Feb 27, 2026
be21e01
fix: ci
hieu-w Feb 27, 2026
ea4f824
fix: clean up
hieu-w Feb 27, 2026
dfb0c0d
fix: jsdom test issue
hieu-w Feb 27, 2026
bfc0584
fix: replace etherjs by viem
hieu-w Feb 27, 2026
7e61572
fix: remove hardcode recover char
hieu-w Mar 2, 2026
ffeb23c
fix: remove randomBytes
hieu-w Mar 2, 2026
e3ecf98
fix: comments
hieu-w Mar 2, 2026
64b570f
fix: rename BNString to BigIntString
hieu-w Mar 2, 2026
c56be57
lint fixes
chaitanyapotti Mar 2, 2026
886652d
more lint fixes
chaitanyapotti Mar 2, 2026
82fa424
lint
chaitanyapotti Mar 2, 2026
24ed12a
Merge branch 'feat/stack-upgrades' of https://github.com/MetaMask/tke…
hieu-w Mar 2, 2026
ce1473f
fix: remove unuse package
hieu-w Mar 2, 2026
bf00981
fix: remove base64url
hieu-w Mar 2, 2026
42bc9d9
fix: remove BigInString
hieu-w Mar 2, 2026
3ae8d61
fix: test
hieu-w Mar 2, 2026
a32d328
fix: remove bigin | null, in IPoint
hieu-w Mar 2, 2026
6d6c2e2
fix: comments
hieu-w Mar 2, 2026
8ed588d
fix: comment
hieu-w Mar 2, 2026
c24a264
fix test
chaitanyapotti Mar 2, 2026
2e25404
undo fix
chaitanyapotti Mar 2, 2026
411e983
fix: crash when privKey is undefined
hieu-w Mar 3, 2026
44252f7
fix: hexToBigInt("") silently returns 0n
hieu-w Mar 3, 2026
45e8cf1
fix: use noble to gen privKey
hieu-w Mar 3, 2026
63bb0ab
fix: shareToShareStore unreachable return
hieu-w Mar 3, 2026
512630c
fix: remove unuse code
hieu-w Mar 3, 2026
d95ef69
fix: clean up
hieu-w Mar 3, 2026
d1d6f9f
fix: lint
hieu-w Mar 3, 2026
13c4454
fix: add compatible test in authMetadata
hieu-w Mar 3, 2026
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
3 changes: 3 additions & 0 deletions .cursor/worktrees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"setup-worktree": ["npm install"]
}
29 changes: 29 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Jira Link

<!-- Link to the Jira ticket (if applicable) -->

## Description

<!-- Describe your changes in detail -->

## How has this been tested?

<!-- Please describe how you tested your changes -->

## Screenshots (if appropriate)

<!-- Add screenshots if UI changes are involved -->

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist

- [ ] My code follows the code style of this project. (run lint)
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
8 changes: 4 additions & 4 deletions .github/workflows/backward.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
name: Backward Compatibility Tests
strategy:
matrix:
node: ["22.x"]
node: ["24.x"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: checkout tkey repo
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: tkey

Expand All @@ -35,7 +35,7 @@ jobs:
cd ./tkey

- name: Set up node
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: "npm"
Expand Down Expand Up @@ -65,4 +65,4 @@ jobs:
- name: Running comp tests
run: |
cd ./backward-compatibility-tests
npm test
npm test
10 changes: 5 additions & 5 deletions .github/workflows/browserTests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: BrowserTests

on:
on:
create: #[push]
workflow_dispatch:
env:
PLAYWRIGHT_BROWSERS_PATH: 0
NODE_VERSION: 20
NODE_VERSION: 24
FORCE_COLOR: 3

jobs:
Expand All @@ -26,10 +26,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:

# - name: Browser Test Production webkit (prod)
# if: startsWith(matrix.browser, 'webkit')
# run: npm run browser-tests:local-prod-webkit
# run: npm run browser-tests:local-prod-webkit
8 changes: 4 additions & 4 deletions .github/workflows/buildMocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ jobs:
name: Backward Compatibility Tests
strategy:
matrix:
node: ["22.x"]
node: ["24.x"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: checkout tkey repo
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: ./tkey

- name: Set up node
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: "npm"
Expand Down Expand Up @@ -65,4 +65,4 @@ jobs:
branch: master
cwd: "./backward-compatibility-tests"
message: "Building Mocks from tkey workflow"
push: true
push: true
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ jobs:
test:
strategy:
matrix:
node: ["22.x"]
node: ["24.x"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Check out Git repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up node
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: "npm"
Expand All @@ -29,6 +29,10 @@ jobs:

- name: Test Development
run: npm run test
env:
TEST_RPC_TARGET: ${{ secrets.TEST_RPC_TARGET }}

- name: Test Production
run: npm run test-production
env:
TEST_RPC_TARGET: ${{ secrets.TEST_RPC_TARGET }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
>=18.x
>=24.x
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

tKey is the underlying SDK used to implement [Web3Auth Plug n Play](https://github.com/web3auth/web3auth). This package can also be used to self host Web3Auth in your own system. tKey stands for Threshold Key, which refers to the management keys & shares generated using threshold cryptography.

> **v16 Breaking Change:** All cryptographic primitives have been migrated from `bn.js`/`elliptic`/`Buffer` to native `bigint`/`@noble/curves`/`Uint8Array`. See the [Migration Guide](#migration-guide) below.

## The `tKey` SDK

The `tKey` SDK manages private keys by generating shares of it using Shamir Secret Sharing. For example, for a 2 out of 3 (2/3) setup, we give the
Expand All @@ -28,6 +30,8 @@ For more information, check out the [technical overview](https://hackmd.io/Tej2t
- Typescript compatible. Includes Type definitions
- Fully composable API
- Module support (Include only those modules which you require)
- Modern cryptography via [`@noble/curves`](https://github.com/paulmillr/noble-curves) (secp256k1, ed25519)
- Zero dependency on `Buffer` — uses native `Uint8Array`
- [Audited](https://github.com/tkey/audit)

## Packages
Expand All @@ -40,7 +44,7 @@ For more information, check out the [technical overview](https://hackmd.io/Tej2t
| `@tkey/core` | [![npm version](https://img.shields.io/npm/v/@tkey/core?label=%22%22)](https://www.npmjs.com/package/@tkey/core/v/latest) | [![minzip](https://img.shields.io/bundlephobia/minzip/@tkey/core?label=%22%22)](https://bundlephobia.com/result?p=@tkey/core@latest) | Core functionalities for creating a tkey |
| 🐕‍🦺 **Service Provider** |
| `@tkey/service-provider-torus` | [![npm version](https://img.shields.io/npm/v/@tkey/service-provider-torus?label=%22%22)](https://www.npmjs.com/package/@tkey/service-provider-torus/v/latest) | [![minzip](https://img.shields.io/bundlephobia/minzip/@tkey/service-provider-torus?label=%22%22)](https://bundlephobia.com/result?p=@tkey/service-provider-torus@latest) | `@service-provider-base` with DirectAuth functionality |
| 🗳 **Storage Layer** |
| 🗳 **Storage Layer** |
| `@tkey/storage-layer-torus` | [![npm version](https://img.shields.io/npm/v/@tkey/storage-layer-torus?label=%22%22)](https://www.npmjs.com/package/@tkey/storage-layer-torus/v/latest) | [![minzip](https://img.shields.io/bundlephobia/minzip/@tkey/storage-layer-torus?label=%22%22)](https://bundlephobia.com/result?p=@tkey/storage-layer-torus@latest) | get/set metadata for various shares |
| 🔌 **Modules** |
| `@tkey/chrome-storage` | [![npm version](https://img.shields.io/npm/v/@tkey/chrome-storage?label=%22%22)](https://www.npmjs.com/package/@tkey/chrome-storage/v/latest) | [![minzip](https://img.shields.io/bundlephobia/minzip/@tkey/chrome-storage?label=%22%22)](https://bundlephobia.com/result?p=@tkey/chrome-storage@latest) | Add/remove a share from chrome extension storage |
Expand All @@ -53,12 +57,37 @@ For more information, check out the [technical overview](https://hackmd.io/Tej2t
| 🐉 **Low-Level** |
| `@tkey/common-types` | [![npm version](https://img.shields.io/npm/v/@tkey/common-types?label=%22%22)](https://www.npmjs.com/package/@tkey/common-types/v/latest) | [![minzip](https://img.shields.io/bundlephobia/minzip/@tkey/common-types?label=%22%22)](https://bundlephobia.com/result?p=@tkey/common-types@latest) | Shared [TypeScript](https://www.typescriptlang.org/) Types |

## Migration Guide

### v16: `bigint` / `@noble/curves` / `Uint8Array`

v16 removes all legacy cryptography dependencies in favor of modern, audited alternatives:

| Before | After |
| ------------------------- | ------------------------- |
| `bn.js` (`BN`) | Native `bigint` |
| `elliptic` | `@noble/curves/secp256k1` |
| `@toruslabs/tweetnacl-js` | `@noble/curves/ed25519` |
| `Buffer` | `Uint8Array` |

**What you need to change:**

- **Private keys and share values** are now `bigint` instead of `BN`. Replace `new BN(hex, 16)` with `BigInt(\`0x${hex}\`)`.
- **Public keys and encrypted data** are now `Uint8Array` instead of `Buffer`. Use `hexToBytes` / `bytesToHex` from `@toruslabs/metadata-helpers` for conversions.
- **`BNString` type** has been removed. APIs now use `bigint` directly (was `BN | string`).
- **JSON serialization** of objects containing `bigint` requires the `bigIntReplacer` from `@tkey/common-types`:
```js
import { bigIntReplacer } from "@tkey/common-types";
JSON.stringify(thresholdKey, bigIntReplacer);
```
- **`@tkey/tss`** has been removed from this package and will be migrated separately.

## Building the SDK Locally

### Requirements

- This package requires a peer dependency of `@babel/runtime`
- Node 18+
- Node 22+

### Installation

Expand Down
6 changes: 6 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ export default [
},
},
},
{
files: ["test/**/*.test.js", "test/**/*.test.ts"],
rules: {
"import/no-extraneous-dependencies": "off",
},
},
];
Loading