From 9970cb56f62f57d51f1114e65c322e966f7194d1 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Thu, 24 Aug 2023 13:08:49 +0200 Subject: [PATCH] hide condition expression from the taco api --- src/taco.ts | 10 +++++----- test/unit/taco.test.ts | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/taco.ts b/src/taco.ts index 816d24943..f378477a3 100644 --- a/src/taco.ts +++ b/src/taco.ts @@ -6,7 +6,7 @@ import { import { ethers } from 'ethers'; import { ThresholdDecrypter } from './characters/cbd-recipient'; -import { ConditionExpression } from './conditions'; +import { Condition, ConditionExpression } from './conditions'; import { DkgClient } from './dkg'; import { toBytes } from './utils'; @@ -23,13 +23,13 @@ export interface TacoMessageKit { export const encrypt = async ( web3Provider: ethers.providers.Web3Provider, message: string, - conditions: ConditionExpression, + condition: Condition, ritualId: number ): Promise => { const dkgRitual = await DkgClient.getFinalizedRitual(web3Provider, ritualId); return await encryptLight( message, - conditions, + condition, dkgRitual.dkgPublicKey, dkgRitual.dkgParams.threshold, ritualId @@ -38,13 +38,13 @@ export const encrypt = async ( export const encryptLight = async ( message: string, - conditions: ConditionExpression, + condition: Condition, dkgPublicKey: DkgPublicKey, // TODO: Remove these parameters after fixing TacoMessageKit threshold: number, ritualId: number ): Promise => { - const aad = conditions.asAad(); + const aad = new ConditionExpression(condition).asAad(); const ciphertext = ferveoEncrypt(toBytes(message), aad, dkgPublicKey); return { ciphertext, diff --git a/test/unit/taco.test.ts b/test/unit/taco.test.ts index 907b58f86..619620202 100644 --- a/test/unit/taco.test.ts +++ b/test/unit/taco.test.ts @@ -24,7 +24,6 @@ import { aliceSecretKeyBytes } from './testVariables'; const { predefined: { ERC721Ownership }, - ConditionExpression, } = conditions; // Shared test variables @@ -34,7 +33,6 @@ const ownsNFT = new ERC721Ownership({ parameters: [3591], chain: 5, }); -const conditionExpr = new ConditionExpression(ownsNFT); const variant = FerveoVariant.precomputed; const message = 'this is a secret'; @@ -48,7 +46,7 @@ describe('taco', () => { const tacoMk = await taco.encrypt( web3Provider, message, - conditionExpr, + ownsNFT, mockedDkg.ritualId );