Skip to content

Commit

Permalink
[TEMP COMMIT] Show how self-delegation works in an example
Browse files Browse the repository at this point in the history
This currently works with tapir ritual 6, but only because it uses OpenAccessAuthorizer. In reality, this will fail with GlobalAllowList since this needs proper validation of evidence authorization.
This commit should be deleted before merging the PR, it's just illustrative
  • Loading branch information
cygnusv committed Nov 7, 2024
1 parent fa6633c commit d8b249d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import {
} from '@nucypher/taco';
import {
EIP4361AuthProvider,
SelfDelegateProvider,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco-auth';
import * as dotenv from 'dotenv';
import { ethers } from 'ethers';
import { Wallet, ethers } from 'ethers';

dotenv.config();

Expand Down Expand Up @@ -73,13 +74,18 @@ const encryptToBytes = async (messageString: string) => {
'Condition requires authentication',
);

const ephemeralPrivateKey = Wallet.createRandom().privateKey;
const selfDelegateProvider = new SelfDelegateProvider(encryptorSigner);

const appSideSigner = await selfDelegateProvider.createSelfDelegatedAppSideSigner(ephemeralPrivateKey);

const messageKit = await encrypt(
provider,
domain,
message,
hasPositiveBalance,
ritualId,
encryptorSigner,
appSideSigner,
);

return messageKit.toBytes();
Expand Down

0 comments on commit d8b249d

Please sign in to comment.