Skip to content

Commit

Permalink
chore: add some comment
Browse files Browse the repository at this point in the history
  • Loading branch information
homura committed Aug 1, 2024
1 parent c894735 commit f17cbfc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/neuron-wallet/src/services/log-encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default class LogEncryption {
*/
private readonly algorithm = DEFAULT_ALGORITHM

/**
* A PEM-formatted RSA public key
* @private
*/
private readonly adminPublicKey: string

/**
Expand Down Expand Up @@ -77,6 +81,23 @@ export class LogDecryption {
}
}

/**
* Parse a message into a JSON
*
* Input:
* ```
* [key1:value2] [key2:value2] remain content
* ```
* Output:
* ```json
* {
* "key1": "value1",
* "key2": "value2",
* "content": "remain content"
* }
* ```
* @param message
*/
function parseMessage(message: string) {
const result: Record<string, string> = {}
const regex = /\[([^\]:]+):([^\]]+)]/g
Expand Down
10 changes: 10 additions & 0 deletions scripts/admin/decrypt-log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

An environment variable `LOG_ENCRYPTION_PUBLIC_KEY` must be set to enable log encryption when releasing Neuron. If the variable is not set, a placeholder message will be left in the log file.

To generate a keypair

```sh
# for ADMIN_PRIVATE_KEY
openssl genrsa -out key.pem 2048

# for LOG_ENCRYPTION_PUBLIC_KEY
openssl rsa -in key.pem -outform PEM -pubout -out public.pem
```

## Decryption

An encrypted log looks the following block
Expand Down

1 comment on commit f17cbfc

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 10193878131

Please sign in to comment.