Split and distribute your private keys securely amongst untrusted network

cocert

An experimental tool for splitting and distributing your private keys safely*

MIT GitHub release Go Report Build Status


cocert, generates ECDSA - P521 key and uses a technique known as Shamir's Secret Sharing algorithm to split the master key into x shares, any y of which are required to reconstruct the master private key. Private keys are stored in PEM-encoded PKCS8 format, which are encrypted by The Update Framework (TUF). Each private key is splitted using Shamir Split. To Combine private key files into single one, it is necessary to enter decrypt password if it has been encrypted by TUF.

*cocert does not support any Distributed Key Generation (DGK) algorithm, yet.

This repository is signed via cosign, by using cocert itself

GIF

Asciinema

High Level Architecture

Screenshot

Use-Case Example

  • What happens if your private key is exposed by either public 3rd-party cloud service provider or internal security breach?

Your private key would have compromised and supply chain attacks would inevitable. What would happen if we not trust just one key, however, distribute our key to multiple secure environments? We would avoid supply chain attacks, that said, even if one of our private keys is compromised, we still need two more keys to combine and get the final private key.

Screenshot

Installation

  • Go
$ go install github.com/Dentrax/cocert@latest
  • Docker
$ docker pull ghcr.io/dentrax/cocert

Verify

Prerequities

  1. cosign
  2. crane

Check

# 1. Download the public key
$ curl https://raw.githubusercontent.com/Dentrax/cocert/main/.github/workflows/certs/cocert.pub -o cocert.pub

# 2. Verify
$ cosign verify -key cocert.pub ghcr.io/dentrax/cocert | jq

# 3. Make sure verified commit matches the digest of the latest image 
$ crane digest ghcr.io/dentrax/cocert

Usage

Usage:
  cocert [command]

Available Commands:
  combine     Combine the cert integrity on the supplied PEM files
  decrypt     Decrypt the target private keys using TUF
  encrypt     Encrypt the target private keys using TUF
  generate    Generates TUF encrypted keys using ECDSA and splits into PKCS8-PKIX key-pairs
  help        Help about any command
  sign        Sign the given payload and create a certificate from Fulcio
  split       Split your existing private key into parts
  verify      Verify the given payload on the supplied signature

Flags:
  -h, --help   help for cocert

Use-Case Demonstration

  1. Generate
$ cocert generate --parts 3 --threshold 2

Generating TUF encrypted Shamir PEMs...
Create new password for private key:  (master)
Confirm password: (master)
Extracting PEMs to files...
Do you want to encrypt each key using TUF? (y/n) [n]: y
Create new password for cocert0.key key: (foo)
Create new password for cocert1.key key: (bar)
Create new password for cocert2.key key: (baz)

2.1. Sign with Private Key

$ cocert sign -f cocert0.key -f cocert1.key -p "Foo Bar Baz"

(Press Enter to continue without decrypt...)
Enter your password for cocert0.key: (foo)
Enter your password for cocert1.key: (bar)
Enter your master key: (master)
Signed: MIGIAkIBCisWXRLBRcv/...+3pccRjm+nUNA==

2.2. Sign with Fulcio (Keyless)

$ cocert sign -f cocert0.key -f cocert1.key  -p "Foo Bar Baz" -o my.cert

(Press Enter to continue without decrypt...)
Enter your password for cocert0.key: (foo)
Enter your password for cocert1.key: (bar)
Enter your master key: (master)
Your browser will now be opened to:
https://oauth2.sigstore.dev/auth/auth?access_type=online&client_id=sigstore&code_challenge=CODE&code_challenge_method=S256&nonce=NONCE&redirect_uri=http%3A%2F%2Flocalhost%3A5556%2Fauth%2Fcallback&response_type=code&scope=openid+email&state=STATE
Signed: MIGIAkIBCisWXRLBRcv/...+3pccRjm+nUNA==

3.1. Verify with Public Key

$ cocert verify -f cocert.pub -p "Foo Bar Baz" -k "MIGIAkIBCisWXRLBRcv/...+3pccRjm+nUNA=="

3.2. Verify with Certificate

$ cocert verify -c my.cert -p "Foo Bar Baz" -k "MIGIAkIBCisWXRLBRcv/...+3pccRjm+nUNA=="

Bonus: Splitting

# 1. Generate the your custom private key
$ cosign generate-key-pair

Enter password for private key: (qux)
Private key written to cosign.key
Public key written to cosign.pub

# 2. Split the key
$ cocert split -f private.key --parts 3 --threshold 2

Create new password for cocert0.key key: (foo)
Create new password for cocert1.key key: (bar)
Create new password for cocert2.key key: (baz)

# 3. Test with combine
$ cocert combine -f cocert0.key -f cocert1.key -o cosign.key

Enter your password for cocert0.key: (foo)
Enter your password for cocert1.key: (bar)
Decrypting TUF encrypted PEMs...
Enter your master key: (qux)
Combined

Encrypt & Decrypt Keys

  • Encrypt
$ cocert encrypt -f cocert0.key -o "cocert0.key.encrypted"

Enter your password for : (foo2)
Confirm password: (foo2)
  • Decrypt
$ cocert decrypt -f cocert0.key.encrypted -o "cocert0.key.decrypted"
# [[ $(md5 -q cocert0.key) -eq $(md5 -q cocert0.key.decrypted) ]]

Enter your password for : (foo2)

$ cocert decrypt -f cocert0.key.decrypted -o "cocert0.key.unencrypted"
# You can pass empty password for 'cocert0.key.unencrypted' key

Enter your password for : (foo)
  • Combine
$ cocert combine -f cocert0.key.unencrypted -f cocert1.key 

Loading PEMs from files...
(Press Enter to continue without decrypt...)
Enter your password for cocert0.key.unencrypted: (PASS)
Enter your password for cocert1.key: (bar)
Decrypting TUF encrypted PEMs...
Enter your master key: (master)
Combined

Special Thanks

Package Author License
cosign sigstore Apache License 2.0
go-tuf The Update Framework BSD
Vault HashiCorp Mozilla Public License 2.0
prompter Songmu MIT
  • Thanks to everyone who contributed these libraries and others that made this project possible.

License

cocert was created by Furkan 'Dentrax' Türkal

The base project code is licensed under MIT unless otherwise specified. Please see the LICENSE file for more information.

Best Regards

Owner
Furkan Türkal
Trying to learn something new every day and still finding new mistakes to make... (SDÜ - Computer Science)
Furkan Türkal
Similar Resources

Boxen - put your network operating systems in a box!

boxen boxen -- put your network operating systems in a box (or if you speak 🇩🇪 , fight them! 🤣 )! boxen is a cli tool written in Go that allows you

Nov 26, 2022

Community-run technology powering the cryptocurrency, and decentralized applications on TrustFi Network

Go TrustFi-Ethereum Official Golang implementation of the TrustFi-Ethereum protocol. Automated builds are available for stable releases and the unstab

May 26, 2021

Yet another Binance Smart Chain client based on TrustFi Network

TrustFi Smart Chain The goal of TrustFi Smart Chain is to bring programmability and interoperability to Binance Chain. In order to embrace the existin

Mar 27, 2021

LEO (Low Ethereum Orbit) is an Ethereum Portal Network client.

LEO LEO (Low Ethereum Orbit) is an Ethereum Portal Network client. What makes LEO different from other Portal Network clients is that it uses libp2p f

Apr 19, 2022

An implementation of the Filecoin Distributed Storage Network

An implementation of the Filecoin Distributed Storage Network

Project Lotus - 莲 Lotus is an implementation of the Filecoin Distributed Storage Network. For more details about Filecoin, check out the Filecoin Spec

Oct 27, 2021

Uniform interface for interacting with network hardware via telnet/ssh

jgivc/console This package provides a uniform interface for interacting with network hardware via telnet/ssh This package uses part of reiver/go-telne

Dec 9, 2021

Avalanche: a network composed of multiple blockchains

Coreth and the C-Chain Avalanche is a network composed of multiple blockchains.

Dec 14, 2022

Practicing network programming using Go. These are some fundamental APIs

Go Networking This repository is a collection of Network Programming APIs or sim

Apr 29, 2022
Map ssh-ed25519 keys into x25519 keys

ssh-x22519 ========== The twisted Edwards curve used for ed25519 signatures is birationally equivalent to the Montgomery curve used for x25519: it is

Jan 4, 2023
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

Jan 7, 2023
Arbitrum is a Layer 2 cryptocurrency platform that makes smart contracts scalable, fast, and private.
Arbitrum is a Layer 2 cryptocurrency platform that makes smart contracts scalable, fast, and private.

Arbitrum is a Layer 2 cryptocurrency platform that makes smart contracts scalable, fast, and private. Arbitrum interoperates closely with Ethereum, so Ethereum developers can easily cross-compile their contracts to run on Arbitrum. Arbitrum achieves these goals through a unique combination of incentives, network protocol design, and virtual machine architecture.

Jan 8, 2023
🌰 encrypt/decrypt using ssh keys

ssh-vault ?? encrypt/decrypt using ssh private keys Documentation https://ssh-vault.com Usage $ ssh-vault -h Example: $ echo "secret" | ssh-vault -u

Dec 30, 2022
Proving possession of private data using KZG-Polynomial Commitments.

data proof Copyright (c) 2021 George Carder [email protected] GENERAL PUBLIC LICENSE Version 3 // proof of concept // not efficient, optimized,

Nov 26, 2021
Public key derivator for ECDSA (without knowledge of the private key)

A proof of concept of a public key derivation for ECDSA (without knowledge of the private key) It is a demonstration of how to implement a simple key

Nov 9, 2022
Private Terraform Provider Registry For Golang

private-reggie Private Terraform Provider Registry Test With curl $ curl http://localhost:8080/terraform/providers/v1/hashicorp/hashicups/versions ht

Dec 13, 2021
Monero: the secure, private, untraceable cryptocurrency
Monero: the secure, private, untraceable cryptocurrency

Monero Copyright (c) 2014-2021 The Monero Project. Portions Copyright (c) 2012-2013 The Cryptonote developers. Table of Contents Development resources

Jan 2, 2023
Kiteco-public - Primary Kite repo — private bits replaced with XXXXXXX

This is a public version of the main Kite repo The main Kite repo (originally kiteco/kiteco) was intended for private use. It has been lightly adapted

Dec 30, 2022
EtherGuess - Crack Ethereum account private key
EtherGuess - Crack Ethereum account private key

EtherGuess This program generates random Ethereum private keys and check for acc

Jun 6, 2022