Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spike init should create Shamir shards and save it on the user's local machine. #45

Open
v0lkan opened this issue Nov 22, 2024 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@v0lkan
Copy link
Contributor

v0lkan commented Nov 22, 2024

Once we have this functionality, we will use it further.

Shamir's Secret Sharing is a standard algorithm and there are many implementations; so writing it from scratch does not make sense.

There is This library that offers an intuitive API and also is compatible with our (and CNCF's) licensing model (i.e. we can just go get it and we'll be good to go)

This task involves the following:

  • SPIKE Pilot would accept configuration for threshold (i.e. minimum number of share) and shares (i.e. total number of shares). If the environment variables are not present, we'll assume sane default. (let's call them T an N)
  • During initialization (i.e. when spike init is called) we will compute N shares and store them in memory.
  • We will also randomly select T of those N shares and save them in ~/.spike/recovery/recovery-token-$shareNumber.spike

That's the entirety of this current task.

Later once we have >1 SPIKE Keepers instances up and running, we will design a method to distribute the shards to Keeper instances; but that's out of the scope of this task.

Ref:
Wikipedia Article about Shamir's Secret Sharing

@v0lkan v0lkan added the good first issue Good for newcomers label Nov 22, 2024
@gurkanguray
Copy link
Contributor

@v0lkan /assign

@v0lkan
Copy link
Contributor Author

v0lkan commented Dec 9, 2024

A few details as usual:

We will need environment variables for config:

  • SPIKE_SHAMIR_THRESHOLD
  • SPIKE_SHAMIR_SHARES

I guess, both Nexus, Keeper(s) and Pilot will need to be aware of these configuration values.

This is how the code typically consumes environment variables as configuration options:

// ./app/spike/internal/env/net.go

// NexusApiRoot returns the URL of the Nexus API.
func NexusApiRoot() string {
	p := os.Getenv("SPIKE_NEXUS_API_URL")
	if p != "" {
		return p
	}
	return "https://localhost:8553"
}

Other than that, this task boils down to learning + using the linked library and creating those shared during spike init.

Thanks for your interest @gurkanguray and good luck.

Feel free to bug me if you need anything.

@v0lkan
Copy link
Contributor Author

v0lkan commented Dec 9, 2024

Assigned!

In the meantime, I'll work on having multiple keeper instances (on the same machine, but still...) so we can test fanning out the pieces and Nexus retrieving them etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

2 participants