Files
lucioandClaude Opus 5.5 f5152fb709 Anti-scraping: 3x3 grids, decoy pools, robot check
Every pyramid level is cut into at least min_grid x min_grid tiles.
Each photo's tile pool mixes real tiles with hard-linked decoys from
other photos; the grid-to-pool map, byte sizes, seed and scramble seed
are sealed per build and unlocked by a press-and-hold check backed by
a static proof of work. Cell scrambling is on by default, and
robots.txt disallows tiles and pool files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 21:39:30 -08:00

52 lines
1.1 KiB
Go

package process
import (
"crypto/hmac"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"hash"
"strconv"
)
type Keyed struct {
mac hash.Hash
buf []byte
sum []byte
}
func (p *Processor) Keyed() *Keyed {
return &Keyed{mac: hmac.New(sha256.New, p.key), buf: make([]byte, 0, 96), sum: make([]byte, 0, sha256.Size)}
}
func (k *Keyed) digest(label, hash string, level, slot int, source string) []byte {
b := append(k.buf[:0], label...)
b = append(b, '|')
b = append(b, hash...)
b = append(b, '|')
b = strconv.AppendInt(b, int64(level), 10)
if slot >= 0 {
b = append(b, '|')
b = strconv.AppendInt(b, int64(slot), 10)
b = append(b, '|')
b = append(b, source...)
}
k.buf = b
k.mac.Reset()
k.mac.Write(b)
k.sum = k.mac.Sum(k.sum[:0])
return k.sum
}
func (k *Keyed) DecoyName(hash string, level, slot int, source string) string {
return hex.EncodeToString(k.digest("decoy", hash, level, slot, source)[:8])
}
func (k *Keyed) Seed(label, hash string, level int) uint64 {
return binary.BigEndian.Uint64(k.digest(label, hash, level, -1, ""))
}
func (p *Processor) Ext() string {
return "." + p.images.Format
}