Documentation
¶
Overview ¶
Package drand is the signature method of SPEC.md section 6.5 (drand signatures): the load checks of the drand chain pins and DrandVerify, the check DERIVE makes of a drand entropy object's signature (section 10.2, step 9 (f)), and the round time of section 6.5, a drand round's candidate for the submitted-after edge (section 11.2). It reads no relay: the verifier uses the signature method in every run, so it makes no drand read (section 6.5, "Two methods").
The curve arithmetic is drand's own Go library, the one drand verifies its beacons of the scheme bls-unchained-g1-rfc9380 with: github.com/drand/kyber-bls12381's BLS12-381 suite under the domain separation tag BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_, and github.com/drand/kyber/sign/tbls's scheme on G1, whose VerifyRecovered is drand's VerifyBeacon. The suite's points are those of github.com/kilic/bls12-381, which decodes a compressed point as the appendix C of draft-irtf-cfrg-pairing-friendly-curves-11 does, with a coordinate refused unless it is below p, and refuses a point outside the subgroup of order r. It reads the identity's one encoding as the identity, which DrandVerify refuses; so the steps that decide whether a signature is canonical, 2 to 4, are made here first, with math/big, and the library's decoding then makes step 5 and its verification steps 6 and 7:
| Step of DrandVerify | Made by | |----------------------------------------------------------------------|------------------------------------| | 1. s is 48 bytes that matched DRANDSIG | [Chain.Verify], from the hex | | 2. the compression flag is 1 and the infinity flag 0 | [Chain.Verify] | | 3. x, s with its three flags cleared, is below p | [Chain.Verify], math/big | | 4. x^3 + 4 is a square mod p | [Chain.Verify], math/big | | 5. S, the point of x and the sign flag, is in G1 | kyber-bls12381's decoding | | 6. H = hash_to_curve(SHA-256(uint64_be(round))) under the G1 DST | tbls's VerifyRecovered | | 7. e(S, g2) = e(H, K_d) | tbls's VerifyRecovered |
The message of step 6, SHA-256(uint64_be(round)) with no prefix, and a chain's hash, which Load recomputes, are the two hashes this package makes; SPEC.md section 4.1 puts both outside the registry, among the hashes an outside protocol fixes.
Index ¶
Constants ¶
const ( CheckScheme = "scheme" CheckPeriod = "period" CheckChainHash = "chain_hash" CheckPublicKey = "public_key" )
The load checks of a chain's pins, by what each checks (see the file's doc).
const Scheme = "bls-unchained-g1-rfc9380"
Scheme is the one scheme a pinned chain may have (SPEC.md section 6.5).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
Network string
ChainHash string
GenesisTime int64
Period int64
// contains filtered or unexported fields
}
Chain is one drand network's chain, its pins loaded: the network, its hash as lowercase hex, its genesis time in Unix seconds and its period in seconds, and K_d, its public key decoded, which only Chain.Verify reads.
func Load ¶
func Load(network string, pins specdata.DrandChain) (*Chain, error)
Load makes the load checks of SPEC.md section 6.5 on pins, the chain of network in spec/drand-chains.json, and gives the chain, or the *LoadFailure of the first check that fails, in the file's order.
func (*Chain) RoundTime ¶
RoundTime is T(n) = genesis_time + (n - 1) x period, the round time of round n of the chain in Unix seconds (SPEC.md section 6.5, "The round time"), and whether it is one: n is at least 1, and the time, from a genesis time no earlier than the Unix epoch, fits an int64.
func (*Chain) Verify ¶
Verify is DrandVerify(K_d, n, s) of SPEC.md section 6.5, with K_d the chain's key, n round and s the 48 bytes signature spells as lowercase hex: nil when the signature passes, and otherwise the Refusal of the first step that fails. It reads nothing but its arguments and the chain's pinned key, so the object's own network never selects the key. The schema keeps round from 1 to MAX_INTEGER (section 3.5), inside drand's range; round 0, drand's genesis, has no signature, so no signature passes under it.
type LoadFailure ¶
LoadFailure is a load check a network's pins failed: the network, the check, and why.
func (*LoadFailure) Error ¶
func (f *LoadFailure) Error() string