Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Blockcrypt algorithm to version 1 #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Encrypt one or more secrets with plausible deniability by design.

Blockcrypt is used to encrypt one or more secrets (up to 4 by default) using encrypted headers which are indistinguishable from each other, data and padding resulting in plausible deniability by design.
Blockcrypt is used to encrypt one or more secrets using encrypted headers which
are indistinguishable from each other, data and padding resulting in plausible
deniability by design.

## Installation

Expand All @@ -13,42 +15,39 @@ $ npm install blockcrypt
## Usage (simplified for demonstration purposes)

```typescript
import { encrypt, decrypt, Secret } from "blockcrypt"
import { decrypt, encrypt, Secret } from "blockcrypt"

const secrets: Secret[] = [
{
message:
"trust vast puppy supreme public course output august glimpse reunion kite rebel virus tail pass enhance divorce whip edit skill dismiss alpha divert ketchup",
passphrase: "lip gift name net sixth",
key: Buffer.from([
4, 72, 156, 132, 66, 216, 156, 26, 55, 162, 221, 77, 214, 13, 146, 94,
146, 239, 47, 156, 123, 68, 210, 35, 142, 146, 52, 193, 214, 82, 109, 220,
]),
},
{
message: "this is a test\nyo",
passphrase: "grunt daisy chow barge pants",
key: Buffer.from([
158, 198, 159, 43, 229, 18, 213, 1, 55, 116, 184, 62, 75, 237, 50, 184,
123, 168, 31, 97, 208, 209, 209, 238, 42, 139, 98, 45, 31, 146, 7, 56,
]),
},
{
message: Buffer.from("yo"),
passphrase: "decor gooey wish kept pug",
key: Buffer.from([
180, 252, 249, 18, 136, 98, 214, 30, 168, 200, 64, 253, 65, 47, 210, 164,
66, 60, 44, 101, 109, 239, 173, 17, 50, 217, 41, 106, 3, 129, 59, 132,
]),
},
]

const block = await encrypt(secrets, kdf)
const block = await encrypt(secrets, 1024)

console.log(block)
// {
// salt: <Buffer 0a 89 b8 fd a1 6d 06 36 86 76 f6 e3 82 2e 54 37>,
// iv: <Buffer bb 4e 6e 86 14 1e dc d0 ed 09 fd fd ae cc 67 8a>,
// headers: <Buffer 82 a2 59 64 c4 a2 cb 3c 38 a6 88 5c f8 52 6e 45 81 0e 61 3f 93 69 0a fe 96 f7 21 ee 6c fc 2b 01 72 cc f0 0b ed 08 e3 f0 92 3f dd f4 b3 6a 5f cb ef 7f ... 14 more bytes>,
// data: <Buffer 5c 68 a6 9e 30 e2 cb 34 ed 70 7c 92 fc 57 af f6 4f 55 a4 7e 28 d5 8a 0f 39 bd fa f4 24 ad ca f9 e1 3e cb 37 89 70 d6 2e 18 1f 8d 34 30 95 42 ac a7 a2 ... 334 more bytes>
// }

const message = await decrypt(
"grunt daisy chow barge pants",
block.salt,
block.iv,
block.headers,
block.data,
kdf
)
// <Buffer 52 4f d0 4f 97 33 36 24 6e 62 07 1e 0a 4c 24 cd 42 78 4c 4b 99 6c 03 73 23 de ea 45 2f d6 7f f4 ef bb ce a0 86 e5 94 29 99 53 cf ad 22 6e eb 30 32 54 ... 974 more bytes>

const message = await decrypt(secrets[1].key, block)

console.log(message)
// <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74 0a 79 6f>
Expand Down
6 changes: 6 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"fmt": {
"semiColons": false,
"exclude": ["dist", "package-lock.json"]
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"printWidth": 80,
"semi": false,
"tabWidth": 2,
"trailingComma": "es5"
"trailingComma": "all",
"proseWrap": "always"
}
}
Loading