func verify(ps peer.Peerstore, r *dhtpb.Record) error { v := make(record.Validator) v["pk"] = record.PublicKeyValidator p := peer.ID(r.GetAuthor()) pk := ps.PubKey(p) if pk == nil { return fmt.Errorf("do not have public key for %s", p) } if err := record.CheckRecordSig(r, pk); err != nil { return err } if err := v.VerifyRecord(r); err != nil { return err } return nil }
// RecordBlobForSig returns the blob protected by the record signature func RecordBlobForSig(r *pb.Record) []byte { k := []byte(r.GetKey()) v := []byte(r.GetValue()) a := []byte(r.GetAuthor()) return bytes.Join([][]byte{k, v, a}, []byte{}) }