- identity: 12-word recovery phrase, device certificates, revocations, device key storage; the identity key is never stored on a node - listing: signed by a device with an embedded certificate, domain-separated signatures, ErrTimeWindow for clock-related failures, region helpers - store: revocations purge a device's listings; keyset-paged Since for sync - p2p: gossipsub topic per geohash region plus a global revocation topic, validators run before relaying, /allmende/1/sync catch-up protocol, bootstrap peers and mDNS - docs: key model, replication and conflict rules Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
23 lines
452 B
Go
23 lines
452 B
Go
// Package pow implements the hashcash-style proof-of-work used to make
|
|
// mass-publishing of listings and revocations expensive.
|
|
package pow
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"math/bits"
|
|
)
|
|
|
|
// LeadingZeroBits returns the number of leading zero bits of sha256(data).
|
|
func LeadingZeroBits(data []byte) int {
|
|
sum := sha256.Sum256(data)
|
|
n := 0
|
|
for _, b := range sum {
|
|
if b == 0 {
|
|
n += 8
|
|
continue
|
|
}
|
|
return n + bits.LeadingZeros8(b)
|
|
}
|
|
return n
|
|
}
|