Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@ export class LitNodeClientNodeJs
const hashOfConditions: ArrayBuffer | undefined =
await this.getHashedAccessControlConditions(params);

log('hashOfConditions', hashOfConditions);

if (!hashOfConditions) {
throw new InvalidArgumentException(
{
Expand All @@ -1282,23 +1284,30 @@ export class LitNodeClientNodeJs
'base16'
);

log('hashOfConditionsStr', hashOfConditionsStr);

// ========== Hashing Private Data ==========
// hash the private data
const hashOfPrivateData = await crypto.subtle.digest(
'SHA-256',
params.dataToEncrypt
);
log('hashOfPrivateData', hashOfPrivateData);
const hashOfPrivateDataStr = uint8arrayToString(
new Uint8Array(hashOfPrivateData),
'base16'
);

log('hashOfPrivateDataStr', hashOfPrivateDataStr);

// ========== Assemble identity parameter ==========
const identityParam = this._getIdentityParamForEncryption(
hashOfConditionsStr,
hashOfPrivateDataStr
);

log('identityParam', identityParam);

// ========== Encrypt ==========
const ciphertext = await encrypt(
this.subnetPubKey,
Expand Down Expand Up @@ -1353,6 +1362,8 @@ export class LitNodeClientNodeJs
const hashOfConditions: ArrayBuffer | undefined =
await this.getHashedAccessControlConditions(params);

log('hashOfConditions', hashOfConditions);

if (!hashOfConditions) {
throw new InvalidArgumentException(
{
Expand All @@ -1369,6 +1380,8 @@ export class LitNodeClientNodeJs
'base16'
);

log('hashOfConditionsStr', hashOfConditionsStr);

// ========== Formatting Access Control Conditions =========
const {
error,
Expand Down Expand Up @@ -1470,6 +1483,8 @@ export class LitNodeClientNodeJs
const hashOfConditions: ArrayBuffer | undefined =
await this.getHashedAccessControlConditions(params);

log('hashOfConditions', hashOfConditions);

if (!hashOfConditions) {
throw new InvalidArgumentException(
{
Expand All @@ -1486,17 +1501,22 @@ export class LitNodeClientNodeJs
'base16'
);

log('hashOfConditionsStr', hashOfConditionsStr);

// ========== Hashing Private Data ==========
// hash the private data
const hashOfPrivateData = await crypto.subtle.digest(
'SHA-256',
params.dataToEncrypt
);
log('hashOfPrivateData', hashOfPrivateData);
const hashOfPrivateDataStr = uint8arrayToString(
new Uint8Array(hashOfPrivateData),
'base16'
);

log('hashOfPrivateDataStr', hashOfPrivateDataStr);

return new LitAccessControlConditionResource(
`${hashOfConditionsStr}/${hashOfPrivateDataStr}`
);
Expand Down
Loading