From 261846aa7e342b23760221b8d002416c3c3c809f Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 21 Apr 2023 18:30:37 -0600 Subject: [PATCH 1/5] move vanillae ts over here --- {bindings/typescript => libs/vdk}/.gitignore | 0 {bindings/typescript => libs/vdk}/jex.eterms | 0 {bindings/typescript => libs/vdk}/notes | 0 {bindings/typescript => libs/vdk}/scratch | 0 {bindings/typescript => libs/vdk}/src/anth.ts | 0 {bindings/typescript => libs/vdk}/src/b58.ts | 0 {bindings/typescript => libs/vdk}/src/b64.ts | 0 {bindings/typescript => libs/vdk}/src/bin.ts | 0 {bindings/typescript => libs/vdk}/src/rlp.ts | 0 {bindings/typescript => libs/vdk}/src/safe.ts | 0 .../typescript => libs/vdk}/test/cases/jex.eterms | 0 .../typescript => libs/vdk}/test/cases/src/cases.ts | 0 .../vdk}/test/cases/src/rlpcases.ts | 0 .../vdk}/test/cases/testgen/.gitignore | 0 .../vdk}/test/cases/testgen/b58.erl | 0 .../vdk}/test/cases/testgen/b58.py | 0 .../vdk}/test/cases/testgen/b58_2.erl | 0 .../vdk}/test/cases/testgen/b58_cases | 0 .../vdk}/test/cases/testgen/b58_cases.eterms | 0 .../vdk}/test/cases/testgen/rlp.erl | 0 .../vdk}/test/cases/testgen/rlp_testgen.erl | 0 .../vdk}/test/cases/testgen/rlpcases.py | 0 .../vdk}/test/cases/testgen/rlptests.py | 0 .../vdk}/test/cases/testgen/tg_b64.erl | 0 .../vdk}/test/cases/tsconfig.json | 0 {bindings/typescript => libs/vdk}/test/favicon.ico | Bin {bindings/typescript => libs/vdk}/test/index.html | 0 {bindings/typescript => libs/vdk}/test/jex.eterms | 0 {bindings/typescript => libs/vdk}/test/src/test.ts | 0 .../typescript => libs/vdk}/test/tsconfig.json | 0 {bindings/typescript => libs/vdk}/tsconfig.json | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename {bindings/typescript => libs/vdk}/.gitignore (100%) rename {bindings/typescript => libs/vdk}/jex.eterms (100%) rename {bindings/typescript => libs/vdk}/notes (100%) rename {bindings/typescript => libs/vdk}/scratch (100%) rename {bindings/typescript => libs/vdk}/src/anth.ts (100%) rename {bindings/typescript => libs/vdk}/src/b58.ts (100%) rename {bindings/typescript => libs/vdk}/src/b64.ts (100%) rename {bindings/typescript => libs/vdk}/src/bin.ts (100%) rename {bindings/typescript => libs/vdk}/src/rlp.ts (100%) rename {bindings/typescript => libs/vdk}/src/safe.ts (100%) rename {bindings/typescript => libs/vdk}/test/cases/jex.eterms (100%) rename {bindings/typescript => libs/vdk}/test/cases/src/cases.ts (100%) rename {bindings/typescript => libs/vdk}/test/cases/src/rlpcases.ts (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/.gitignore (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/b58.erl (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/b58.py (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/b58_2.erl (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/b58_cases (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/b58_cases.eterms (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/rlp.erl (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/rlp_testgen.erl (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/rlpcases.py (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/rlptests.py (100%) rename {bindings/typescript => libs/vdk}/test/cases/testgen/tg_b64.erl (100%) rename {bindings/typescript => libs/vdk}/test/cases/tsconfig.json (100%) rename {bindings/typescript => libs/vdk}/test/favicon.ico (100%) rename {bindings/typescript => libs/vdk}/test/index.html (100%) rename {bindings/typescript => libs/vdk}/test/jex.eterms (100%) rename {bindings/typescript => libs/vdk}/test/src/test.ts (100%) rename {bindings/typescript => libs/vdk}/test/tsconfig.json (100%) rename {bindings/typescript => libs/vdk}/tsconfig.json (100%) diff --git a/bindings/typescript/.gitignore b/libs/vdk/.gitignore similarity index 100% rename from bindings/typescript/.gitignore rename to libs/vdk/.gitignore diff --git a/bindings/typescript/jex.eterms b/libs/vdk/jex.eterms similarity index 100% rename from bindings/typescript/jex.eterms rename to libs/vdk/jex.eterms diff --git a/bindings/typescript/notes b/libs/vdk/notes similarity index 100% rename from bindings/typescript/notes rename to libs/vdk/notes diff --git a/bindings/typescript/scratch b/libs/vdk/scratch similarity index 100% rename from bindings/typescript/scratch rename to libs/vdk/scratch diff --git a/bindings/typescript/src/anth.ts b/libs/vdk/src/anth.ts similarity index 100% rename from bindings/typescript/src/anth.ts rename to libs/vdk/src/anth.ts diff --git a/bindings/typescript/src/b58.ts b/libs/vdk/src/b58.ts similarity index 100% rename from bindings/typescript/src/b58.ts rename to libs/vdk/src/b58.ts diff --git a/bindings/typescript/src/b64.ts b/libs/vdk/src/b64.ts similarity index 100% rename from bindings/typescript/src/b64.ts rename to libs/vdk/src/b64.ts diff --git a/bindings/typescript/src/bin.ts b/libs/vdk/src/bin.ts similarity index 100% rename from bindings/typescript/src/bin.ts rename to libs/vdk/src/bin.ts diff --git a/bindings/typescript/src/rlp.ts b/libs/vdk/src/rlp.ts similarity index 100% rename from bindings/typescript/src/rlp.ts rename to libs/vdk/src/rlp.ts diff --git a/bindings/typescript/src/safe.ts b/libs/vdk/src/safe.ts similarity index 100% rename from bindings/typescript/src/safe.ts rename to libs/vdk/src/safe.ts diff --git a/bindings/typescript/test/cases/jex.eterms b/libs/vdk/test/cases/jex.eterms similarity index 100% rename from bindings/typescript/test/cases/jex.eterms rename to libs/vdk/test/cases/jex.eterms diff --git a/bindings/typescript/test/cases/src/cases.ts b/libs/vdk/test/cases/src/cases.ts similarity index 100% rename from bindings/typescript/test/cases/src/cases.ts rename to libs/vdk/test/cases/src/cases.ts diff --git a/bindings/typescript/test/cases/src/rlpcases.ts b/libs/vdk/test/cases/src/rlpcases.ts similarity index 100% rename from bindings/typescript/test/cases/src/rlpcases.ts rename to libs/vdk/test/cases/src/rlpcases.ts diff --git a/bindings/typescript/test/cases/testgen/.gitignore b/libs/vdk/test/cases/testgen/.gitignore similarity index 100% rename from bindings/typescript/test/cases/testgen/.gitignore rename to libs/vdk/test/cases/testgen/.gitignore diff --git a/bindings/typescript/test/cases/testgen/b58.erl b/libs/vdk/test/cases/testgen/b58.erl similarity index 100% rename from bindings/typescript/test/cases/testgen/b58.erl rename to libs/vdk/test/cases/testgen/b58.erl diff --git a/bindings/typescript/test/cases/testgen/b58.py b/libs/vdk/test/cases/testgen/b58.py similarity index 100% rename from bindings/typescript/test/cases/testgen/b58.py rename to libs/vdk/test/cases/testgen/b58.py diff --git a/bindings/typescript/test/cases/testgen/b58_2.erl b/libs/vdk/test/cases/testgen/b58_2.erl similarity index 100% rename from bindings/typescript/test/cases/testgen/b58_2.erl rename to libs/vdk/test/cases/testgen/b58_2.erl diff --git a/bindings/typescript/test/cases/testgen/b58_cases b/libs/vdk/test/cases/testgen/b58_cases similarity index 100% rename from bindings/typescript/test/cases/testgen/b58_cases rename to libs/vdk/test/cases/testgen/b58_cases diff --git a/bindings/typescript/test/cases/testgen/b58_cases.eterms b/libs/vdk/test/cases/testgen/b58_cases.eterms similarity index 100% rename from bindings/typescript/test/cases/testgen/b58_cases.eterms rename to libs/vdk/test/cases/testgen/b58_cases.eterms diff --git a/bindings/typescript/test/cases/testgen/rlp.erl b/libs/vdk/test/cases/testgen/rlp.erl similarity index 100% rename from bindings/typescript/test/cases/testgen/rlp.erl rename to libs/vdk/test/cases/testgen/rlp.erl diff --git a/bindings/typescript/test/cases/testgen/rlp_testgen.erl b/libs/vdk/test/cases/testgen/rlp_testgen.erl similarity index 100% rename from bindings/typescript/test/cases/testgen/rlp_testgen.erl rename to libs/vdk/test/cases/testgen/rlp_testgen.erl diff --git a/bindings/typescript/test/cases/testgen/rlpcases.py b/libs/vdk/test/cases/testgen/rlpcases.py similarity index 100% rename from bindings/typescript/test/cases/testgen/rlpcases.py rename to libs/vdk/test/cases/testgen/rlpcases.py diff --git a/bindings/typescript/test/cases/testgen/rlptests.py b/libs/vdk/test/cases/testgen/rlptests.py similarity index 100% rename from bindings/typescript/test/cases/testgen/rlptests.py rename to libs/vdk/test/cases/testgen/rlptests.py diff --git a/bindings/typescript/test/cases/testgen/tg_b64.erl b/libs/vdk/test/cases/testgen/tg_b64.erl similarity index 100% rename from bindings/typescript/test/cases/testgen/tg_b64.erl rename to libs/vdk/test/cases/testgen/tg_b64.erl diff --git a/bindings/typescript/test/cases/tsconfig.json b/libs/vdk/test/cases/tsconfig.json similarity index 100% rename from bindings/typescript/test/cases/tsconfig.json rename to libs/vdk/test/cases/tsconfig.json diff --git a/bindings/typescript/test/favicon.ico b/libs/vdk/test/favicon.ico similarity index 100% rename from bindings/typescript/test/favicon.ico rename to libs/vdk/test/favicon.ico diff --git a/bindings/typescript/test/index.html b/libs/vdk/test/index.html similarity index 100% rename from bindings/typescript/test/index.html rename to libs/vdk/test/index.html diff --git a/bindings/typescript/test/jex.eterms b/libs/vdk/test/jex.eterms similarity index 100% rename from bindings/typescript/test/jex.eterms rename to libs/vdk/test/jex.eterms diff --git a/bindings/typescript/test/src/test.ts b/libs/vdk/test/src/test.ts similarity index 100% rename from bindings/typescript/test/src/test.ts rename to libs/vdk/test/src/test.ts diff --git a/bindings/typescript/test/tsconfig.json b/libs/vdk/test/tsconfig.json similarity index 100% rename from bindings/typescript/test/tsconfig.json rename to libs/vdk/test/tsconfig.json diff --git a/bindings/typescript/tsconfig.json b/libs/vdk/tsconfig.json similarity index 100% rename from bindings/typescript/tsconfig.json rename to libs/vdk/tsconfig.json From a7ff4c5e2e1e2c5221269042ecbeb93fe6c95eea Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 21 Apr 2023 18:30:59 -0600 Subject: [PATCH 2/5] add untested faert implementation --- libs/vdk/src/faert.ts | 398 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 libs/vdk/src/faert.ts diff --git a/libs/vdk/src/faert.ts b/libs/vdk/src/faert.ts new file mode 100644 index 0000000..c48b2e1 --- /dev/null +++ b/libs/vdk/src/faert.ts @@ -0,0 +1,398 @@ +/** + * FÆRT: Fast Æternity Recovery Text + * + * Reference: https://gitlab.com/zxq9/passgas/-/blob/83607fedb08be5dfd03210e331f9c76125bb3467/fullofbeans + * + * @module + */ + +export { + encode, + decode, + byte_of_word, + check_word, + check_byte, + words +} + +import * as safe from './safe.js'; + + + +/** + * Encode a bytestring into FÆRT + */ +function +encode + (bytes : Uint8Array) + : string +{ + // initial accumulator + let words_acc : Array = []; + + // go along each byte and look up the word + // add it to the accumulator + for (let this_byte of bytes) { + let this_word = words[this_byte]; + words_acc.push(this_word); + } + + // prepend check word to phrase + // yes craig it would be faster to do the check byte inline + // the usage case here is 64 byte strings + // double pass is not a big deal + return check_word(bytes) + ' ' + words_acc.join(' '); +} + + + +/** + * Decode a FAERT string into bytes + */ +function +decode + (faert : string) + : safe.Safe +{ + let all_words : Array = faert.split(' '); + let input_check_word : string = all_words[0]; + let input_words : Array = all_words.slice(1) + + // accumulator + let computed_bytes : Array = []; + + // loop over words and figure out accumulator + for (let this_input_word of input_words) { + let maybe_this_byte : safe.Safe = byte_of_word(this_input_word); + // if the word is an allowable word, add it to the accumulator + if (maybe_this_byte.ok) { + let this_byte : number = maybe_this_byte.result; + computed_bytes.push(this_byte); + } + // error case, propagate the error up the call chain + else { + return maybe_this_byte; + } + } + + // at this point, we can assume we correctly decoded all words + // compute the check byte + let computed_check_word : string = check_word(computed_bytes); + + // check if it is correct + // if so, return the computed bytes + if (computed_check_word === input_check_word) { + return safe.ok(new Uint8Array(computed_bytes)); + } + // otherwise, return an error + else { + return safe.error('checksum failure! computed check word: ' + computed_check_word + '; input check word: ' + input_check_word); + } +} + + + +/** + * given a word, find its index + */ +function +byte_of_word + (word: string) + : safe.Safe +{ + for (let i=0; i<=255, i++) { + if (word == words[i]) + return safe.ok(i); + } + return safe.error('invalid word: ' + word); +} + + + +/** + * compute the check word of an array + */ +function +check_word + (bytes: Uint8Array) + : string +{ + return words[check_byte(bytes)]; +} + + +/** + * given an array, compute the xor of all the bytes in the array + */ +function +check_byte + (bytes: Uint8Array) + : number +{ + let check_byte = 0; + for (let this_byte of bytes) { + check_byte ^= this_byte; + } + return check_byte; +} + + + +words = [ + "able", + "abuse", + "acquire", + "adjust", + "agent", + "air", + "alert", + "alpha", + "anger", + "answer", + "any", + "argue", + "around", + "assume", + "asthma", + "aunt", + "awkward", + "balcony", + "barrel", + "because", + "behave", + "bicycle", + "bike", + "blind", + "blouse", + "bonus", + "bottom", + "breeze", + "brother", + "bubble", + "burger", + "butter", + "can", + "cannon", + "cargo", + "catalog", + "caught", + "century", + "chaos", + "chicken", + "churn", + "cinnamon", + "clever", + "clock", + "clown", + "collect", + "conduct", + "convince", + "correct", + "cradle", + "crane", + "crime", + "cross", + "crystal", + "curve", + "daughter", + "debris", + "decrease", + "deny", + "deputy", + "despair", + "diesel", + "dinner", + "distance", + "document", + "donate", + "drama", + "drink", + "dutch", + "earth", + "educate", + "elbow", + "employ", + "endless", + "enlist", + "enter", + "equal", + "eternal", + "example", + "exhibit", + "exotic", + "faculty", + "famous", + "fault", + "feature", + "fiber", + "filter", + "firm", + "flame", + "flush", + "follow", + "forward", + "frame", + "fringe", + "future", + "game", + "gate", + "gift", + "glare", + "glow", + "goat", + "grab", + "grief", + "guilt", + "hand", + "hawk", + "health", + "hen", + "hire", + "honey", + "hover", + "hurry", + "hybrid", + "impose", + "inch", + "inherit", + "injury", + "install", + "iron", + "jazz", + "joke", + "just", + "kit", + "kitchen", + "language", + "laundry", + "leader", + "lend", + "leopard", + "license", + "live", + "lobster", + "lounge", + "magnet", + "mail", + "mansion", + "mass", + "math", + "media", + "message", + "metal", + "misery", + "mix", + "more", + "mountain", + "museum", + "mutual", + "narrow", + "nerve", + "next", + "note", + "obey", + "obtain", + "offer", + "once", + "orange", + "ostrich", + "over", + "owner", + "palace", + "patch", + "pave", + "pen", + "phrase", + "piece", + "pizza", + "plunge", + "polar", + "pool", + "power", + "pretty", + "private", + "protect", + "pulp", + "purity", + "quit", + "quote", + "raise", + "razor", + "recall", + "region", + "relief", + "rent", + "rescue", + "review", + "ride", + "risk", + "roof", + "rough", + "saddle", + "salmon", + "sand", + "scene", + "scrub", + "season", + "seek", + "series", + "shed", + "shoe", + "sick", + "silent", + "situate", + "skill", + "slide", + "slush", + "snack", + "solar", + "soul", + "special", + "sphere", + "spot", + "spy", + "stairs", + "stereo", + "strategy", + "stuff", + "success", + "sunny", + "surge", + "swear", + "symptom", + "tail", + "ten", + "tent", + "theme", + "thumb", + "tiny", + "toe", + "tooth", + "topic", + "trade", + "trash", + "trophy", + "truly", + "tumble", + "typical", + "uncle", + "unfair", + "until", + "upper", + "useless", + "van", + "venue", + "video", + "visa", + "vocal", + "walk", + "waste", + "wedding", + "weekend", + "wide", + "winner", + "wise", + "wood", + "wrist", + "zero" +] From 662cdbd5de87023609aced867277e3fc102afda4 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 28 Apr 2023 18:43:59 -0600 Subject: [PATCH 3/5] jrx prettification --- jrx/README.md | 5 +++ jrx/ext/icons/keypair.svg | 82 +++++++++++++++++++++++++++++++++++++++ jrx/popup.html | 56 ++++++++++++++++---------- 3 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 jrx/README.md create mode 100644 jrx/ext/icons/keypair.svg diff --git a/jrx/README.md b/jrx/README.md new file mode 100644 index 0000000..86e696c --- /dev/null +++ b/jrx/README.md @@ -0,0 +1,5 @@ +# Jack Russell Extension + +## File Tree + + diff --git a/jrx/ext/icons/keypair.svg b/jrx/ext/icons/keypair.svg new file mode 100644 index 0000000..54435c1 --- /dev/null +++ b/jrx/ext/icons/keypair.svg @@ -0,0 +1,82 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/jrx/popup.html b/jrx/popup.html index cb99a42..af53d7f 100644 --- a/jrx/popup.html +++ b/jrx/popup.html @@ -1,38 +1,52 @@ - + + + -

Jack Russell

+ + + + + +
+ JÆCK RUSSELL +
- -
- -

Keypairs

- - -
- - -
- - -
- - - - -

Log

-

+
+ + + + + +
+ KEYPAIRS +
+
+ From d79697a9c717b4e10d115b7b29b80816234b7a95 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 28 Apr 2023 18:44:22 -0600 Subject: [PATCH 4/5] cleaning faert ts implementation --- libs/vdk/src/faert.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libs/vdk/src/faert.ts b/libs/vdk/src/faert.ts index c48b2e1..96997b7 100644 --- a/libs/vdk/src/faert.ts +++ b/libs/vdk/src/faert.ts @@ -32,7 +32,8 @@ encode // go along each byte and look up the word // add it to the accumulator - for (let this_byte of bytes) { + for (let this_byte of bytes) + { let this_word = words[this_byte]; words_acc.push(this_word); } @@ -62,17 +63,18 @@ decode let computed_bytes : Array = []; // loop over words and figure out accumulator - for (let this_input_word of input_words) { + for (let this_input_word of input_words) + { let maybe_this_byte : safe.Safe = byte_of_word(this_input_word); // if the word is an allowable word, add it to the accumulator - if (maybe_this_byte.ok) { + if (maybe_this_byte.ok) + { let this_byte : number = maybe_this_byte.result; computed_bytes.push(this_byte); } // error case, propagate the error up the call chain - else { + else return maybe_this_byte; - } } // at this point, we can assume we correctly decoded all words @@ -81,13 +83,11 @@ decode // check if it is correct // if so, return the computed bytes - if (computed_check_word === input_check_word) { + if (computed_check_word === input_check_word) return safe.ok(new Uint8Array(computed_bytes)); - } // otherwise, return an error - else { + else return safe.error('checksum failure! computed check word: ' + computed_check_word + '; input check word: ' + input_check_word); - } } @@ -100,8 +100,9 @@ byte_of_word (word: string) : safe.Safe { - for (let i=0; i<=255, i++) { - if (word == words[i]) + for (let i=0; i<=255, i++) + { + if (word === words[i]) return safe.ok(i); } return safe.error('invalid word: ' + word); @@ -130,9 +131,8 @@ check_byte : number { let check_byte = 0; - for (let this_byte of bytes) { + for (let this_byte of bytes) check_byte ^= this_byte; - } return check_byte; } From 478fcd123fc81227ce3761b7197a7f74c7d91b76 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Fri, 28 Apr 2023 18:44:52 -0600 Subject: [PATCH 5/5] trivial change to vb64 --- utils/vw/src/vb64.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/vw/src/vb64.erl b/utils/vw/src/vb64.erl index 09fa6e0..4cc961f 100644 --- a/utils/vw/src/vb64.erl +++ b/utils/vw/src/vb64.erl @@ -1,5 +1,6 @@ -module(vb64). +-compile([export_all]). -export([enc/1, dec/1]). -export([test/0]).