@ 21ba553f2ac9aed7435e6a7744c2a33c37c9dec8 | 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))
}