kidwords

package module
v0.0.1 Latest Latest
Warning

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

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

README

Kid Words, Alpha

Data encoding accessible to children for generating passwords and paper keys or splitting them into shards using Shamir's Secret Sharing algorithm.

Release Checklist

  • Add Shamir's Secret Sharing key splitting.
  • Add Shamir's Secret Sharing key re-combination.
  • Harden Shamir's Secret Sharing algorithm with mod Prime.
  • Add HTML SeparatorFunc.

Command Line Tool

# Command line tool installation:
go install github.com/dkotik/kidwords/cmd/kidwords@latest
kidwords --help
Key Splitting

The secret is compressed using Zstd algorithm before getting split into eight shards. Quorum is set using --quorum=3 flag.

The number of shards is limited to eight in order to use additional 13 bites for an error detection code. The shard ordinal and the error detection code are expressed as two additional words appended to the end of each shard. (This is wrong - the last byte encodes a random shard ordinal from 0-255)

When the quorum is set to 3 any three of the shards will be sufficient to recover the secret. If the quorum is set to 8, every single shard will be required.

Library

// In shell: $ go get github.com/dkotik/kidwords@latest

func main() {
  w, err := kidwords.NewWriter(os.Stdout)
  if err != nil {
    panic(err)
  }
  _, _ = w.Write([]byte("test")) // will output words  
}

Documentation

Overview

Package kidwords provides data encoding accessible to children.

Use it to create passwords and paper 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:

hill golf hush itch half hero <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("  hill - golf hush itch ; half hero ")
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 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
JackTT - Gopher 🇻🇳