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
7 changes: 7 additions & 0 deletions packages/common-types/src/base/Point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ class Point implements IPoint {
};
}

toPointHex() {
return {
x: this.x.toString("hex").padStart(64, "0"),
y: this.y.toString("hex").padStart(64, "0"),
};
}

isIdentity(): boolean {
return this.x === null && this.y === null;
}
Expand Down
22 changes: 16 additions & 6 deletions packages/tss/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Point, TkeyStoreItemType } from "@tkey/common-types";
import { EncryptedMessage, PointHex } from "@toruslabs/rss-client";
import { KeyType } from "@toruslabs/torus.js";
import BN from "bn.js";

export type FactorEncType = "direct" | "hierarchical";
Expand Down Expand Up @@ -34,18 +35,18 @@ export interface IRemoteClientState {
signatures: string[];
}

export interface refreshRemoteTssType {
export interface RefreshRemoteTssParams {
// from client
factorEnc: FactorEnc;

factorPubs: Point[];
factorPubs: PointHex[];
targetIndexes: number[];
verifierNameVerifierId: string;

tssTag: string;
tssCommits: Point[];
tssCommits: PointHex[];
tssNonce: number;
newTSSServerPub: Point;
newTSSServerPub: PointHex;
// nodeIndexes : number[],

serverOpts: {
Expand All @@ -55,14 +56,23 @@ export interface refreshRemoteTssType {
selectedServers: number[];
authSignatures: string[];
};

curve: KeyType;
}

export interface RefreshRemoteTssReturnType {
tssTag: string;
tssNonce: number;
tssPolyCommits: Point[];
factorPubs: Point[];
tssPolyCommits: PointHex[];
factorPubs: PointHex[];
factorEncs: {
[factorPubID: string]: FactorEnc;
};
}

export interface CopyRemoteTssParams {
tssCommits: PointHex[];
factorPub: PointHex;
factorEnc: FactorEnc;
curve: KeyType;
}
26 changes: 18 additions & 8 deletions packages/tss/src/tss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ import { ec as EC } from "elliptic";
import { keccak256 } from "ethereum-cryptography/keccak";

import { TSSTorusServiceProvider } from ".";
import { FactorEnc, IAccountSaltStore, InitializeNewTSSKeyResult, IRemoteClientState, RefreshRemoteTssReturnType } from "./common";
import {
CopyRemoteTssParams,
FactorEnc,
IAccountSaltStore,
InitializeNewTSSKeyResult,
IRemoteClientState,
RefreshRemoteTssParams,
RefreshRemoteTssReturnType,
} from "./common";
import {
generateSalt,
getEd25519SeedStoreDomainKey,
Expand Down Expand Up @@ -569,22 +577,23 @@ export class TKeyTSS extends TKey {

const factorEnc = this.getFactorEncs(Point.fromSEC1(secp256k1, remoteClient.remoteFactorPub));

const dataRequired = {
const dataRequired: RefreshRemoteTssParams = {
factorEnc,
factorPubs: factorPubs.map((pub) => pub.toJSON()),
factorPubs: factorPubs.map((pub) => pub.toPointHex()),
targetIndexes: tssIndices,
verifierNameVerifierId,
tssTag: this.tssTag,
tssCommits: tssCommits.map((commit) => commit.toJSON()),
tssCommits: tssCommits.map((commit) => commit.toPointHex()),
tssNonce,
newTSSServerPub: newTSSServerPub.toJSON(),
newTSSServerPub: newTSSServerPub.toPointHex(),
serverOpts: {
selectedServers: finalSelectedServers,
serverEndpoints,
serverPubKeys,
serverThreshold,
authSignatures: remoteClient.signatures,
},
curve: this.tssKeyType,
};

const result = (
Expand Down Expand Up @@ -644,11 +653,12 @@ export class TKeyTSS extends TKey {
const { newFactorPub, tssIndex, remoteClient } = params;
const remoteFactorPub = Point.fromSEC1(secp256k1, remoteClient.remoteFactorPub);
const factorEnc = this.getFactorEncs(remoteFactorPub);
const tssCommits = this.getTSSCommits();
const dataRequired = {
const tssCommits = this.getTSSCommits().map((commit) => commit.toPointHex());
const dataRequired: CopyRemoteTssParams = {
factorEnc,
tssCommits,
factorPub: newFactorPub,
factorPub: newFactorPub.toPointHex(),
curve: this.tssKeyType,
};

const result = (
Expand Down