Skip to content
Draft
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
26,005 changes: 3,875 additions & 22,130 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion packages/common-types/src/baseTypes/aggregateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ export interface IMetadata extends ISerializable {

nonce: number;

tssNonces?: {
[tssTag: string]: number;
};

tssPolyCommits?: {
[tssTag: string]: Point[];
};

factorPubs?: {
[tssTag: string]: Point[];
};

factorEncs?: {
[tssTag: string]: {
[factorPubID: string]: FactorEnc;
};
};

getShareIndexesForPolynomial(polyID: PolynomialID): string[];
getLatestPublicPolynomial(): PublicPolynomial;
addTSSData(tssData: {
Expand Down Expand Up @@ -142,6 +160,8 @@ export type KeyDetails = {
threshold: number;
totalShares: number;
shareDescriptions: ShareDescriptionMap;
deviceShare?: ShareStore;
userShare?: ShareStore;
};

export type TKeyArgs = {
Expand Down Expand Up @@ -252,8 +272,18 @@ export type LocalMetadataTransitions = [LocalTransitionShares, LocalTransitionDa

export interface ITKeyApi {
getMetadata(): IMetadata;
getServiceProvider(): IServiceProvider;
getStorageLayer(): IStorageLayer;
initialize(params: { input?: ShareStore; importKey?: BN; neverInitializeNewKey?: boolean }): Promise<KeyDetails>;
initialize(params: {
withShare?: ShareStore;
importKey?: BN;
neverInitializeNewKey?: boolean;
transitionMetadata?: IMetadata;
previouslyFetchedCloudMetadata?: IMetadata;
previousLocalMetadataTransitions?: LocalMetadataTransitions;
delete1OutOf1?: boolean;
// input?: ShareStore; importKey?: BN; neverInitializeNewKey?: boolean
}): Promise<KeyDetails>;
catchupToLatestShare(params: {
shareStore: ShareStore;
polyID?: string;
Expand Down
17 changes: 15 additions & 2 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ class ThresholdKey implements ITKey {
throw CoreError.metadataUndefined();
}

getServiceProvider(): IServiceProvider {
if (typeof this.serviceProvider !== "undefined") {
return this.serviceProvider;
}

throw CoreError.default("serviceProvider undefined");
}

async initialize(params?: {
withShare?: ShareStore;
importKey?: BN;
Expand Down Expand Up @@ -287,7 +295,7 @@ class ThresholdKey implements ITKey {
throw CoreError.default("key has not been generated yet");
}
// no metadata set, assumes new user
await this._initializeNewKey({
const result = await this._initializeNewKey({
initializeModules: true,
importedKey: importKey,
delete1OutOf1: p.delete1OutOf1,
Expand All @@ -296,7 +304,11 @@ class ThresholdKey implements ITKey {
const { factorEncs, factorPubs, tssPolyCommits } = await this._initializeNewTSSKey(this.tssTag, deviceTSSShare, factorPub, deviceTSSIndex);
this.metadata.addTSSData({ tssTag: this.tssTag, tssNonce: 0, tssPolyCommits, factorPubs, factorEncs });
}
return this.getKeyDetails();
const keyDetail = this.getKeyDetails();
keyDetail.deviceShare = result.deviceShare;
keyDetail.userShare = result.userShare;

return keyDetail;
}
// else we continue with catching up share and metadata
shareStore = ShareStore.fromJSON(rawServiceProviderShare);
Expand Down Expand Up @@ -1697,6 +1709,7 @@ class ThresholdKey implements ITKey {
getApi(): ITKeyApi {
return {
getMetadata: this.getMetadata.bind(this),
getServiceProvider: this.getServiceProvider.bind(this),
getStorageLayer: this.getStorageLayer.bind(this),
initialize: this.initialize.bind(this),
catchupToLatestShare: this.catchupToLatestShare.bind(this),
Expand Down
3 changes: 2 additions & 1 deletion packages/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
"@tkey/share-transfer": "^8.1.0-alpha.0",
"@tkey/storage-layer-torus": "^8.1.0-alpha.0",
"@toruslabs/eccrypto": "^2.1.1",
"@toruslabs/rss-client": "^1.4.1",
"bn.js": "^5.2.1"
},
"devDependencies": {
"@tkey/private-keys": "^8.1.0-alpha.0",
"@tkey/seed-phrase": "^8.1.0-alpha.0",
"@toruslabs/http-helpers": "^4.0.0",
"@toruslabs/rss-client": "^1.4.1",
"@tkey/tss": "^8.1.0-alpha.0",
"jsrsasign": "^10.6.1",
"web3-utils": "^1.8.1"
},
Expand Down
Loading