Skip to content

Commit d8b249d

Browse files
committed
[TEMP COMMIT] Show how self-delegation works in an example
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
1 parent fa6633c commit d8b249d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

examples/taco/nodejs/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {
1313
} from '@nucypher/taco';
1414
import {
1515
EIP4361AuthProvider,
16+
SelfDelegateProvider,
1617
USER_ADDRESS_PARAM_DEFAULT,
1718
} from '@nucypher/taco-auth';
1819
import * as dotenv from 'dotenv';
19-
import { ethers } from 'ethers';
20+
import { Wallet, ethers } from 'ethers';
2021

2122
dotenv.config();
2223

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

77+
const ephemeralPrivateKey = Wallet.createRandom().privateKey;
78+
const selfDelegateProvider = new SelfDelegateProvider(encryptorSigner);
79+
80+
const appSideSigner = await selfDelegateProvider.createSelfDelegatedAppSideSigner(ephemeralPrivateKey);
81+
7682
const messageKit = await encrypt(
7783
provider,
7884
domain,
7985
message,
8086
hasPositiveBalance,
8187
ritualId,
82-
encryptorSigner,
88+
appSideSigner,
8389
);
8490

8591
return messageKit.toBytes();

0 commit comments

Comments
 (0)