Skip to content

Commit

Permalink
fixed imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptroger committed Mar 1, 2024
1 parent de24c49 commit 37659e0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 420 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Alg, Feed, HistoricalTransfer, Signature, hashRequest } from '@narval/policy-engine-shared'
import { Feed, HistoricalTransfer, Signature } from '@narval/policy-engine-shared'
import { Alg, hashRequest } from '@narval/signature'
import { Injectable } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { mapValues, omit } from 'lodash/fp'
Expand Down
3 changes: 2 additions & 1 deletion apps/armory/src/data-feed/core/service/price-feed.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Action, Alg, AssetId, Feed, Signature, hashRequest } from '@narval/policy-engine-shared'
import { Action, AssetId, Feed, Signature } from '@narval/policy-engine-shared'
import { Alg, hashRequest } from '@narval/signature'
import { InputType, Intents, safeDecode } from '@narval/transaction-request-intent'
import { Injectable } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Decision, EvaluationRequest, EvaluationResponse, hashRequest } from '@narval/policy-engine-shared'
import { Decision, EvaluationRequest, EvaluationResponse } from '@narval/policy-engine-shared'
import { hashRequest } from '@narval/signature'
import { Injectable, Logger } from '@nestjs/common'
import { zip } from 'lodash/fp'
import { ClusterNotFoundException } from '../../core/exception/cluster-not-found.exception'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alg } from '@narval/policy-engine-shared'
import { Alg } from '@narval/signature'
import { z } from 'zod'

export const algSchema = z.nativeEnum(Alg)
Expand Down
44 changes: 22 additions & 22 deletions doc/policy-engine-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sequenceDiagram
Engine ->> DB: Write KEK (AES-256) encrypted MK
Engine ->> DB: Write KEK (AES-256) encrypted AK
Engine -->> Engineer: Return engine configuration JSON
else
else
Engine -->> Engineer: Prompt Yes/No to re-provision
deactivate Engine
Note over Engine: Re-provisioning will overwrite existing data to "factory default".
Expand Down Expand Up @@ -89,15 +89,15 @@ sequenceDiagram
participant DB as Database
participant DS as Data Storage
Engine ->> Engine: Read and validate engine's configuration
Engine ->> Engine: Read and validate engine's configuration
activate Engine
alt if engine configuration is valid
Engine ->> DB: Read tenants configuration
loop For each tenant
Engine ->> DS: Fetch tenant data
end
else
Engine ->> Engine: Abort the boot with invalid environment error message
else
Engine ->> Engine: Abort the boot with invalid environment error message
deactivate Engine
end
```
Expand All @@ -115,12 +115,12 @@ sequenceDiagram
participant DB as Database
participant DS as Data Storage
Admin ->> Engine: Onboard tenant request
Admin ->> Engine: Onboard tenant request
activate Engine
Engine ->> DB: Verify if admin API key exists
Engine ->> Engine: Generate tenant signing key pair
Engine ->> Engine: Generate tenant API key (TAK)
Engine ->> DB: Write CEK (AES-256) encrypted tenant configuration
Engine ->> DB: Write CEK (AES-256) encrypted tenant configuration
Engine ->> DS: Fetch tenant data
Engine ->> DB: Write CEK (AES-256) tenant's data
Note over DB: Does not fail the onboarding if fetching the tenant data failed
Expand Down Expand Up @@ -148,24 +148,24 @@ sequenceDiagram
This section describes the encryption summary used to secure the Policy Engine.

1. **Master Password to Key Encryption Key (KEK) via PBKDF2**: Using PBKDF2
(Password-Based Key Derivation Function 2) to derive a Key Encryption Key (KEK)
from an "encryptor master password" is a standard practice. PBKDF2 is designed
to make brute-force attacks difficult by using a salt and iterating the hashing
process many times, thus slowing down the attack attempts.
1. [node.js crypto built-in implementation](https://nodejs.org/api/crypto.html#cryptopbkdf2password-salt-iterations-keylen-digest-callback)
2. Master Password is an env secret
(Password-Based Key Derivation Function 2) to derive a Key Encryption Key (KEK)
from an "encryptor master password" is a standard practice. PBKDF2 is designed
to make brute-force attacks difficult by using a salt and iterating the hashing
process many times, thus slowing down the attack attempts.
1. [node.js crypto built-in implementation](https://nodejs.org/api/crypto.html#cryptopbkdf2password-salt-iterations-keylen-digest-callback)
2. Master Password is an env secret
2. **Generating an AES-256 Master Key and Encrypting with KEK**: Generating a
strong AES-256 master key for encryption is a solid choice given AES-256's
widespread acceptance and strength. Encrypting this master key with the KEK for
storage is a common approach in hierarchical key management systems, ensuring
that the master key is not exposed in plaintext.
strong AES-256 master key for encryption is a solid choice given AES-256's
widespread acceptance and strength. Encrypting this master key with the KEK for
storage is a common approach in hierarchical key management systems, ensuring
that the master key is not exposed in plaintext.
3. **Deriving a Content Encryption Key (CEK) from the Master Key using HKDF**:
HKDF (HMAC-based Key Derivation Function) is designed for deriving additional
keys from a single master key, which is a suitable method for generating Content
Encryption Keys (CEKs) from your master key. This step allows for different keys
to be used for different pieces of content or sessions, enhancing security by
limiting the scope of each key's usage.
1. [node.js crypto built-in implementation](https://nodejs.org/api/crypto.html#cryptohkdfdigest-ikm-salt-info-keylen-callback)
HKDF (HMAC-based Key Derivation Function) is designed for deriving additional
keys from a single master key, which is a suitable method for generating Content
Encryption Keys (CEKs) from your master key. This step allows for different keys
to be used for different pieces of content or sessions, enhancing security by
limiting the scope of each key's usage.
1. [node.js crypto built-in implementation](https://nodejs.org/api/crypto.html#cryptohkdfdigest-ikm-salt-info-keylen-callback)

### Notes

Expand Down
Loading

0 comments on commit 37659e0

Please sign in to comment.