Skip to content

Commit

Permalink
fix: rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Jan 3, 2024
1 parent 49f86e2 commit 03523d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions tkey-mpc-web/tkey-mpc-react-bitcoin-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function App() {
if (sessionId) {
const signingParams: any = await sessionManager!.authorizeSession();
uiConsole("signingParams", signingParams);
// signingParams["ecPublicKey"] = Buffer.from(signingParams.ecPublicKey.padStart(64, "0"), "hex");

const factorKeyMetadata = await tKey.storageLayer.getMetadata<{
message: string;
Expand Down Expand Up @@ -239,13 +238,13 @@ function App() {
const { tssShare: tssShare2, tssIndex: tssShare2Index } = await tKey.getTSSShare(factorKey);

// 4. derive tss pub key, tss pubkey is implicitly formed using the dkgPubKey and the userShare (as well as userTSSIndex)
let tssPubKey = tKey.getTSSPub()
let tssPubKeyPoint = tKey.getTSSPub()
// const tssPubKey = getTSSPubKey(tssShare1PubKey, tssShare2PubKey, tssShare2Index);
// console.log("tssPub", tssPubKey);

const TSSPubKey = Buffer.from(`${tssPubKey.x.toString(16, 64)}${tssPubKey.y.toString(16, 64)}`, "hex");
const tssPubKey = Buffer.from(`${tssPubKeyPoint.x.toString(16, 64)}${tssPubKeyPoint.y.toString(16, 64)}`, "hex");

const prefixedTSSPubKey = Buffer.from(`04${TSSPubKey.toString("hex")}`, "hex");
const prefixedTSSPubKey = Buffer.from(`04${tssPubKey.toString("hex")}`, "hex");
const ECPubKey = ECPair.fromPublicKey(prefixedTSSPubKey, { network: testnet , compressed: true});
const { address: btcAddress } = p2pkh({ pubkey: ECPubKey.publicKey, network: testnet });

Expand All @@ -264,7 +263,6 @@ function App() {

const nodeDetails = await tKey.serviceProvider.getTSSNodeDetails()

const tsspubhex = Buffer.from(TSSPubKey).toString("hex");
const signingParams : SigningParams = {
oAuthShare: OAuthShare.toString("hex"),
factorKey: factorKey.toString("hex"),
Expand All @@ -273,7 +271,7 @@ function App() {
tssNonce,
tssShare2 : tssShare2.toString("hex"),
tssShare2Index,
compressedTSSPubKey: tsspubhex,
tssPubKey: tssPubKey.toString("hex"),
signatures,
userInfo: loginResponse!.userInfo,
nodeDetails,
Expand Down
10 changes: 5 additions & 5 deletions tkey-mpc-web/tkey-mpc-react-bitcoin-example/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type SigningParams = {
tssNonce: number;
tssShare2: string;
tssShare2Index: number;
compressedTSSPubKey: string;
tssPubKey: string;
signatures: string[];
userInfo: any;
nodeDetails: any;
Expand Down Expand Up @@ -63,7 +63,7 @@ export const generateTSSEndpoints = (tssNodeEndpoints: string[], parties: number

export const setupWeb3 = async (loginReponse: any, signingParams: SigningParams) => {
try {
const { tssNonce, tssShare2, tssShare2Index, compressedTSSPubKey, signatures, ecPublicKey, nodeDetails } = signingParams;
const { tssNonce, tssShare2, tssShare2Index, tssPubKey, signatures, ecPublicKey, nodeDetails } = signingParams;
const tssShare2BN = new BN(tssShare2, 16);

const { verifier, verifierId } = loginReponse.userInfo;
Expand Down Expand Up @@ -107,7 +107,7 @@ export const setupWeb3 = async (loginReponse: any, signingParams: SigningParams)
endpoints,
sockets,
share,
Buffer.from(compressedTSSPubKey, "hex").toString("base64"),
Buffer.from(tssPubKey, "hex").toString("base64"),
true,
tssImportUrl
);
Expand All @@ -129,8 +129,8 @@ export const setupWeb3 = async (loginReponse: any, signingParams: SigningParams)
return Promise.resolve(sigBuffer);
};

if (!compressedTSSPubKey) {
throw new Error(`compressedTSSPubKey does not exist ${compressedTSSPubKey}`);
if (!tssPubKey) {
throw new Error(`compressedTSSPubKey does not exist ${tssPubKey}`);
}

const toAsyncSigner = (signer: Signer): SignerAsync => {
Expand Down

0 comments on commit 03523d2

Please sign in to comment.