Skip to content

Commit 098c4f5

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 4e26e9d commit 098c4f5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

examples/taco/nodejs/src/index.ts

Lines changed: 7 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,17 @@ const encryptToBytes = async (messageString: string) => {
7374
'Condition requires authentication',
7475
);
7576

77+
const selfDelegateProvider = new SelfDelegateProvider(encryptorSigner);
78+
const ephemeralPrivateKey = Wallet.createRandom().privateKey;
79+
const [appSideSigner, authSignature] = await selfDelegateProvider.createSelfDelegatedAppSideSigner(ephemeralPrivateKey);
80+
7681
const messageKit = await encrypt(
7782
provider,
7883
domain,
7984
message,
8085
hasPositiveBalance,
8186
ritualId,
82-
encryptorSigner,
87+
appSideSigner,
8388
);
8489

8590
return messageKit.toBytes();

0 commit comments

Comments
 (0)