story_key 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1233b236b5edf1cbec6d96eee8ace63be0c141402a9dadb6954c714b4311a8b0
4
- data.tar.gz: b49c36a26550ca611bcbdb55ff7c7fbc37534a797fb6cad34d1112fa6f0d4480
3
+ metadata.gz: eeeb70d8a72b1bc5e5d79ddfbcdd209e99fc0a06585e39a962e03c23e16668da
4
+ data.tar.gz: 65f19dfe8a2dea256fd81b9e89cc408abbf49bec3cdca1ab2c11d5e0f727d595
5
5
  SHA512:
6
- metadata.gz: 9022e3f8f6e2d19596ab98eaff22e229c8284a1a08a7069410b307711a6442cb242ed61ab4896245451db6670966b560e75bba9d224bcd96df462888152905ed
7
- data.tar.gz: 4ce3e4d9445922acba618a1ae402439b02d9420e47578526581ab701aa45c35aa9c9c9483aee47279f6c577756e4e85261730e6dad359fbe86a084a21d7aa39e
6
+ metadata.gz: b20a511ddc38ac544dcf5f9d406ac2828d9f0f0605bf4e8d645742d2fe0e032f0581f8b0faec9d7bf9983a7231bca0ceccde8d2f7334263a610295f4aa2bd797
7
+ data.tar.gz: 1b10fdb21424a1712520e2d12b6c48bd4766bfc7f9d49e0880524469aa4ca060c881860e1e7180acd595ed2ccf3c81688e91d4b3618d00c1d51f31ba2ffffbd5
data/.gitignore CHANGED
@@ -1,9 +1,12 @@
1
+ **/.DS_Store
2
+ .env
1
3
  .rspec_status
4
+ *.gem
2
5
  /_yardoc/
3
6
  /.bundle/
4
7
  /.yardoc
5
8
  /doc/
6
9
  /pkg/
7
10
  /spec/reports/
8
- /tmp/
9
- *.gem
11
+ /tmp/*
12
+ !/tmp/.keep
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
 
5
6
  AllCops:
@@ -8,7 +9,7 @@ AllCops:
8
9
  - vendor/**/*
9
10
  - lib/story_key/data.rb
10
11
  NewCops: enable
11
- TargetRubyVersion: 3.1.1
12
+ TargetRubyVersion: 3.2.0
12
13
  Gemspec/RequireMFA:
13
14
  Enabled: false
14
15
  Layout/EmptyLineAfterGuardClause:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.2.0
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ dist: focal
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 3.1.1
5
+ - 3.2.0
6
6
  notifications:
7
7
  email: false
8
8
  before_install:
data/Gemfile.lock CHANGED
@@ -1,21 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- story_key (0.3.0)
5
- activesupport (~> 7.0.2)
4
+ story_key (0.4.0)
5
+ activesupport (~> 7.0.4)
6
6
  awesome_print (~> 1.9.2)
7
7
  base58 (~> 0.2.3)
8
+ dotenv (~> 2.8.1)
8
9
  dry-initializer (~> 3.1.1)
9
- indefinite_article (~> 0.2.4)
10
+ indefinite_article (~> 0.2.5)
10
11
  pry (~> 0.14.1)
11
12
  remedy (~> 0.3.0)
13
+ rmagick (~> 5.1.0)
14
+ ruby-openai (~> 3.0.2)
12
15
  thor (~> 1.2.1)
13
- zeitwerk (~> 2.5.4)
16
+ zeitwerk (~> 2.6.6)
14
17
 
15
18
  GEM
16
19
  remote: https://rubygems.org/
17
20
  specs:
18
- activesupport (7.0.2.3)
21
+ activesupport (7.0.4)
19
22
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
23
  i18n (>= 1.6, < 2)
21
24
  minitest (>= 5.1)
@@ -26,75 +29,91 @@ GEM
26
29
  coderay (1.1.3)
27
30
  concurrent-ruby (1.1.10)
28
31
  diff-lcs (1.5.0)
32
+ dotenv (2.8.1)
29
33
  dry-initializer (3.1.1)
30
- i18n (1.10.0)
34
+ httparty (0.20.0)
35
+ mime-types (~> 3.0)
36
+ multi_xml (>= 0.5.2)
37
+ i18n (1.12.0)
31
38
  concurrent-ruby (~> 1.0)
32
- indefinite_article (0.2.4)
39
+ indefinite_article (0.2.5)
33
40
  activesupport
41
+ json (2.6.3)
34
42
  method_source (1.0.0)
35
- minitest (5.15.0)
43
+ mime-types (3.4.1)
44
+ mime-types-data (~> 3.2015)
45
+ mime-types-data (3.2022.0105)
46
+ minitest (5.16.3)
47
+ multi_xml (0.6.0)
36
48
  parallel (1.22.1)
37
- parser (3.1.1.0)
49
+ parser (3.1.3.0)
38
50
  ast (~> 2.4.1)
51
+ pkg-config (1.5.1)
39
52
  pry (0.14.1)
40
53
  coderay (~> 1.1)
41
54
  method_source (~> 1.0)
42
55
  rainbow (3.1.1)
43
56
  rake (13.0.6)
44
- regexp_parser (2.2.1)
57
+ regexp_parser (2.6.1)
45
58
  remedy (0.3.0)
46
59
  rexml (3.2.5)
47
- rspec (3.11.0)
48
- rspec-core (~> 3.11.0)
49
- rspec-expectations (~> 3.11.0)
50
- rspec-mocks (~> 3.11.0)
51
- rspec-core (3.11.0)
52
- rspec-support (~> 3.11.0)
53
- rspec-expectations (3.11.0)
60
+ rmagick (5.1.0)
61
+ pkg-config (~> 1.4)
62
+ rspec (3.12.0)
63
+ rspec-core (~> 3.12.0)
64
+ rspec-expectations (~> 3.12.0)
65
+ rspec-mocks (~> 3.12.0)
66
+ rspec-core (3.12.0)
67
+ rspec-support (~> 3.12.0)
68
+ rspec-expectations (3.12.1)
54
69
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.11.0)
56
- rspec-mocks (3.11.1)
70
+ rspec-support (~> 3.12.0)
71
+ rspec-mocks (3.12.1)
57
72
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.11.0)
59
- rspec-support (3.11.0)
60
- rubocop (1.26.1)
73
+ rspec-support (~> 3.12.0)
74
+ rspec-support (3.12.0)
75
+ rubocop (1.41.1)
76
+ json (~> 2.3)
61
77
  parallel (~> 1.10)
62
- parser (>= 3.1.0.0)
78
+ parser (>= 3.1.2.1)
63
79
  rainbow (>= 2.2.2, < 4.0)
64
80
  regexp_parser (>= 1.8, < 3.0)
65
- rexml
66
- rubocop-ast (>= 1.16.0, < 2.0)
81
+ rexml (>= 3.2.5, < 4.0)
82
+ rubocop-ast (>= 1.23.0, < 2.0)
67
83
  ruby-progressbar (~> 1.7)
68
84
  unicode-display_width (>= 1.4.0, < 3.0)
69
- rubocop-ast (1.16.0)
85
+ rubocop-ast (1.24.1)
70
86
  parser (>= 3.1.1.0)
71
- rubocop-performance (1.13.3)
87
+ rubocop-performance (1.15.2)
72
88
  rubocop (>= 1.7.0, < 2.0)
73
89
  rubocop-ast (>= 0.4.0)
74
90
  rubocop-rake (0.6.0)
75
91
  rubocop (~> 1.0)
76
- rubocop-rspec (2.9.0)
77
- rubocop (~> 1.19)
92
+ rubocop-rspec (2.16.0)
93
+ rubocop (~> 1.33)
94
+ ruby-openai (3.0.2)
95
+ httparty (>= 0.18.1, < 0.21.0)
78
96
  ruby-progressbar (1.11.0)
79
97
  thor (1.2.1)
80
- tzinfo (2.0.4)
98
+ tzinfo (2.0.5)
81
99
  concurrent-ruby (~> 1.0)
82
- unicode-display_width (2.1.0)
83
- zeitwerk (2.5.4)
100
+ unicode-display_width (2.3.0)
101
+ zeitwerk (2.6.6)
84
102
 
85
103
  PLATFORMS
86
104
  arm64-darwin-21
105
+ arm64-darwin-22
87
106
  x86_64-linux
88
107
 
89
108
  DEPENDENCIES
90
- bundler (~> 2.3.7)
109
+ bundler (~> 2.4.1)
91
110
  rake (~> 13.0.6)
92
- rspec (~> 3.11.0)
93
- rubocop (~> 1.26.1)
94
- rubocop-performance (~> 1.13.3)
111
+ rspec (~> 3.12.0)
112
+ rubocop (~> 1.41.1)
113
+ rubocop-performance (~> 1.15.2)
95
114
  rubocop-rake (~> 0.6.0)
96
- rubocop-rspec (~> 2.9.0)
115
+ rubocop-rspec (~> 2.16.0)
97
116
  story_key!
98
117
 
99
118
  BUNDLED WITH
100
- 2.3.7
119
+ 2.4.1
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/story_key.svg)](https://badge.fury.io/rb/story_key)
2
- ![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/story_key?type=total)
3
2
  [![Build Status](https://travis-ci.org/jcraigk/story_key.svg?branch=main)](https://travis-ci.org/jcraigk/story_key)
4
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/6046413814d7f6417ce9/maintainability)](https://codeclimate.com/github/jcraigk/story_key/maintainability)
5
4
 
@@ -8,23 +7,28 @@
8
7
 
9
8
  | Gem Version | Locale | Lexicon SHA |
10
9
  |-------------|--------|-------------|
11
- | 0.3.0 | Miami | 4eea29f |
10
+ | 0.4.0 | Miami | 3bfbbf9 |
11
+
12
+ Locale will not change until v1.0 release
12
13
 
13
14
 
14
15
  # StoryKey
15
16
 
16
- StoryKey is a [Brainwallet](https://en.bitcoin.it/wiki/Brainwallet) inspired by [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) written in [Ruby](https://www.ruby-lang.org/en/). It converts an arbitrary string of data, such as a [cryptocurrency private key](https://en.bitcoin.it/wiki/Private_key), into an English paragraph intended for longterm human memory. It also assists in decoding the story back into its original form.
17
+ StoryKey is a proof of concept [Brainwallet](https://en.bitcoin.it/wiki/Brainwallet) inspired by [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) written in [Ruby](https://www.ruby-lang.org/en/). It converts an arbitrary string of data, such as a [cryptocurrency private key](https://en.bitcoin.it/wiki/Private_key), into an English paragraph intended for longterm human memory. It also assists in decoding the story back into its original form. Optionally, a visual representation of the paragraph is also provided using [OpenAI DALL-E](https://openai.com/dall-e-2).
17
18
 
18
- Each story is provided in two formats:
19
- * Humanized
19
+ Each story is provided in multiple formats:
20
+ * Humanized Text
20
21
  * Version locale header ("In Miami I saw...")
21
22
  * Enumerated phrases
22
23
  * Colorized parts of speech (adjectives, verbs, nouns)
23
24
  * Grammatical filler (articles, prepositions, conjunctions, punctuation)
24
- * Tokenized
25
+ * Tokenized Text
25
26
  * Ordered list of unique tokens
26
27
  * Space-delimited lowercase alphanumeric/dash
27
28
  * Useful as a seed phrase for generating derivative keys
29
+ * Graphical
30
+ * AI-generated images via [DALL-E](https://openai.com/dall-e-2)
31
+ * Requires OpenAI key
28
32
 
29
33
  ## Features
30
34
 
@@ -33,7 +37,7 @@ Each story is provided in two formats:
33
37
  * Includes version slug to ensure accurate decoding
34
38
  * Uses a repeating English grammar to aid in mnemonics
35
39
  * Uses a lexicon curated for mental visualization
36
- * Avoids token repetition
40
+ * Avoids word repetition
37
41
  * Provides interactive command-line recovery
38
42
 
39
43
  Each token of the story, which may be a single word or short compound phrase, encodes 10 bits. The checksum length is variable based on the input size and space available in the last two tokens after accounting for a 4-bit footer. Here are a few example key sizes along with their respective story and checksum sizes.
@@ -47,24 +51,25 @@ Each token of the story, which may be a single word or short compound phrase, en
47
51
  | 384 | 40 | 12 |
48
52
  | 512 | 53 | 14 |
49
53
 
50
- An example key and its associated story and seed phrase are shown below.
54
+ An example key with its associated story, seed phrase, and image are shown below.
51
55
 
52
- ![Key/Story Example](https://user-images.githubusercontent.com/104095/161372021-1edb5999-453d-453a-a7bb-d2fc2bcc3120.png)
56
+ ![KeyStory Example Text](https://user-images.githubusercontent.com/104095/210197560-45494c50-6382-465b-8163-a61b3783ac76.png)
57
+ ![KeyStory Example Image](https://user-images.githubusercontent.com/104095/210197577-11e1d6ac-a32f-4438-b7eb-f766bf62f0f2.png)
53
58
 
54
59
  ```
55
60
  Key:
56
- CH8krjSZpGFmxnKo9QPqQEd9oMUkXnLcUhhEQFLrGCtg
61
+ CgCLLXvoch7sLaQWe5Y3Evtzety2Vr9XJGRmAq9YZUXY
57
62
  Story:
58
63
  In Miami I saw
59
- 1. a pensive Ellen Ripley surpass a musician,
60
- 2. an unhappy pug drink vodka with a dove,
61
- 3. an opulent Dante Alighieri diagnose Huckleberry Finn,
62
- 4. a frantic sister eat pretzels with Mozart,
63
- 5. a cunning meerkat trim a balloonist,
64
- 6. a rich ocelot step to John Wayne,
65
- 7. and a civilian convict a locust.
64
+ 1. a practical theorist eating toast with a shopkeeper,
65
+ 2. a jobless macaw disowning a scientist,
66
+ 3. a toothsome brother eating dumplings with Paul Cezanne,
67
+ 4. a rabid outsider leveling a vulture,
68
+ 5. a hysterical Marge Simpson threatening Moe Szyslak,
69
+ 6. a rancid cyborg demanding a jeweler,
70
+ 7. and a wife paging Jimi Hendrix.
66
71
  Seed Phrase:
67
- pensive ellen-ripley surpass musician unhappy pug drink-vodka dove opulent dante-alighieri diagnose huckleberry-finn frantic sister eat-pretzels mozart cunning meerkat trim balloonist rich ocelot step john-wayne civilian convict locust
72
+ miami practical theorist eating-toast shopkeeper jobless macaw disowning scientist toothsome brother eating-dumplings paul-cezanne rabid outsider leveling vulture hysterical marge-simpson threatening moe-szyslak rancid cyborg demanding jeweler wife paging jimi-hendrix
68
73
  ````
69
74
 
70
75
  This paragraph or seed phrase can be deterministically decoded back into its original form using the same version of StoryKey. The locale of the story (e.g. `Miami`) identifies that version. During key recovery, an exception will be raised if:
@@ -86,11 +91,6 @@ The lexicon was selected using the following criteria:
86
91
  * Balance brevity with clarity.
87
92
 
88
93
 
89
- ### Graphical Visualization
90
-
91
- When AI becomes more common, StoryKey stories may be converted to graphical panels similar to the [DALL-E Project](https://openai.com/blog/dall-e/). This will likely aid in mnemonics process for many users.
92
-
93
-
94
94
  ## Installation
95
95
 
96
96
  Add this line to your application's Gemfile:
@@ -113,7 +113,16 @@ $ gem install story_key
113
113
 
114
114
  ## Usage
115
115
 
116
- This library may be used by calling Ruby methods or directly from the command line.
116
+ This library may be used directly from the command line or by calling Ruby methods.
117
+
118
+ If you want to generate images of the story along with the text, create a file named `.env` in the project directory and add your [OpenAI key](https://beta.openai.com/account/api-keys) as an environment variable:
119
+
120
+ ```
121
+ # .env
122
+ OPENAI_KEY=<your-api-key>
123
+ ```
124
+
125
+ You must have [ImageMagick](https://imagemagick.org/index.php) installed locally.
117
126
 
118
127
 
119
128
  ### Command Line Usage
@@ -129,6 +138,8 @@ StoryKey commands:
129
138
  storykey recover # Decode a story interactively
130
139
  ```
131
140
 
141
+ To see help on a specific command, run `bin/storyke --help [command]`.
142
+
132
143
  The command line also features an interactive recovery tool to aid in converting a story back into its source key. Run `bin/storykey recover` to initiate the process:
133
144
 
134
145
  ![Key/Story Example](https://user-images.githubusercontent.com/104095/161376334-4a591100-e3fc-41ce-b931-4773bebc23fd.png)
@@ -141,10 +152,10 @@ After installing the gem, you may run `bin/console` or `require` the gem in your
141
152
 
142
153
  ### Generate new key/story
143
154
 
144
- Generate a new random key/story pair.
155
+ Generate a new random key and associated story.
145
156
 
146
157
  ```
147
- 3.1.1# StoryKey.generate
158
+ # StoryKey.generate
148
159
  =>
149
160
  ["4eqfoXzMDyqQW6p8zAQj7c8KkynK5K2BW6D5Vfp7xCaQ",
150
161
  #<struct StoryKey::Story
@@ -157,12 +168,12 @@ Generate a new random key/story pair.
157
168
  ```
158
169
 
159
170
 
160
- ### Encode key => story
171
+ ### Encode an existing key
161
172
 
162
173
  Produce an English paragraph given input data (e.g. a cryptocurrency private key):
163
174
 
164
175
  ```
165
- 3.1.1# StoryKey.encode(key: '4eqfoXzMDyqQW6p8zAQj7c8KkynK5K2BW6D5Vfp7xCaQ')
176
+ # StoryKey.encode(key: '4eqfoXzMDyqQW6p8zAQj7c8KkynK5K2BW6D5Vfp7xCaQ')
166
177
  =>
167
178
  #<struct StoryKey::Story
168
179
  text=
@@ -176,12 +187,12 @@ Produce an English paragraph given input data (e.g. a cryptocurrency private key
176
187
  `key` may be in the form of a hexidecimal (`ab29f3`), a binary string (`1001101`), a decimal (`230938`), or a base58 string (`uMBca`). If not in the default base58, `format` must be provided.
177
188
 
178
189
 
179
- ### Decode story => key
190
+ ### Decode an existing story
180
191
 
181
192
  Recover source data (e.g. a cryptocurrency private key) based on the English paragraph:
182
193
 
183
194
  ```
184
- 3.1.1# StoryKey.decode(story: 'In Miami I saw an official Benjamin Franklin transport Matt Damon')
195
+ # StoryKey.decode(story: 'In Miami I saw an official Benjamin Franklin transport Matt Damon')
185
196
  => "4NTM"
186
197
  ```
187
198
 
data/assets/error.png ADDED
Binary file
@@ -46,13 +46,11 @@ clear
46
46
  cold
47
47
  colorful
48
48
  comical
49
- complex
50
49
  cosmic
51
50
  coy
52
51
  cynical
53
52
  dangerous
54
53
  dark
55
- dead
56
54
  decayed
57
55
  deficient
58
56
  delicate
@@ -152,7 +150,6 @@ late
152
150
  lewd
153
151
  liberal
154
152
  limpid
155
- limping
156
153
  little
157
154
  lively
158
155
  lofty
@@ -307,11 +304,11 @@ volatile
307
304
  wasteful
308
305
  wholesome
309
306
  wide
307
+ wide-eyed
310
308
  wild
311
309
  winged
312
310
  wintery
313
311
  wobbly
314
- wonderful
315
312
  woozy
316
313
  worried
317
314
  wrinkled
@@ -1,8 +1,8 @@
1
1
  adamant
2
- adroit
2
+ adament
3
3
  affable
4
4
  affluent
5
- ageless
5
+ aging
6
6
  albino
7
7
  alcoholic
8
8
  alluring
@@ -50,8 +50,8 @@ chaste
50
50
  cheap
51
51
  childish
52
52
  childlike
53
- choking
54
53
  chubby
54
+ churlish
55
55
  civilized
56
56
  clairvoyant
57
57
  clammy
@@ -91,6 +91,7 @@ dapper
91
91
  dashing
92
92
  dastardly
93
93
  dazed
94
+ dead
94
95
  deaf
95
96
  decadent
96
97
  decisive
@@ -107,6 +108,7 @@ difficult
107
108
  dignified
108
109
  diligent
109
110
  dim
111
+ disabled
110
112
  discreet
111
113
  diseased
112
114
  disguised
@@ -126,7 +128,6 @@ drunk
126
128
  dull
127
129
  dumb
128
130
  dutiful
129
- dying
130
131
  eager
131
132
  earnest
132
133
  elderly
@@ -358,6 +359,7 @@ purring
358
359
  pushy
359
360
  queasy
360
361
  quirky
362
+ quivering
361
363
  rambling
362
364
  rash
363
365
  reckless
@@ -465,6 +467,7 @@ trashy
465
467
  trembling
466
468
  trendy
467
469
  truthful
470
+ twitching
468
471
  unconscious
469
472
  undead
470
473
  unkempt