taubyte / tau

Open source distributed Platform as a Service (PaaS). A self-hosted Vercel / Netlify / Cloudflare alternative.
https://tau.how
BSD 3-Clause "New" or "Revised" License
3.2k stars 85 forks source link

[libdream] Each universe should have it's own swam key #159

Closed samyfodil closed 3 months ago

samyfodil commented 3 months ago

We are using a static dev mode swam key in libdream. See: https://github.com/taubyte/tau/blob/main/libdream/simple.go#L145 https://github.com/taubyte/tau/blob/main/libdream/universe.go#L222

While this was fine at the very start, it's causing issues when running multiple tests in parallel.

We need a function like:

func generateSwarmKey(id string) string {
    hash := sha256.Sum256([]byte(id))
    return "/key/swarm/psk/1.0.0//base16/" + hex.EncodeToString(hash[:])
}

Which will generate the same swarm key for the same universe id, and use that in lieu of protocols.SwarmKey()

Maybe have universe.SwarmKey() which calls generateSwarmKey and caches the result, or call generateSwarmKey when universe is created here https://github.com/taubyte/tau/blob/main/libdream/universe.go#L22. I prefer the second way better.

protocols.SwarmKey() function should then be deleted.