Skip to content

Commit 6f9ef40

Browse files
Merge branch 'main' into fix/generate-simplify
2 parents e61e7d2 + 335c310 commit 6f9ef40

13 files changed

Lines changed: 14 additions & 10 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v3
1717
- uses: actions/setup-go@v4
1818
with:
19-
go-version: '1.21'
19+
go-version: '1.25'
2020
cache: false
2121
- name: golangci-lint
2222
uses: golangci/golangci-lint-action@v3

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
steps:
77
- name: Check out code into the Go module directory
88
uses: actions/checkout@v4
9-
- name: Set up Go 1.21
9+
- name: Set up Go 1.25
1010
uses: actions/setup-go@v5
1111
with:
12-
go-version: '1.21'
12+
go-version: '1.25'
1313
cache: true
1414
- name: Unit tests
1515
run: make test

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ formatters:
103103
settings:
104104
goimports:
105105
local-prefixes:
106-
- istio.io/
106+
- github.com/theskyinflames/word2png/
107107
exclusions:
108108
generated: lax
109109
paths:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ To get back the words encoded in the above image, the passphrase is needed:
4343
<img src="doc/decode.png" alt="encoding" style="width:800px;background-color:white;padding:0px"/>
4444

4545
## How it works - Encoding
46-
First of all, the provided words are encrypted using AES-256 encryption in a *chain* mode. I mean, except for the first word, which is encrypted using the provided passphrase, the rest of the words are encrypted using the previous encrypted word as a passphrase.
46+
First of all, the provided words are encrypted using AES-256-GCM encryption in a *chain* mode. The encryption key is derived from the passphrase using **Argon2id** (RFC 9106), a memory-hard KDF resistant to GPU/ASIC attacks. A random 16-byte salt is generated for each encryption and prepended to the ciphertext (salt||nonce||encrypted). I mean, except for the first word, which is encrypted using the provided passphrase, the rest of the words are encrypted using the previous encrypted word as a passphrase.
4747

4848
<img src="doc/ic-encryption.png" alt="Words encryption" style="width:400px;background-color:white;padding:10px"/>
4949

5050
It prevents modifying the sequence of words.
5151

52-
Once we have the words encrypted, we need a bijective function to encode the encrypted words in a sequence of colors in the PNG file. But we also want that this relation between each *byte* and its color depended on the passphrase. So if the passphrase changes, this relation will also change. It's achieved by using the MD5 checksum of the passphrase. It is a 128 bytes signature length, or in other words, it allows to encode 128 values into 128 colors. Here, two bijective functions are built, the first one to encode and the second one to decode:
52+
Once we have the words encrypted, we need a bijective function to encode the encrypted words in a sequence of colors in the PNG file. But we also want that this relation between each *byte* and its color depended on the passphrase. So if the passphrase changes, this relation will also change. It's achieved by using an Argon2id-derived key from the passphrase. Here, two bijective functions are built, the first one to encode and the second one to decode:
5353

5454
<img src="doc/bijective.png" alt="Words encryption" style="width:400px;background-color:white;padding:10px"/>
5555

cmd/png2word/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/alecthomas/kingpin/v2"
1010
"github.com/pterm/pterm"
11+
1112
"github.com/theskyinflames/word2png/lib"
1213
)
1314

cmd/word2png/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/alecthomas/kingpin/v2"
99
"github.com/pterm/pterm"
10+
1011
"github.com/theskyinflames/word2png/lib"
1112
)
1213

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module theskyinflames/word2png
1+
module github.com/theskyinflames/word2png
22

33
go 1.26
44

@@ -8,7 +8,6 @@ require (
88
github.com/alecthomas/kingpin/v2 v2.3.2
99
github.com/pterm/pterm v0.12.69
1010
github.com/stretchr/testify v1.8.4
11-
github.com/theskyinflames/word2png v0.0.0-20230310162449-716270965f75
1211
golang.org/x/crypto v0.52.0
1312
)
1413

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
7070
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
7171
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
7272
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
73-
github.com/theskyinflames/word2png v0.0.0-20230310162449-716270965f75 h1:/v9JPvd6n/3NnGO3dR3km6kO7djJ10H5c6A+44emnyU=
74-
github.com/theskyinflames/word2png v0.0.0-20230310162449-716270965f75/go.mod h1:sEqjyLcA7jCDiW9eE/KfQKqeaC8+0NV1j5QX4Q+a6Ms=
7573
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
7674
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
7775
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=

lib/aes256_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/require"
7+
78
"github.com/theskyinflames/word2png/lib"
89
)
910

lib/color_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/stretchr/testify/require"
7+
78
"github.com/theskyinflames/word2png/lib"
89
)
910

0 commit comments

Comments
 (0)