Skip to content

Commit b34e57b

Browse files
committed
bip340
1 parent 78457af commit b34e57b

File tree

8 files changed

+257
-149
lines changed

8 files changed

+257
-149
lines changed

demo/redirect-flow-example/package-lock.json

Lines changed: 23 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/redirect-flow-example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"private": true,
55
"dependencies": {
66
"@tkey/common-types": "^15.1.0",
7-
"@toruslabs/tss-dkls-lib": "^4.0.0",
8-
"@toruslabs/tss-frost-lib": "^1.0.0",
7+
"@toruslabs/tss-dkls-lib": "^5.0.0-alpha.0",
8+
"@toruslabs/tss-frost-lib": "^2.0.0-alpha.0",
9+
"@toruslabs/tss-frost-lib-bip340": "^0.1.0-alpha.0",
910
"@types/jest": "^27.5.2",
1011
"@types/node": "^16.18.48",
1112
"@types/react": "^18.3.11",

demo/redirect-flow-example/src/App.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ import {
1212
parseToken,
1313
factorKeyCurve,
1414
makeEthereumSigner,
15+
SigType,
1516
} from "@web3auth/mpc-core-kit";
1617
import Web3 from "web3";
1718
import { CHAIN_NAMESPACES, CustomChainConfig, IProvider } from "@web3auth/base";
1819
import { EthereumSigningProvider } from "@web3auth/ethereum-mpc-provider";
1920
import { BN } from "bn.js";
2021
import { KeyType, Point } from "@tkey/common-types";
21-
import { tssLib } from "@toruslabs/tss-dkls-lib";
22+
// import { tssLib } from "@toruslabs/tss-dkls-lib";
2223
// import{ tssLib } from "@toruslabs/tss-frost-lib";
24+
import{ tssLib } from "@toruslabs/tss-frost-lib-bip340";
2325

2426
import "./App.css";
2527
import jwt, { Algorithm } from "jsonwebtoken";
@@ -171,7 +173,7 @@ function App() {
171173
if (!factorPubs) {
172174
throw new Error("factorPubs not found");
173175
}
174-
const pubsHex = factorPubs[coreKitInstance.tKey.tssTag].map((pub: Point) => {
176+
const pubsHex = factorPubs[coreKitInstance.tKey.tssTag].map(pub => {
175177
return pub.toSEC1(factorKeyCurve, true).toString("hex");
176178
});
177179
uiConsole(pubsHex);
@@ -357,14 +359,15 @@ function App() {
357359
}
358360
const address = (await web3.eth.getAccounts())[0];
359361
const balance = web3.utils.fromWei(
360-
await web3.eth.getBalance(address) // Balance is in wei
362+
await web3.eth.getBalance(address), // Balance is in wei
363+
"ether"
361364
);
362365
uiConsole(balance);
363366
return balance;
364367
};
365368

366369
const signMessage = async (): Promise<any> => {
367-
if (coreKitInstance.keyType === "secp256k1") {
370+
if (coreKitInstance.sigType === SigType.ecdsa_secp256k1) {
368371
if (!web3) {
369372
uiConsole("web3 not initialized yet");
370373
return;
@@ -376,7 +379,7 @@ function App() {
376379

377380

378381
uiConsole(signedMessage);
379-
} else if (coreKitInstance.keyType === "ed25519") {
382+
} else if (coreKitInstance.sigType === SigType.ed25519 || coreKitInstance.sigType === SigType.bip340) {
380383
const msg = Buffer.from("hello signer!");
381384
const sig = await coreKitInstance.sign(msg);
382385
uiConsole(sig.toString("hex"));
@@ -512,7 +515,7 @@ function App() {
512515
const fromAddress = (await web3.eth.getAccounts())[0];
513516

514517
const destination = "0x2E464670992574A613f10F7682D5057fB507Cc21";
515-
const amount = web3.utils.toWei("0.0001"); // Convert 1 ether to wei
518+
const amount = web3.utils.toWei("0.0001", "ether"); // Convert 1 ether to wei
516519

517520
// Submit transaction to the blockchain and wait for it to be mined
518521
uiConsole("Sending transaction...");

0 commit comments

Comments
 (0)