// Package verify is the signature verification worker domain. It owns no // state: it receives a public key, message hash and signature, and answers // with a boolean. Several of these domains form the relay's verification pool. package verify import ( "git.smesh.lol/torly/pkg/crypto/secp256k1" tinyspawn "git.smesh.lol/torly/pkg/tinyspawn" "git.smesh.lol/torly/pkg/wire" ) // Chans are the channels bound at spawn. type Chans struct { Req tinyspawn.Duplex[wire.VerifyRequest] Resp tinyspawn.Duplex[wire.VerifyResponse] Ready chan<- wire.Ready Stop tinyspawn.Breaker } // Run is the domain entry point. func Run(_ struct{}, ch Chans) { ch.Ready <- wire.Ready{OK: true} for { select { case req := <-ch.Req.Recv(): ok := secp256k1.Verify(req.Pub, req.Msg, req.Sig) select { case ch.Resp.Tx <- wire.VerifyResponse{ID: req.ID, OK: ok}: case <-ch.Stop.Done(): return } case <-ch.Stop.Done(): return } } }