# ogori-geolib
On-chain point-in-polygon verification and versioned audit rule-sets for agri-food traceability.
Research artefact accompanying two manuscripts on field-evidence verification in the OGORI
traceability platform (Ogori Chain, PoA, `chainId 83333`). Everything here is reproducible: the
contracts compile from source, the benchmark script regenerates every number quoted in the papers,
and the field data it validates against is publicly readable on the OGORI block explorer.
## What is in here
| Path | Contents |
|---|---|
| `contracts/GeoLib.sol` | Fixed-point spherical geometry: haversine distance, Jordan ray-casting containment, point-to-segment distance |
| `contracts/LandRegistry.sol` | Write-once plot boundaries with per-plot distance thresholds, and in-transaction verification of a capture |
| `contracts/LensRegistry.sol` | Append-only anchor for versioned audit rule-set digests |
| `test/benchmark.js` | Gas benchmark across polygon sizes, plus cross-validation against production field events |
| `test/latency_client.mjs` | Client-side re-assessment timing (JavaScript reimplementation of the same algorithm) |
| `data/` | Plot polygons, 44 production field events, and the generated benchmark output |
The contracts are deliberately **not upgradeable**. A registered polygon cannot be mutated and the
verification logic that graded a historical event cannot be replaced after the fact, which is the
point: an evidence ledger whose grading rules can be swapped by its operator proves less than one
whose rules cannot.
## Reproducing the results
```bash
npm install
npx hardhat compile
npx hardhat run test/benchmark.js # gas + cross-validation, writes data/benchmark_results.json
node test/latency_client.mjs # client-side re-assessment timing
```
### Gas, measured
solc 0.8.19, optimizer enabled (200 runs), EVM target `paris`, Hardhat 2.22.15.
| Polygon vertices | `registerPlot` | `verifyEvidence` (inside) | `verifyEvidence` (outside) |
|---: …