BTC
ETH
HTX
SOL
BNB
View Market
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

Blockchain wallet multi-platform signature scheme

Nervos
特邀专栏作者
This article is about 5250 words, reading the full article takes about 8 minutes
How to balance security and ease of use, as well as a consistent experience across platforms, is a problem that needs to be solved by the multi-platform signature scheme.
AI Summary
Expand
How to balance security and ease of use, as well as a consistent experience across platforms, is a problem that needs to be solved by the multi-platform signature scheme.

This technical article originates from the Dev Meetup held by Nervos every Wednesday. The author is Duan Yangyang, technical director of Nervos AppChain of Secret Ape Technology.

---

Many people may have played blockchain DApps, such as CryptoKitties. When you see a particularly cute cat and want to buy it, you will usually see a prompt to download and install MetaMask. MetaMask is a plug-in wallet based on a PC browser. To successfully download and install it, you need to know a little scientific Internet knowledge. After the installation is successful, you can complete the payment transaction by invoking the MetaMask plug-in wallet.


However, if you want to play CryptoKitties on your mobile phone, you will find that you cannot continue the game because you do not have a MetaMask wallet. Maybe you still have imToken and other mobile wallets in your mobile phone. Unfortunately, if you open the CryptoKitties game through a mobile browser, you still cannot automatically wake up imToken and other wallets for signature payment.

Multi-platform signature issues and pain points

So you will find that there are many ways to carry DApps, including applications based on PC browsers and native APP applications on mobile phones. Similarly, wallets also have many carrying methods, such as imToken mobile client wallets, PC-based client wallets such as the official Ethereum wallet, open source web wallets such as MyEtherWallet, and various cold wallets. Cold wallets are easy to understand. Suppose my mobile phone is a piece of hardware that is not connected to the Internet. If I need to sign for payment, I only need to take a USB cable and connect it to the computer to sign. The private key will not be exposed to the Internet during the whole process. environment.

That is to say, if you want to achieve the same DApp experience on PC browsers and mobile phones, and do not need to switch wallet accounts frequently, let alone transfer money back and forth, it is currently impossible. On the PC side, you can use the MetaMask wallet, and on the mobile phone side, you need to open it in the mobile wallet to experience the complete DApp. Think about the one-stop cross-platform experience of Alipay and WeChat Pay, do you have such an idea, is there no wallet that can solve the one-stop multi-platform signature pain points?

What's more unfortunate is that MetaMask mentioned on its official blog that users are not advised to put a large amount of funds in such plug-in wallets, as plug-in wallets are not safe. Maybe you will smile bitterly at this moment, I am just an ordinary novice user, I just want a wallet that can sign transactions on multiple platforms and is safe, can this small requirement not be met? Don't worry, let's analyze the current situation and possible solutions.

If there is a wallet that can solve the DApp signature problem on all platforms, then the experience can be guaranteed to be consistent, and the advantage of the mobile wallet is that the private key is always stored locally on the mobile phone, which is more secure than the browser wallet or plug-in wallet. Second, users do not need to install various wallets to handle transactions from different platforms.

Therefore, how to balance security and ease of use, as well as a consistent experience across platforms, is a problem that the multi-platform signature scheme needs to solve. This is the industry appeal we have seen so far, so we started research and tried to give our solution.

Scanning solution on mobile phone

Existing Internet applications may provide us with some ideas for reference. The left side of the picture below is the payment page of Alipay on the mobile phone. We are all familiar with Alipay. If you use Alipay to pay on the mobile phone, the application will automatically wake up Alipay, and then directly complete the payment process on Alipay. If you pay on the Taobao website on the computer side, a QR code will appear on the Taobao payment page. Just open Alipay on your mobile phone, scan the QR code, and complete the payment on your mobile phone, and then the payment result will be sent to Taobao. It's done, the experience is very good, and it's also very safe.


The right side of the picture is the service of Netease mailbox. Before logging in Netease mailbox on the PC browser, you need to enter the account number and password. Later, Netease felt that this is not very safe. Entering the account number and password is also cumbersome, and what should I do if the password is lost? ? Considering that everyone has a smartphone, and the mobile phone is relatively private and highly secure, they give a QR code when logging in on the browser, and scan the QR code with the email app on the mobile phone. Code, the mobile terminal completes the verification and authentication, and then the webmail on the PC browser will automatically log in successfully. The solution for existing Internet products is that since better security cannot be solved on the browser side, this shortcoming can be made up for by a more secure way of scanning codes on the mobile side.

Thinking along this line of thought, if you play CryptoKitties on a PC browser, and now you want to place an order to buy a cute cat, in the past, you had to surf the Internet scientifically, install MetaMask, create a wallet account, and then buy it from your Transfer some ETH to the MetaMask wallet with imToken or other wallets, and finally sign and pay to purchase. Is there a way to directly present the transaction data of CryptoKitties in the form of a QR code, scan the mobile wallet, complete the entire signature transaction process on the mobile phone, and then send the transaction data to the chain, and finally send the transaction The result is sent back to the browser web page, so the whole experience will be very good.

We have thought about this plan, but after thinking about it later, there is a problem! What's the problem?

If ordinary transfer transactions are fine, the transaction data is relatively small, but what if a contract is deployed? This is an ordinary contract. Its function is simply to store and read data. There are only so many data fields. If you replace it with a QR code, you will find such a dense QR code that most apps cannot scan it out at all. , Obviously, the way of directly scanning the code will not work.

Later, we tried another method in the company's internal Hackathon. Since the data is complex and large, and cannot be directly scanned and transmitted to the mobile phone with a QR code, can a server be used as a relay to forward the data? It is still the original DApp, which first transmits the complex transaction data to the relay server, and then returns a request interface to the DApp. Through this HTTP request interface, the client can access the complete transaction data. After the DApp gets the request interface address, Generate a QR code from the request address.

The wallet APP scans the QR code, obtains the request address, and obtains the transaction data from the request address. The wallet completes the signature with the local private key and forwards it to the chain, and finally sends the transaction hash returned by the blockchain to the relay server , since the DApp and the relay server are permanently connected, the DApp can obtain the transaction hash and process subsequent business processes according to the transaction hash.

It's a nice idea, at least it solves some problems, but it raises other problems.

The full name of DApp is a decentralized application. If a relay server is added, both the DApp itself and the wallet will rely heavily on the relay server. Once the service is abnormal or unavailable, the entire signing process will be blocked. Instead, a decentralized application must strongly rely on a centralized server, which contradicts the concept of decentralization of the blockchain.

Mobile wallet as server solution

In order to solve the problem that DApp and wallet rely heavily on the central server, then we thought about whether the mobile phone can become a server. If the mobile phone and the computer are in the same local area network, they can directly access each other through IP. Since the computer can be a server, the mobile phone can also be a server. The mobile phone is a server, and the DApp sends a transaction directly to the server. After the mobile phone gets the transaction data, it signs and forwards the data to the blockchain, and then sends the transaction hash returned by the chain to the DApp. This solves the contradiction between centralization and decentralization, but there is a problem that the computer and mobile phone must be in the same local area network, otherwise there is no way to request data.

It is an uncommon way to use a mobile phone as a server. Usually, this method is only used when transferring large files in a short distance or for small-scale point-to-point communication. This method is not suitable for expansion. Change the mobile phone to a LAN or 4G , its IP will change, then the DApp needs to frequently change the IP address of the connection. When you have no way to achieve good compatibility, this may be a good idea.

WalletConnect

Many teams in the industry are also trying to solve this problem, and WalletConnect is one of the more famous solutions. It also uses a relay service, and this relay service does more than the above mentioned. To put it simply, first, the DApp and the relay server will initially have a handshake and establish a long-term session connection channel, and then the DApp will generate a symmetric key for future encrypted transaction data, and the DApp will send the encrypted transaction data to Go to the relay server, and get the transaction data request address returned by the server.

Then the DApp packs the request address, symmetric key and session ID and generates a QR code, the mobile wallet scans the QR code and extracts the data request address and symmetric key, and then the wallet obtains the transaction data ciphertext from the interface address, And use the symmetric key to decrypt to get the plaintext of the transaction data. Then complete the transaction confirmation, signature and forwarding in the mobile wallet, and finally send the transaction hash obtained from the chain to the relay server. Since the DApp and the relay server are permanently connected, the relay server will push it to the DApp after getting the transaction hash, and then the DApp can query the execution status of the transaction on the blockchain according to the transaction hash.

WalletConnect is the same as the method discussed above, but it is one step closer. The transaction data is encrypted with a symmetric key, which has better security. The relay server is a place where transaction data is forwarded, and the QR code is the DApp. The information communication medium with the mobile wallet carries lighter data.

There may be another server in this solution, called Push service. If there is a Push service, then the DApp will send transaction data to the relay server later, without scanning the QR code, but directly push the data to the Push service, and then the Push service will push the message to the mobile wallet, mobile wallet Then sign and send to the chain, and inform the relay service of the transaction hash. Of course, if there is no Push server, the whole process can also go through, but the mobile wallet needs to scan the code to trigger the transaction data request, and then complete the subsequent process.

It should be noted that WalletConnect does not provide public Push services, but only public relay services. For DApp or wallet operators, it is necessary to maintain a centralized Push server. Although the experience and security are very good, the solution is somewhat trouble. WalletConnect proposed to the Ethereum Foundation that this set of data specifications should be made into an EIP protocol. Currently, the protocol is still under discussion and has not yet been finalized.

AppLink

There is another method, which is slightly simpler than the previous solution. Friends who have done mobile development may know DeepLink, or simply AppLink.

We all know that opening a website link address on a browser can jump to the desired webpage, but for smartphones, each App is an isolated island of information, and there is no simple communication mechanism between them. To give a simple example, Taobao and WeChat block each other, and things in WeChat cannot be found on Baidu. The information between Apps is a split state. Therefore, Google and Apple, as operating system providers, hope to solve this problem from the operating system level, so there is AppLink.

As long as any App is registered on the AppLink service according to certain protocol specifications, other Apps can connect and communicate with it through the AppLink service. For example, if I want to buy a cat on a PC browser, a transaction QR code will be displayed on the purchase page. I scan the QR code with the iPhone system camera, as long as the content of the QR code is in my operating system AppLink If you have registered in the mobile wallet, you can invoke the mobile wallet page to complete the subsequent signature payment process.

However, this service has not been widely used for many reasons. The most important reason is that apps are unwilling to share data. They prefer users to stay inside the app to increase user stickiness. Moreover, the fragmentation of Android is relatively serious. Many domestic mobile phone manufacturers have changed the underlying code of the operating system, so there is no way to provide a good consistent experience. Therefore, this solution is achievable in some relatively small scenarios and is not suitable for all scenarios. This data protocol has also been submitted to the Ethereum Foundation, hoping to establish an ERC standard. It is currently in the draft process and no consensus has been reached.

MyEtherWallet

The last case is very interesting. There is a web wallet called MyEtherWallet, which proposes a scheme to complete signature transactions by establishing a P2P secure channel. In the past, when creating a wallet on MyEtherWallet, the private key, mnemonic and other information are all generated by the wallet and stored in the browser storage space. However, it is actually not safe to store the private key on the web page. Although the web page itself has a certain storage function, its security is still much weaker than that of mobile phones. So how to solve this security problem?

MyEtherWallet has recently launched a mobile APP called NEWconnect, and it started public testing some time ago. They developed a mobile wallet called NEWconnect. Although it has many functions of a wallet, it does not act as an independent wallet, but is used in conjunction with the web wallet. For example, if a user wants to transfer an account of 1.5eth on the web page, the user generates a transaction on the web page, and the mobile phone directly connects to the web page point-to-point through P2P, and the confirmation transaction page will pop up automatically. After completing the signed transaction on the mobile phone, the result will be passed The P2P communication channel is sent back to the web page, and the web page updates and displays the data after transaction processing.

The experience of this program is very good, and it is very safe. Because it is a private P2P communication channel, transaction data will not be easily stolen, which can perfectly solve the above-mentioned problems. However, this solution also has the problem of difficult expansion, and can only transfer data in a closed system. P2P itself is peer-to-peer communication. If it is expanded, it needs a whole set of channel establishment process and encryption mechanism, but this idea is really worth learning.

still on the way

The entire industry has not yet had a final solution. We are also doing various researches and attempts. Even though we have made a preliminary solution in the Hackathon, it is still not perfect. Many people have discovered the demands and pain points of the industry and are actively trying to solve them. However, the entire industry has not yet reached a consensus solution.

At present, there is still a gap between many blockchain services and Internet services in terms of experience. Internet services are centralized, and there are many centralized ways to solve the problems of experience and security. Blockchain applications are decentralized, and wallets and DApps are also decentralized. If we use relay services to do it, it is equivalent to solving the problem of decentralization in a centralized way. Let us first Do not discuss good and bad, at least it will not be the optimal solution.

Security is also an important consideration. The transaction data presented by the QR code is easy to be tampered with, and the transaction request provided by the relay service is also easy to be intercepted. If it is an Internet application, the data can be verified in a centralized way, but For decentralized applications, how to achieve a balance between security and decentralization needs further discussion.

We can find a large number of wallet software on Google Play and App Store, and the experience varies greatly from each other, but it has never been able to solve the multi-platform signature payment problem like Alipay. For this reason, we are still researching and doing MVP verification, hoping to have a solution that takes into account security, experience, and decentralization in the future.

Welcome to Join Odaily Official Community