You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.0 KiB
54 lines
2.0 KiB
package profile
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"time"
|
|
)
|
|
|
|
// Quicknet Provider Profile V1 parameters, pinned in the binary (spec §12).
|
|
// No relay, API or ciphertext can replace them (spec §13, §35).
|
|
const (
|
|
QuicknetID = "datekeys:quicknet:v1"
|
|
QuicknetNetwork = "quicknet"
|
|
QuicknetChainHash = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971"
|
|
QuicknetPublicKey = "83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a"
|
|
QuicknetGenesisSeed = "f477d5c89f21a17c863a7f937c6a6d15859414d2be09cd448d4279af331c5d3e"
|
|
QuicknetGenesisTime = int64(1692803367)
|
|
QuicknetPeriod = 3 * time.Second
|
|
QuicknetScheme = "bls-unchained-g1-rfc9380"
|
|
|
|
// QuicknetProfileHash is profile_hash of the Quicknet profile: SHA-256 of
|
|
// its exact Deterministic CBOR (spec §11). It is the first official vector,
|
|
// frozen in testdata/vectors/profile_quicknet.json, and part of the root of
|
|
// trust of spec §13: Default refuses to build if the compiled-in
|
|
// parameters do not reproduce it.
|
|
QuicknetProfileHash = "4147645109798ecbc9f630c2f709835bb5846fe7911a6bd5c5755e25ade2ada4"
|
|
)
|
|
|
|
// Quicknet returns a fresh copy of the pinned Quicknet Provider Profile V1.
|
|
// A function instead of a package variable keeps the root of trust free of
|
|
// shared mutable state.
|
|
func Quicknet() *Profile {
|
|
p := &Profile{
|
|
ID: QuicknetID,
|
|
Provider: ProviderDrand,
|
|
Network: QuicknetNetwork,
|
|
PublicKey: mustHex(QuicknetPublicKey),
|
|
Period: QuicknetPeriod,
|
|
GenesisTime: QuicknetGenesisTime,
|
|
Scheme: QuicknetScheme,
|
|
}
|
|
copy(p.ChainHash[:], mustHex(QuicknetChainHash))
|
|
copy(p.GenesisSeed[:], mustHex(QuicknetGenesisSeed))
|
|
return p
|
|
}
|
|
|
|
// mustHex decodes compile-time constants only.
|
|
func mustHex(s string) []byte {
|
|
b, err := hex.DecodeString(s)
|
|
if err != nil {
|
|
panic("profile: invalid pinned constant: " + err.Error())
|
|
}
|
|
return b
|
|
}
|