Skip to content

Commit

Permalink
hide condition expression from the taco api
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Aug 24, 2023
1 parent b2cf2e4 commit 9970cb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/taco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -23,13 +23,13 @@ export interface TacoMessageKit {
export const encrypt = async (
web3Provider: ethers.providers.Web3Provider,
message: string,
conditions: ConditionExpression,
condition: Condition,
ritualId: number
): Promise<TacoMessageKit> => {
const dkgRitual = await DkgClient.getFinalizedRitual(web3Provider, ritualId);
return await encryptLight(
message,
conditions,
condition,
dkgRitual.dkgPublicKey,
dkgRitual.dkgParams.threshold,
ritualId
Expand All @@ -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<TacoMessageKit> => {
const aad = conditions.asAad();
const aad = new ConditionExpression(condition).asAad();
const ciphertext = ferveoEncrypt(toBytes(message), aad, dkgPublicKey);
return {
ciphertext,
Expand Down
4 changes: 1 addition & 3 deletions test/unit/taco.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { aliceSecretKeyBytes } from './testVariables';

const {
predefined: { ERC721Ownership },
ConditionExpression,
} = conditions;

// Shared test variables
Expand All @@ -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';

Expand All @@ -48,7 +46,7 @@ describe('taco', () => {
const tacoMk = await taco.encrypt(
web3Provider,
message,
conditionExpr,
ownsNFT,
mockedDkg.ritualId
);

Expand Down

1 comment on commit 9970cb5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundled size for the package is listed below:

build/main/src/characters: 74.22 KB
build/main/src/kits: 19.53 KB
build/main/src/conditions/context: 42.97 KB
build/main/src/conditions/predefined: 19.53 KB
build/main/src/conditions/base: 54.69 KB
build/main/src/conditions: 156.25 KB
build/main/src/agents: 39.06 KB
build/main/src/sdk/strategy: 35.16 KB
build/main/src/sdk: 46.88 KB
build/main/src/policies: 19.53 KB
build/main/src: 449.22 KB
build/main/test: 46.88 KB
build/main/types/ethers-contracts/factories: 82.03 KB
build/main/types/ethers-contracts: 152.34 KB
build/main/types: 156.25 KB
build/main: 707.03 KB
build/module/src/characters: 74.22 KB
build/module/src/kits: 19.53 KB
build/module/src/conditions/context: 42.97 KB
build/module/src/conditions/predefined: 19.53 KB
build/module/src/conditions/base: 54.69 KB
build/module/src/conditions: 156.25 KB
build/module/src/agents: 39.06 KB
build/module/src/sdk/strategy: 31.25 KB
build/module/src/sdk: 42.97 KB
build/module/src/policies: 19.53 KB
build/module/src: 437.50 KB
build/module/test: 42.97 KB
build/module/types/ethers-contracts/factories: 82.03 KB
build/module/types/ethers-contracts: 152.34 KB
build/module/types: 156.25 KB
build/module: 691.41 KB
build: 1.37 MB

Please sign in to comment.