Simple Shamir's Secret Sharing (s4) - A go package giving a easy to use interface for the shamir's secret sharing algorithm

Simple Shamir's Secret Sharing (s4)

With Simple Shamir's Secret Sharing (s4) I want to provide you an easy to use interface for this beautiful little piece of math.

Please note that s4 is provided as it is and I do not take responsibility for any bugs. s4 is a tiny layer around hashicorp vault shamir and golang's AES encryption.

📚 Usage as library

You can use s4 as normal go library in your go projects by importing it via import "github.com/simonfrey/s4" and en-/decrypt bytes to byte shares and vice versa

🏠 Building the WASM for the frontend

I assume you have a go build environment setup in your machine.

In order to build & pack the web assembly file for the frontend please use the following command in the top level directory:

bash buildFrontend.sh

This will build you the required file. You now can copy to frontend folder to your web server (or use it locally) and it should run s4 as intended.

💸 Report Bugs & Tip

Please use Github Issues in order to report bugs

💸 If you want to tip me for my work on this project feel free to do so 💸

🗣 Discussions

s4 was broadly discussed on HackerNews, and was mentioned in golang weekly in June 2020.

📃 License

MIT License

Owner
Simon Frey
Hacker - Blogger - Organiser
Simon Frey
Comments
  • Website does not work offline

    Website does not work offline

    Hey! I'm trying to use the S4 website after downloading, but somehow after the page is downloaded (as webpage complete) some Javascript is not being activated.

    See: https://ibb.co/7gXn6Hp

  • How to use the go library ?

    How to use the go library ?

    Hello,

    I'm trying to use the s4 go library to encrypt and decrypt bytes. But when using import "github.com/simonfrey/s4" as written in the README, I get a strange error :

    go: finding github.com/simonfrey/s4 latest go: downloading github.com/simonfrey/s4 v0.0.0-20210502093622-aa95753ec8f6 go: extracting github.com/simonfrey/s4 v0.0.0-20210502093622-aa95753ec8f6 go: test imports github.com/simonfrey/s4: github.com/simonfrey/[email protected]: parsing go.mod: module declares its path as: s4 but was required as: github.com/simonfrey/s4

    I've tried the rewrite directive in my go.mod but it's only making things worse. How to correctly import this library ? Thanks !

  • Remove vue (fixes #11)

    Remove vue (fixes #11)

    First of all thanks for sharing this repo @simonfrey !

    This PR is really heavy handed - no hard feelings if you don't want to go down this road.

    It replaces the Vue dependency with a super-micro "framework" that you can see here in framework.js.

    Each "component" manages its own state, and every "render" forces a re-render of all of it's children, so it's pretty 'dumb' but it gets the job done in just 60 lines of "framework code".

    The render trees themselves are just using the el and append functions (also in framework.js) which are helpers for creating DOM elements, applying properties, and (recursively) appending children.


    I tried to keep all the major functionality identical, but I did tweak it so that each form has its own "error" state and rendering. I also removed the ability to hide the errors because that doesn't play nicely with how I implemented "computed properties", which re-trigger the error that you just tried to clear.


    Also ./buildFrontend.sh wasn't executable so that's also patched here :)

  • Prevent running dom modifications before dom is loaded

    Prevent running dom modifications before dom is loaded

    I think this will solve #20

    When loaded locally, the javascript could execute before the DOM was parsed, leading to a situation where the decrypt inputs didn't have events attached to them.

  • Bug fixes, legibility improvements and various refinements

    Bug fixes, legibility improvements and various refinements

    Hello,

    First thanks for this project :+1:

    I'm currently using your tool and by looking at the source I've found your two open issues (#20, #21) and wanted to help. I fixed them and added a few extras along the way.

    What's new :

    • WASM binary is slightly smaller.
    • The output is now a single HTML page, CSS and JS are packed inside at build time (thanks awk). I found it handy to move this tool around as one file only.
    • I updated the JavaScript with a more contemporary syntax and hopefully made it more straightforward too.
    • Textareas are cleared when pressing Ctrl+S to avoid storing secrets.
    • Bulma CSS is no more, I wrote simple and modern CSS from scratch to make the project even more understandable. I kept the same look and feel.
    • HTML is now even simpler.

    I hope you like it, let me know what we can improve.

    Have a nice day !

  • Replace vue.js

    Replace vue.js

    Vue.js is the biggest blog of not understandable code in this project. Would be nice if that could be replaced with a lower attack surface vanilla javascript code

  • Remove bulmacss

    Remove bulmacss

    The bulma.css (https://bulma.io/) we use is already quite small, but as we only use a quite low percentage of it, we could remove it to make the project even more understandable.

    It would be desirable to get rid of this file: https://github.com/simonfrey/s4/blob/master/frontend/css/bulma.min.css

  • Readme still references sharedsecret

    Readme still references sharedsecret

    Please note that s4 is provided as it is and I do not take responsibility for any bugs. s4 is a tiny layer around sharedsecret and golang's AES encryption.

  • Replaces mention of posener/sharedsecret with hashicorp/vault to catc…

    Replaces mention of posener/sharedsecret with hashicorp/vault to catc…

    …h up with code change

    https://github.com/simonfrey/s4/commit/c5934512c30db8030831bd293a3b291b2f9a8678 I think changes from github.com/posener/sharedsecret to github.com/hashicorp/vault ; this updates the text in the index.html to reflect that

  • Replace sharedsecret dependency with hasi corps vault implementation

    Replace sharedsecret dependency with hasi corps vault implementation

    As the hashi corp shamir secret sharing is used in a lot wider array of applications and hashi corp has a financial interest in keeping the library up to date and working I want to move away from the shared secret library to https://github.com/hashicorp/vault/blob/master/shamir/shamir.go

  • func TestSecretSharingSameShares: rand.Intn(n int) panics if n <= 0

    func TestSecretSharingSameShares: rand.Intn(n int) panics if n <= 0

    If merged, this pull request addresses the issue that func TestSecretSharingSameShares panics depending on what value is assigned to n.

    Background: From the docs, rand.Intn(myInt int) returns a a non-negative pseudo-random number in [0,myInt). It panics if myInt <= 0.

    Here if n is assigned 0, 1, or 2 then the line where k is defined panics.

    Note: This test still fails. This PR addresses the random element of this test failing. The remaining element will be addressed in a different PR.

  • Replace included wasm_exec.js with the local one

    Replace included wasm_exec.js with the local one

    The WebAssembly JavaScript support file is currently included in the project. I think a better approach is using the file present in the Go root folder.

    According to the WebAssembly documentation, wasm_exec.js can be retrieved from the local Go root folder using

    cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
    

    Therefore in this commit:

    • I have removed frontend/js/wasm_exec.js
    • I have included this file to the .gitignore to avoid risking to commit it
    • I have added the WebAssembly documentation command to the build script
Simple key value database that use json files to store the database

KValDB Simple key value database that use json files to store the database, the key and the respective value. This simple database have two gRPC metho

Nov 13, 2021
Kivik provides a common interface to CouchDB or CouchDB-like databases for Go and GopherJS.

Kivik Package kivik provides a common interface to CouchDB or CouchDB-like databases. The kivik package must be used in conjunction with a database dr

Dec 29, 2022
Beerus-DB: a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic operations

Beerus-DB · Beerus-DB is a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic

Oct 29, 2022
datatable is a Go package to manipulate tabular data, like an excel spreadsheet.
datatable is a Go package to manipulate tabular data, like an excel spreadsheet.

datatable is a Go package to manipulate tabular data, like an excel spreadsheet. datatable is inspired by the pandas python package and the data.frame R structure. Although it's production ready, be aware that we're still working on API improvements

Nov 23, 2022
moss - a simple, fast, ordered, persistable, key-val storage library for golang

moss moss provides a simple, fast, persistable, ordered key-val collection implementation as a 100% golang library. moss stands for "memory-oriented s

Dec 18, 2022
A simple, fast, embeddable, persistent key/value store written in pure Go. It supports fully serializable transactions and many data structures such as list, set, sorted set.

NutsDB English | 简体中文 NutsDB is a simple, fast, embeddable and persistent key/value store written in pure Go. It supports fully serializable transacti

Jan 1, 2023
Fast and simple key/value store written using Go's standard library
Fast and simple key/value store written using Go's standard library

Table of Contents Description Usage Cookbook Disadvantages Motivation Benchmarks Test 1 Test 4 Description Package pudge is a fast and simple key/valu

Nov 17, 2022
Simple implementation of a sharded mutex in Go
Simple implementation of a sharded mutex in Go

Sharded Mutex in Go This package contains a sharded mutex which should do better than a traditional sync.RWMutex in certain cases where you want to pr

May 7, 2022
A simple Git Notes Key Value store

Gino Keva - Git Notes Key Values Gino Keva works as a simple Key Value store built on top of Git Notes, using an event sourcing architecture. Events a

Aug 14, 2022
Simple DB using yaml. A project for managing the content of yaml files.

DB Yaml Simple DB using yaml. A project for managing the content of yaml files. Table of Contents DB Yaml Features Usage Write to DB Query DB Get Firs

Dec 27, 2022
This is a simple graph database in SQLite, inspired by "SQLite as a document database".

About This is a simple graph database in SQLite, inspired by "SQLite as a document database". Structure The schema consists of just two structures: No

Jan 3, 2023
A simple memory database. It's nothing but a homework to learn primary datastruct of golang.

A simple memory database. It's nothing but a homework to learn primary datastruct of golang.

Nov 8, 2021
Go reproduction of Bustub--a simple relational database system.

Bustub in Golang Bustub is the course project of CMU15-445 Database System, which is a simple relational database system. This repo is a golang reprod

Dec 18, 2021
A simple wrapper around badgerDB that can be used across multiple projects

mstore Mstore is a simple wrapper around badgerDB for platform applications that require a quick persistent cache close to the consumer. It's intended

Dec 14, 2021
Simple Go program to prevent AFK timeouts during FFXIV Endwalker launch.
Simple Go program to prevent AFK timeouts during FFXIV Endwalker launch.

Idler Just a super simple keyboard idler written in Go, to assist in hands-free queueing/preventing AFK timeouts during the FFXIV Endwalker expansion

Dec 22, 2021
Fsyncperf - A very simple program to tell how fast/slow is fsync on your disk

fsyncperf This is a very simple program to tell you who fast/slow is fsync on yo

May 9, 2022
Simple-read-file - Example of how to read file in Go

simple-read-file This repository contains a simple example of how to read file i

Jan 11, 2022
This is a simple Golang application that executes SQL commands to clean up a mirror node's database.

This is a simple Golang application that executes SQL commands to clean up a mirror node's database.

Jan 24, 2022
GoPostgreSQL - An example usage of PostgreSQL with GO, very simple since the objective is that others can read and learn
GoPostgreSQL - An example usage of PostgreSQL with GO, very simple since the objective is that others can read and learn

GoPostgreSQL - An example usage of PostgreSQL with GO, very simple since the objective is that others can read and learn

Feb 10, 2022