kidwords

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 13 Imported by: 1

README

Kid Words, Alpha

Provides durable and accessible paper key encoding that children can use.

Warning: alpha version is not stable and subject to iteration!

Printable paper keys are occasionally used as the last resort for recovering account access. They increase security by empowering a user with the ability to wrestle control of a compromised account from an attacker.

Most paper keys are encoded using BIP39 convention into a set of words. The final few words encode the integrity of the key with a cyclical redundancy check. When printed and stored, such keys are not durable because they can be lost to minor physical damage.

Kid Words package or command line tool increases key durability by splitting the key using Shamir's Secret Sharing algorithm into shards and encoding each shard using a dictionary of 256 four-letter English nouns.

Benefits

  • Keys can be recovered from partially damaged paper.
  • Shards can be transmitted and memorized by children.
  • Shards are easier to speak over poor radio or telephone connection, which can save time during an emergency.
  • Shards can be hidden in several physical locations by cutting the paper into pieces. Once a configurable quorum of shards, four by default, is gathered back, the key can be restored.
  • Shards can easily be obfuscated by sequencing:
    • toys or books on a shelf
    • pencil scribbles on paper
    • objects or signs in a Minecraft world
    • emojis
  • Command line tool can apply all of the above benefits to:
    • important passwords to rarely accessed accounts that do not support paper keys
    • conventional BIP39 keys

Development Checklist

  • Harden Shamir's Secret Sharing algorithm with mod Prime.
  • finish Argon hashing
  • finish SQL store
  • add BIP39 converter
  • add Mongo store
  • Add Emoji dictionary
  • Add random password generator

Using as Library


import (
  "fmt"
  "os"

  // To install the library run shell command:
  //
  // $ go get github.com/dkotik/kidwords@latest
  "github.com/dkotik/kidwords"
  "github.com/dkotik/kidwords/shamir"
)

func main() {
  // break a secret key into shards
  shards, err := kidwords.Split(
    []byte("secret paper key"), // encoding target
    12,                         // number of shards
    4,                          // quorum number of shards
                                // needed to recover the original
  )
  if err != nil {
    panic(err)
  }
  if _, err = shards.Grid(
    3,  // number of table columns
    18, // number of characters to wrap the text at
  ).Write(os.Stdout); err != nil {
    panic(err)
  }

  // reconstitute the key back using a quorum of four shards
  key, err := shamir.Combine(shards[0:4])
  if err != nil {
    panic(err)
  }
  fmt.Println(string(key))
  // Output: secret paper key
}

Using as Command Line Tool

$ go install github.com/dkotik/kidwords/cmd/kidwords@latest
$ kidwords split somePaperKey
🔑 Pick any 4 shards:
┌──────────────╥──────────────╥──────────────┐
│farm line belt║line hall cash║view home shot│
│beer crab pity║trap loot site║room turn tale│
│hour fund fuel║head flag pool║bank wind deal│
╞══════════════╬══════════════╬══════════════╡
│line hall cash║view home shot║help dirt turn│
│trap loot site║room turn tale║goat coat heir│
│head flag pool║bank wind deal║moss iron tour│
╞══════════════╬══════════════╬══════════════╡
│view home shot║help dirt turn║golf tape font│
│room turn tale║goat coat heir║pear debt dust│
│bank wind deal║moss iron tour║lake urge bush│
╞══════════════╬══════════════╬══════════════╡
│help dirt turn║golf tape font║wish risk cold│
│goat coat heir║pear debt dust║trap room card│
│moss iron tour║lake urge bush║firm moon root│
└──────────────╨──────────────╨──────────────┘
$ go run github.com/dkotik/kidwords/cmd/kidwords@latest combine

Documentation

Overview

Package kidwords provides durable and accessible paper key encoding that children can use.

Printable paper keys are occasionally used as the last resort for recovering account access. They increase security by empowering a user with the ability to wrestle control of a compromised account from an attacker.

Most paper keys are encoded using BIP39 convention into a set of words. The final few words encode the integrity of the key with a cyclical redundancy check. When printed and stored, such keys are not durable because they can be lost to minor physical damage.

Kid Words package or command line tool increases key durability by splitting the key using [Shamir's Secret Sharing](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing) algorithm into shards and encoding each shard using a dictionary of 256 four-letter English nouns.

## Benefits

- Keys can be recovered from partially damaged paper. - Shards can be transmitted and memorized by children. - Shards are easier to speak over poor radio or telephone connection, which can save time during an emergency. - Key shards can be hidden in several physical locations by cutting the paper into pieces. Once a configurable quorum of shards, three by default, is gathered back, the key can be restored. - Shards can easily be obfuscated by sequencing:

  • toys or books on a shelf
  • pencil scribbles on paper
  • objects or signs in a Minecraft world
  • emojis

- Command line tool can apply all of the above benefits to:

  • important passwords to rarely accessed accounts that do not support paper keys
  • conventional BIP39 keys

## Inspired By

- [Horcrux][horcrux]

horcrux: https://github.com/jesseduffield/horcrux/tree/master

Index

Examples

Constants

This section is empty.

Variables

View Source
var ChecksumTable = crc32.MakeTable(crc32.Koopman)

Functions

func ChecksumChop

func ChecksumChop(b []byte) (remainder []byte, ok bool)

func ChecksumWriter

func ChecksumWriter(w io.Writer) io.WriteCloser

func FromBytes

func FromBytes(b []byte, withOptions ...WriterOption) (string, error)

FromBytes translates a set of bytes into Kid Words.

Example
fmt.Println(
	FromBytes([]byte("marvel")),
)
Output:

hole gold hush item half hint <nil>

func FromReader

func FromReader(r io.Reader, withOptions ...WriterOption) (string, error)

FromReader translates io.Reader stream into Kid Words.

func FromString

func FromString(s string, withOptions ...WriterOption) (string, error)

FromString translates a string into Kid Words.

func ToBytes

func ToBytes(s string, withOptions ...ReaderOption) ([]byte, error)

ToBytes translates Kid Words into bytes.

Example
b, err := ToBytes("  hole gold hush item half hint ")
fmt.Println(string(b), err)
Output:

marvel <nil>

func ToString

func ToString(s string, withOptions ...ReaderOption) (string, error)

ToString translates Kid Words into a string.

func ToWriter

func ToWriter(w io.Writer, s string, withOptions ...ReaderOption) error

ToWriter streams translated Kid Words into io.Writer.

Types

type Option

type Option interface {
	ReaderOption
	WriterOption
}

func WithDictionary

func WithDictionary(d *dictionary.Dictionary) Option

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.Reader, withOptions ...ReaderOption) (*Reader, error)

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type ReaderOption

type ReaderOption interface {
	// contains filtered or unexported methods
}

type SeparatorFunc

type SeparatorFunc func() []byte

type SplitFunc func()

type Shards added in v0.0.2

type Shards []string

func Split added in v0.0.2

func Split(
	key string,
	total,
	quorum int,
	withOptions ...WriterOption,
) (shards Shards, err error)

func (Shards) Grid added in v0.0.2

func (s Shards) Grid(columns, wrap int) tgrid.Grid

func (Shards) String added in v0.0.2

func (s Shards) String() string

func (Shards) Write added in v0.0.2

func (s Shards) Write(w io.Writer) (int, error)

func (Shards) WriteHTML added in v0.0.2

func (s Shards) WriteHTML(w io.Writer, columns int) (err error)

type Writer

type Writer struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(out io.Writer, withOptions ...WriterOption) (*Writer, error)

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

type WriterOption

type WriterOption interface {
	// contains filtered or unexported methods
}

func WithSeparator

func WithSeparator(f SeparatorFunc) WriterOption

Directories

Path Synopsis
cmd
kidwords Module
Package dictionary defines arrays of 256 words used for KidWords encoding.
Package dictionary defines arrays of 256 words used for KidWords encoding.
Package shamir implements Shamir Secret Sharing (SSS) scheme that splits a password into independent parts.
Package shamir implements Shamir Secret Sharing (SSS) scheme that splits a password into independent parts.
store module
test Module
Package tgrid represents tables as simple ASCII art.
Package tgrid represents tables as simple ASCII art.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL