2key Smart Links as Multi-Party State Networks

By: Dr. Yoram Kornatzky, eiTan LaVi

Initial Implementation — Multi-Step Referrals

2key Network is a blockchain-based referral network intended to reward referrers through smart contracts. Referrals progress through the network thanks to people forwarding links to one-another. The 2key Protocol,powering the network, generates off-chain, cryptographically signed links, which propagate among users without reaching the blockchain. Upon conversion, or upon finalisation of the contract at large, a user can submit any or all of the signed-links to the main-chain 2key smart contract, which then rewards the chain of referrers as represented in the signed link(s). The 2key smart contract is deployed per referral campaign by the campaign initiator (the “Contractor”), depositing 2KEY tokens to ensure a vested stake in upholding the contract.

a Multi Party?

State Channels

A state channel (also called a payment channel) is an off-chain mechanism where the two sides of the channel, henceforth called the sender and receiver, deploy a smart contract to which one side, the sender, deposits an amount of cryptocurrency. Upon pre-agreed off-chain events, the sender transmits to the receiver cryptographically signed messages, with each message overriding the previous one. Each message commits the sender to pay an amount of cryptocurrency to the receiver. This commitment can be turned into an actual payment by the receiver submitting a transaction to the smart contract.

State channels can be generalised to multi-party state channels, involving more than two parties, where again there is an initial deposit of cryptocurrency into the state channel that serves as a guarantee for enforcing of future commitments.

It should be noted that existing state channel solutions require apriori knowledge of the parties participating in the channel.

Constructions like the Raiden Network may use intermediaries that are unknown beforehand to construct a two-party state channel, but the two parties actually involved in the state channel will need to be known in advance to initiating the channel.

2key Campaign as a Multi-Party State Channel

In essence, with the 2key signed link, the campaign smart contract constructs a multi-party state channel spawning from the initiator of the campaign to the referrers. This DAG (Directed Acyclic Graph) structure is built dynamically as referrals progresses through the campaign. The referrers are guaranteed their reward pending conversions generated downstream from them in the referral graph.

In stark advantage to other state channel solutions, with the 2key Protocol there is no requirement for initial knowledge of the parties involved. In fact, the originator has no prior knowledge regarding who the eventual referrers or converters will be. This echoes with the fact that the 2key Protocol is embedded to HTTP, in a way which is etheric to web2.0, and allows these multi-party state channels to distribute web-wide, across borders of countries, applications and platforms.

2key’s unique novelty is in building the state channel through the cryptographically signed links — the 2key “Smart Links.” Thus, there is no need for exchange of commitments, as the signed link serves as a commitment. Moreover, this commitment involves multiple parties.

Counterfactual

Counterfactual is a protocol for off-chain blockchain, consisting of a library for off-chain applications, an intuitive generalised state channels protocol, and a set of Ethereum smart contracts. Counterfactual generalises state channels by exchanging cryptographically signed transactions between the parties to the channel. These transactions can include deployment of contracts and calls to functions of smart contracts.

Counterfactual means something that could be true but is not. This is an extremely helpful concept when discussing state channels, where we spend a lot of time reasoning about things that could be happening on chain but are not. In state channels, we say counterfactual X to describe a case where: X could happen on the chain but doesn’t. Any participant can unilaterally make X happen on-chain. Participants can, therefore, act as though X has happened on-chain”

Counterfactual is based on a set of smart contracts that are installed on the blockchain, with each Dapp developer wishing to construct a state channel using its library, and installing a multisig wallet with a deposit to start the state channel.

Clearly, by exchanging messages that represent the deployment of smart contracts and call to methods of smart contracts, Counterfactual enables more powerful state channels in the sense of carrying more complex interactions off-chain.

However, in contrast to 2key, Counterfactual requires the parties to a state channel be known in advance to setting up the state channel, and to further have a central entity construct and manage a multisig wallet with a cryptocurrency deposit in order to initiate a state channel. Hence, not only do the parties in the state channel have to be known in advance, but the Counterfactual solution is primarily suited to be used within siloed, centralised contexts of specific apps, and not as a decentralised, dynamic, web-wide solution.

2key Signed Link as a Generalised State Channel Protocol

A 2key Smart Link carries a commitment for a payment for a path of referrals. So a 2key signed link is an off-chain state channel involving multiple parties. With counterfactual thinking, a signed link represents something that will occur on the blockchain if submitted. But this referral reward to all referrer parties will occur only upon conversion, so this initial implementation can be thought of as a dynamic, conditionally finalised state channel solution.

So far we described our initial construction of the 2key signed link as a sequence of referrals that is cryptographically signed. This was the initial concept for the 2key network that we implemented on top of the 2key protocol.

We are now working to expand the 2key protocol to enable a general multi-party state channel solution:

First, we generalised the signed link from containing the path of referrers as a sequence of addresses of referrer to contain small pieces of state. For example, for a voting contract, the piece of state will be the vote, or, for a token acquisition campaign, the small piece of state will be referrer’s requested cut from the reward.

Realising the limitation of storing all information in a link, we moved the expanded smart link to be stored on decentralised storage, currently using IPFS . Hence, the 2key smart link now contains just a single hash representing the entire state at the moment of interaction, and the interaction / transaction/ state change request itself.

Later we will release an implementation where browsers themselves can act as bulletin boards for storing and serving these smart contracts for other participants in the channel to dynamically sync with the evolving state, what we call 2key nodes.

Now, examining the Counterfactual mechanism of employing the state channel, it is evident that it depends on the Dapp using their library. In contrast, 2key wanted its signed link to be constructed by a regular browser using JavaScript.

There are two approaches to having the browser of a referrer participate in constructing a signed link. The centralized approach requires the user to go to a 2key website, where the referrer will get a referral link. We’re now transforming to the decentralized approach, where the code used to generate the user interface as well as the cryptography needed to both validate and construct the 2key Smart Links resides in decentralized storage as well.

This means that the 2key smart link will ultimately be just a small piece of javascript directing the browser to load a big javascript code (the UI and the cryptography) with a specific hash from IPFS, as well as the state hash.

So, the 2key link has this symbolic structure:

js://{node-code-hash}&{state-hash}

Where node-code-hash is the hash to the JavaScript code to construct the link, and the state-hash is a hash to the combined state and referral address, which are cryptographically signed.

The Dapp using the 2key link is itself served from decentralized storage. Thereby, the 2key multi-party state channel operates in a completely decentralized way through standard browsers.

Conclusions

We believe 2key possesses many of the attributes of Counterfactual, such as multi-party state channels. Moreover, 2key is superior in terms of decentralization as it does not require prior knowledge of the participants in the state channel, and it operates through standard browsers over HTTP, fully open to the world-wide-web.