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 4, 2024
1 parent 1143204 commit 1aa77f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 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,17 @@ const encryptToBytes = async (messageString: string) => {
'Condition requires authentication',
);

const selfDelegateProvider = new SelfDelegateProvider(encryptorSigner);
const ephemeralPrivateKey = Wallet.createRandom().privateKey;
const [appSideSigner, authSignature] = await selfDelegateProvider.createSelfDelegatedAppSideSigner(ephemeralPrivateKey);

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

return messageKit.toBytes();
Expand Down

0 comments on commit 1aa77f3

Please sign in to comment.