Skip to content

Commit 9ac6afd

Browse files
committed
feat: Log encryption metadata to compare against node logs
1 parent e505d90 commit 9ac6afd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ export class LitNodeClientNodeJs
12661266
const hashOfConditions: ArrayBuffer | undefined =
12671267
await this.getHashedAccessControlConditions(params);
12681268

1269+
log('hashOfConditions', hashOfConditions);
1270+
12691271
if (!hashOfConditions) {
12701272
throw new InvalidArgumentException(
12711273
{
@@ -1282,23 +1284,30 @@ export class LitNodeClientNodeJs
12821284
'base16'
12831285
);
12841286

1287+
log('hashOfConditionsStr', hashOfConditionsStr);
1288+
12851289
// ========== Hashing Private Data ==========
12861290
// hash the private data
12871291
const hashOfPrivateData = await crypto.subtle.digest(
12881292
'SHA-256',
12891293
params.dataToEncrypt
12901294
);
1295+
log('hashOfPrivateData', hashOfPrivateData);
12911296
const hashOfPrivateDataStr = uint8arrayToString(
12921297
new Uint8Array(hashOfPrivateData),
12931298
'base16'
12941299
);
12951300

1301+
log('hashOfPrivateDataStr', hashOfPrivateDataStr);
1302+
12961303
// ========== Assemble identity parameter ==========
12971304
const identityParam = this._getIdentityParamForEncryption(
12981305
hashOfConditionsStr,
12991306
hashOfPrivateDataStr
13001307
);
13011308

1309+
log('identityParam', identityParam);
1310+
13021311
// ========== Encrypt ==========
13031312
const ciphertext = await encrypt(
13041313
this.subnetPubKey,
@@ -1353,6 +1362,8 @@ export class LitNodeClientNodeJs
13531362
const hashOfConditions: ArrayBuffer | undefined =
13541363
await this.getHashedAccessControlConditions(params);
13551364

1365+
log('hashOfConditions', hashOfConditions);
1366+
13561367
if (!hashOfConditions) {
13571368
throw new InvalidArgumentException(
13581369
{
@@ -1369,6 +1380,8 @@ export class LitNodeClientNodeJs
13691380
'base16'
13701381
);
13711382

1383+
log('hashOfConditionsStr', hashOfConditionsStr);
1384+
13721385
// ========== Formatting Access Control Conditions =========
13731386
const {
13741387
error,
@@ -1470,6 +1483,8 @@ export class LitNodeClientNodeJs
14701483
const hashOfConditions: ArrayBuffer | undefined =
14711484
await this.getHashedAccessControlConditions(params);
14721485

1486+
log('hashOfConditions', hashOfConditions);
1487+
14731488
if (!hashOfConditions) {
14741489
throw new InvalidArgumentException(
14751490
{
@@ -1486,17 +1501,22 @@ export class LitNodeClientNodeJs
14861501
'base16'
14871502
);
14881503

1504+
log('hashOfConditionsStr', hashOfConditionsStr);
1505+
14891506
// ========== Hashing Private Data ==========
14901507
// hash the private data
14911508
const hashOfPrivateData = await crypto.subtle.digest(
14921509
'SHA-256',
14931510
params.dataToEncrypt
14941511
);
1512+
log('hashOfPrivateData', hashOfPrivateData);
14951513
const hashOfPrivateDataStr = uint8arrayToString(
14961514
new Uint8Array(hashOfPrivateData),
14971515
'base16'
14981516
);
14991517

1518+
log('hashOfPrivateDataStr', hashOfPrivateDataStr);
1519+
15001520
return new LitAccessControlConditionResource(
15011521
`${hashOfConditionsStr}/${hashOfPrivateDataStr}`
15021522
);

0 commit comments

Comments
 (0)