Skip to content

Commit

Permalink
Construct a PorterClient earlier in the call stack for decrypt(), and…
Browse files Browse the repository at this point in the history
… then pass the client to calls later in the stack instead of passing around the porterUri(s).
  • Loading branch information
derekpierre committed Aug 16, 2024
1 parent 8c30bc4 commit 81d9006
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/taco/src/taco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
fromHexString,
getPorterUris,
GlobalAllowListAgent,
PorterClient,
toBytes,
} from '@nucypher/shared';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -143,6 +144,7 @@ export const decrypt = async (
const porterUrisFull: string[] = porterUris
? porterUris
: await getPorterUris(domain);
const porter = new PorterClient(porterUrisFull);

const ritualId = await DkgCoordinatorAgent.getRitualIdFromPublicKey(
provider,
Expand All @@ -152,7 +154,7 @@ export const decrypt = async (
return retrieveAndDecrypt(
provider,
domain,
porterUrisFull,
porter,
messageKit,
ritualId,
context,
Expand Down
7 changes: 3 additions & 4 deletions packages/taco/src/tdec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ export const encryptMessage = async (
export const retrieveAndDecrypt = async (
provider: ethers.providers.Provider,
domain: Domain,
porterUris: string[],
porter: PorterClient,
thresholdMessageKit: ThresholdMessageKit,
ritualId: number,
context?: ConditionContext,
): Promise<Uint8Array> => {
const decryptionShares = await retrieve(
provider,
domain,
porterUris,
porter,
thresholdMessageKit,
ritualId,
context,
Expand All @@ -82,7 +82,7 @@ export const retrieveAndDecrypt = async (
const retrieve = async (
provider: ethers.providers.Provider,
domain: Domain,
porterUris: string[],
porter: PorterClient,
thresholdMessageKit: ThresholdMessageKit,
ritualId: number,
context?: ConditionContext,
Expand All @@ -106,7 +106,6 @@ const retrieve = async (
thresholdMessageKit,
);

const porter = new PorterClient(porterUris);
const { encryptedResponses, errors } = await porter.tacoDecrypt(
encryptedRequests,
ritual.threshold,
Expand Down

0 comments on commit 81d9006

Please sign in to comment.