diff --git a/packages/shared/package.json b/packages/shared/package.json index 4915cf8ed..b97994e9f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -42,7 +42,7 @@ "dependencies": { "@ethersproject/abi": "^5.7.0", "@ethersproject/providers": "^5.7.2", - "@nucypher/nucypher-contracts": "0.10.1", + "@nucypher/nucypher-contracts": "0.12.0", "@nucypher/nucypher-core": "0.13.0-alpha.1", "axios": "^1.6.0", "deep-equal": "^2.2.1", diff --git a/packages/shared/src/contracts/agents/coordinator.ts b/packages/shared/src/contracts/agents/coordinator.ts index 49a0f0a5d..e4e65b6d6 100644 --- a/packages/shared/src/contracts/agents/coordinator.ts +++ b/packages/shared/src/contracts/agents/coordinator.ts @@ -36,11 +36,12 @@ export type DkgParticipant = { export enum DkgRitualState { NON_INITIATED, - AWAITING_TRANSCRIPTS, - AWAITING_AGGREGATIONS, - TIMEOUT, - INVALID, - FINALIZED, + DKG_AWAITING_TRANSCRIPTS, + DKG_AWAITING_AGGREGATIONS, + DKG_TIMEOUT, + DKG_INVALID, + ACTIVE, + EXPIRED, } export class DkgCoordinatorAgent { diff --git a/packages/taco/src/dkg.ts b/packages/taco/src/dkg.ts index cbc908f7d..8e6ce50ec 100644 --- a/packages/taco/src/dkg.ts +++ b/packages/taco/src/dkg.ts @@ -157,13 +157,13 @@ export class DkgClient { ); } - public static async getFinalizedRitual( + public static async getActiveRitual( provider: ethers.providers.Provider, domain: Domain, ritualId: number, ): Promise { const ritual = await DkgClient.getRitual(provider, domain, ritualId); - if (ritual.state !== DkgRitualState.FINALIZED) { + if (ritual.state !== DkgRitualState.ACTIVE) { throw new Error(ERR_RITUAL_NOT_FINALIZED(ritualId, ritual)); } return ritual; diff --git a/packages/taco/src/taco.ts b/packages/taco/src/taco.ts index 236fba1a5..a9d9054b2 100644 --- a/packages/taco/src/taco.ts +++ b/packages/taco/src/taco.ts @@ -25,7 +25,7 @@ import { DkgClient } from './dkg'; import { retrieveAndDecrypt } from './tdec'; /** - * Encrypts a message under given conditions using a public key from a finalized DKG ritual. + * Encrypts a message under given conditions using a public key from an active DKG ritual. * * @export * @param {ethers.providers.Provider} provider - Instance of ethers provider which is used to interact with @@ -42,7 +42,7 @@ import { retrieveAndDecrypt } from './tdec'; * @returns {Promise} Returns Promise that resolves with an instance of ThresholdMessageKit. * It represents the encrypted message. * - * @throws {Error} If the finalized DKG Ritual cannot be retrieved an error is thrown. + * @throws {Error} If the active DKG Ritual cannot be retrieved an error is thrown. */ export const encrypt = async ( provider: ethers.providers.Provider, @@ -64,11 +64,7 @@ export const encrypt = async ( // // Given that we just initialized the ritual, this should never happen // throw new Error('Ritual ID is undefined'); // } - const dkgRitual = await DkgClient.getFinalizedRitual( - provider, - domain, - ritualId, - ); + const dkgRitual = await DkgClient.getActiveRitual(provider, domain, ritualId); return await encryptWithPublicKey( message, @@ -85,7 +81,7 @@ export const encrypt = async ( * @param {Uint8Array | string} message - The message to be encrypted. * @param {Condition} condition - Condition under which the message will be encrypted. Those conditions must be * satisfied in order to decrypt the message. - * @param {DkgPublicKey} dkgPublicKey - The public key of a finalized DKG Ritual to be used for encryption + * @param {DkgPublicKey} dkgPublicKey - The public key of an active DKG Ritual to be used for encryption * @param {ethers.Signer} authSigner - The signer that will be used to sign the encrypter authorization. * * @returns {Promise} Returns Promise that resolves with an instance of ThresholdMessageKit. @@ -138,7 +134,7 @@ export const encryptWithPublicKey = async ( * * @returns {Promise} Returns Promise that resolves with a decrypted message * - * @throws {Error} If the finalized DKG Ritual cannot be retrieved or decryption process throws an error, + * @throws {Error} If the active DKG Ritual cannot be retrieved or decryption process throws an error, * an error is thrown. */ export const decrypt = async ( @@ -158,7 +154,7 @@ export const decrypt = async ( domain, messageKit.acp.publicKey, ); - const ritual = await DkgClient.getFinalizedRitual(provider, domain, ritualId); + const ritual = await DkgClient.getActiveRitual(provider, domain, ritualId); return retrieveAndDecrypt( provider, domain, diff --git a/packages/taco/test/taco.test.ts b/packages/taco/test/taco.test.ts index f06b4dfc2..398398c7a 100644 --- a/packages/taco/test/taco.test.ts +++ b/packages/taco/test/taco.test.ts @@ -21,7 +21,7 @@ import { conditions, domains, toBytes } from '../src'; import { fakeDkgRitual, mockDkgParticipants, - mockGetFinalizedRitual, + mockGetActiveRitual, mockGetParticipants, mockMakeSessionKey, } from './test-utils'; @@ -44,7 +44,7 @@ describe('taco', () => { const mockedDkgRitual = fakeDkgRitual(mockedDkg); const provider = fakeProvider(aliceSecretKeyBytes); const signer = fakeSigner(aliceSecretKeyBytes); - const getFinalizedRitualSpy = mockGetFinalizedRitual(mockedDkgRitual); + const getFinalizedRitualSpy = mockGetActiveRitual(mockedDkgRitual); const messageKit = await taco.encrypt( provider, @@ -77,7 +77,7 @@ describe('taco', () => { const getRitualIdFromPublicKey = mockGetRitualIdFromPublicKey( mockedDkg.ritualId, ); - const getRitualSpy = mockGetFinalizedRitual(mockedDkgRitual); + const getRitualSpy = mockGetActiveRitual(mockedDkgRitual); const decryptedMessage = await taco.decrypt( provider, diff --git a/packages/taco/test/test-utils.ts b/packages/taco/test/test-utils.ts index 024197bd2..5a0083503 100644 --- a/packages/taco/test/test-utils.ts +++ b/packages/taco/test/test-utils.ts @@ -171,7 +171,7 @@ export const fakeDkgRitual = (ritual: { ritual.dkg.publicKey(), ritual.sharesNum, ritual.threshold, - DkgRitualState.FINALIZED, + DkgRitualState.ACTIVE, ); }; @@ -181,8 +181,8 @@ export const mockGetRitual = (): SpyInstance => { }); }; -export const mockGetFinalizedRitual = (dkgRitual: DkgRitual): SpyInstance => { - return vi.spyOn(DkgClient, 'getFinalizedRitual').mockImplementation(() => { +export const mockGetActiveRitual = (dkgRitual: DkgRitual): SpyInstance => { + return vi.spyOn(DkgClient, 'getActiveRitual').mockImplementation(() => { return Promise.resolve(dkgRitual); }); }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dac448aee..5a9419a38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -482,8 +482,8 @@ importers: specifier: ^5.7.2 version: 5.7.2 '@nucypher/nucypher-contracts': - specifier: 0.10.1 - version: 0.10.1 + specifier: 0.12.0 + version: 0.12.0 '@nucypher/nucypher-core': specifier: 0.13.0-alpha.1 version: 0.13.0-alpha.1 @@ -3589,8 +3589,8 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 - /@nucypher/nucypher-contracts@0.10.1: - resolution: {integrity: sha512-uLXcGp0Pq3B9qinEbK0FgHr7R1sVbhmSwhMEEIzYdLg2l3JLE+GxrguyV8z6xkRnskPDL2eAbH8TsEOU185xIw==} + /@nucypher/nucypher-contracts@0.12.0: + resolution: {integrity: sha512-utlqZuSWnfBHNwMap+bxNz/h11GO+WwjsR8neDrc7PLD9IcIRkpDy1s2eBeK0fZhnOUin/vNqJ/i/GSEpDkqVw==} dev: false /@nucypher/nucypher-core@0.13.0-alpha.1: