Add device keys, revocation and libp2p gossip with sync
- 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>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user