@ de62e8f8076f6010f59527991dbc61d7625a603e | history
package lisp2gov
import (
"crypto/ed25519"
"crypto/sha256"
"strconv"
)
// DefaultSeed signs programs compiled without an author key. It is public
// on purpose: anyone can rebuild, amend or repeal such a program, and
// `government verify` says so.
var DefaultSeed = sha256.Sum256([]byte("GOVERNMENT"))
// keyForDepth returns the signing key of the cert at depth i (0 is the
// anchor). Deriving every key from one seed keeps output deterministic and
// means the seed's holder alone can rebuild the chain or sign repeals.
func keyForDepth(seed [32]byte, i int) ed25519.PrivateKey {
if i == 0 {
return ed25519.NewKeyFromSeed(seed[:])
}
h := sha256.New()
h.Write(seed[:])
h.Write([]byte("GOVERNMENT"))
h.Write([]byte(strconv.Itoa(i)))
return ed25519.NewKeyFromSeed(h.Sum(nil))
}