Crypto-Spatial Coordinates — the open location standard on Ethereum

Kristoffer Josefsson
FOAM
Published in
6 min readNov 27, 2017

--

At FOAM, our mission is to build a consensus-driven map of the world that can be trusted for all applications.

To do this, we are developing a protocol for proof-of-location, an API for geospatial interactions on the blockchain, and the Spatial Index (a visual explorer). Last week we released the purescript-web3 library for Ethereum, on which the Spatial Index is built. In the coming weeks, we will be releasing more information about FOAM: our vision, our white-paper and our first beta version of the Spatial Index.

In this post, we introduce a new fundamental part of our work: the Crypto-Spatial Coordinate (CSC), which is an open and interoperable standard for location in Ethereum smart contracts.

Blockchains are eventually going to change the world we interact in — from the internet of things, supply chains, real estate and land registries to augmented reality and location-based gaming. Currently, there are no standards for embedded locations, physical addresses, or coordinates in smart contracts. In order for smart contracts to remain interoperable, they will need a shared language for them to reference and index the physical world.

The FOAM CSC is a starting point for this shared location standard, allowing any smart contract to make an immutable claim to an address on the blockchain and a corresponding location on the map.

Location standards today

Throughout history, there have been many ways of encoding physical location into addresses — from longitude and latitude all the way to the more recent geohash. While autonomous car companies are racing for more accurate location data, the fact remains that most of the Earth’s surface lacks addresses. According to the United Nations, 70% of the world is unaddressed, including more than half of the worldʼs sprawling urban developments.

Alternative addressing systems have attempted to increase human memorability, verifiability and machine readability. Notable examples are What3words and Open Location Code. As these systems are either proprietary and/or lacking economic incentives (edit: OLC is Apache 2.0 licensed), attempts to create a standard around them have been crippled. See ‘An Evaluation of Location Encoding Systemsʼ for an overview of different location standards.

Comparison of Location Standards, including CSC

What3Words uses unique three-word addresses to divide the world into a grid of 3x3m2 squares. In this system, an address such as Banana.Radio.Scent could describe an area within a field. Though What3Words hopes to become a global standard, we find it problematic as it is a centralized addressing system that charges a license fee.

We need a location standard for blockchain applications that is free, open source and interoperable so that we can securely connect offline spaces to online assets.

The FOAM protocol will enable different agents, parties and smart contracts to negotiate with each other on top of shared location data. Smart contract protocols need to be modular so that diverse network participants can be connected, from users to developers and service providers. Being a protocol allows FOAM to be detached from any singular application or use case, creating open building blocks that anyone can access and use in their applications.

Crypto-Spatial Coordinate (CSC)

Crypto-Spatial Coordinates (CSC) are Ethereum smart contract addresses with corresponding addresses positioned in physical space that are verifiable both on- and off-chain. This allows for physical addresses in the built environment to have an corresponding smart contract address that is accessible for decentralized applications. We are using the geohash standard as a basis for this construction because of its conceptual and mathematical simplicity. Another benefit of the geohash standard is that it is in the public domain. This doesn’t mean that the geohash doesn’t have limitations. Therefore, we will allow for changing this in future versions if we find it to be too limiting. Despite using the word hash, the geohash is not a hash in the cryptographic sense. Instead, it is a self-similar, space-filling coordinate system.

The CSC standard can be adopted by any smart contract to make a claim to, or reference, a location in the physical environment. When adopted across verticals and use cases, the CSC allows smart contract transaction activities to take on a spatial dimension. The CSC acts as an index for spatial events that works for any kind of transaction on the blockchain. Since geohashes are intrinsically hierarchical, it also means that a contract referencing a building, and a contract referencing an IoT device located within that building, automatically have a spatial relationship.

New Lab, the location of our office in New York with corresponding CSC

Properties of the CSC

We encode a CSC as a hash with inputs consisting of

  • a geohash
  • a corresponding Ethereum address

A key property of the CSC is that it is verifiable both on- and off-chain. This means that

  • the relationship between a CSC and its constituent geohash and ethereum address is completely deterministic.
  • a smart contract can take a CSC and decode the location and the ethereum address associated by the CSC. Currently this is done by a registry contract.
  • two smart contracts should be able to compute their location and spatial relationship on-chain.

The approximate resolution of a CSC is 1 m2. This resolution is rather arbitrary but allows for a maximum of approximately 500 trillion locations.

The CSC proposal

  1. For geographical input, we use a geohash of up to length 10 characters in base32. The alphabet used is the standard geohash alphabet as defined here. This amounts to approximately 50 bits.
  2. For the ethereum address, we simply use the 20 bytes, or 160 bits, associated with the address of a contract.

The CSC is a 96 bit identifier, defined as the first 12 bytes of the Keccak-256 hash of the concatenation of the geohash with the ethereum address. In Solidity, this looks like this:

function computeCSC(bytes12 geohash, address addr) returns(bytes12){
return bytes12(sha3(geohash, addr));
}

The output of this is then base58 encoded using the bitcoin alphabet to avoid visually similar characters in the encoding.

For ease of communication between humans, we display the first 8 characters in this representation. Using approximately 48 bits for visual identification of the CSC still gives us roughly the same order of magnitude correspondence between CSCs and the 500 trillion possible geohashes that we currently aim to represent.

In conclusion, the CSC is effectively a human readable representation of a pair of a geohash and an Ethereum address, together with an immutable pairing of the two on the blockchain. It is possible to verify the CSC of a contract and its associated geohash. We lose the ability to derive the location and Ethereum address from this format, but it still allows the CSC to be mapped back to the original geohash and address on-chain using the registry.

A local energy market, CSCs mark suburban houses trading surplus energy.

This first version of the CSC protocol is currently in use in FOAM smart contracts and within our Spatial Index. Throughout the next months we will release tools and contracts that demonstrate the usage of CSCs in Solidity and in applications. This protocol is still under development and we welcome community feedback as we move towards a formal specification document for the ecosystem to begin testing the standard.

We will be releasing more information soon, including our roadmap, timeline and some exciting partnerships. For now, check out our website and join our Slack. Updates will be posted on reddit, Twitter and Telegram. Leading up to the release of our white paper, we will be sharing posts going into more detail on the FOAM protocol, our API, use cases for different verticals, and the Spatial Index.

We welcome feedback from the community and are open to collaborations, so please get in touch.

Edited to clarify that OLC is Apache 2.0 licensed

--

--