<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Covenant Labs on Medium]]></title>
        <description><![CDATA[Stories by Covenant Labs on Medium]]></description>
        <link>https://medium.com/@covenant_labs?source=rss-b4be9f949f2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mTnVKCo3ex80J_FXwXHWJg.png</url>
            <title>Stories by Covenant Labs on Medium</title>
            <link>https://medium.com/@covenant_labs?source=rss-b4be9f949f2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 00:06:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@covenant_labs/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Internet Data Privacy Tug-of-War]]></title>
            <link>https://medium.com/@covenant_labs/internet-data-privacy-tug-of-war-87e573eaa66d?source=rss-b4be9f949f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/87e573eaa66d</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Covenant Labs]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 10:30:29 GMT</pubDate>
            <atom:updated>2019-03-18T12:05:31.953Z</atom:updated>
            <content:encoded><![CDATA[<p>Author: Auxten Wang</p><h3><strong>Growing Data Breach</strong></h3><p>Due to the growing data breach, data privacy issues are getting more attention from people and government. Europe published GDPR in 2018, while other countries such as India and Brazil are also publishing data protection acts. In China, the nation people’s congress has listed the personal data protection act in the 2019 legislative work plan. In the rising awareness of protecting personal data, the questions remain as of how do we protect our data as individuals, and how do companies protect users’ data when developing applications?</p><h3><strong>Data Leaking Caused by System Security Issues</strong></h3><p>In the second decade of the 21st century, data storage and processing technology have been developed faster than ever, along with a lot of problems of privacy issues increasing dramatically in the meantime. The following table listed the top 10 data breaches reported by media before 2018 August (Trendmicro 2018).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cr8ye1YkYFnIb08tC2R__Q.png" /><figcaption>TrendMicro: Data Breaches 101</figcaption></figure><p>Even the top tech companies which have set a lot of standards for API and done penetration testing, can not guarantee “data leaking” will never happen. Usually, these companies are in control of tremendous user data and sensitive information, and due to this reason, these companies have a large impact on customers or even our society if data breaches occur.</p><p>But, why???</p><p>To understand why the consequences are severe, first of all, we need to know how the hacker hack.</p><h3><strong>How Hackers Hack</strong></h3><p>In general, there are four steps that hackers will do (Trendmicro 2018).</p><p><strong>Research</strong>: Hackers search for network or system flaws in the target company’s security system. Since this involves a large amount of work, most companies cannot implement full protection and most of them improve their security by employee education and period checkup.</p><p><strong>Attack</strong>: Attacks are categorized in two ways:</p><p>1. Most widely known — attack on the infrastructure. The traditional firewall protects the servers from this type of hacking.</p><p>2. Uncommon — a different way of attacking by using social engineering ways such as Phishing, pirated copy Trojan, WiFi phisher, and social media fraud. If the information is really valuable, the hacker may utilize the 0Day vulnerability.</p><p>Examples are:</p><ul><li>Stuxnet worm entered Iran’s nuclear facilities in 2014</li><li>APT-C-01 against China National Security lasting for 11 years</li><li>APT-C-12 against China’s nuclear facilities and research institution lasting for 8 years</li></ul><p><strong>Drag</strong>: As long as the hacker enters the company’s office network, or even the server, due to the historical reasons of the database (I will explain this later), the address and password of the database are usually written in the code. Even if the hacker doesn’t find the password, he could just copy the data file and then transmit the valuable data back. Since DBMS (Database Management System, relational database) is simpler to develop and more flexible, it’s used to store data in most user privacy sensitive scenarios. Therefore, no matter the most widely known way of attack or the uncommon way of attack, DBMS is commonly used for storing data.</p><p><strong>Hide</strong>: The majority of data breaches are not reported to the public, or they are usually reported after a long while when the data have been sold and cannot be traced. For those valuable data, hackers often hide in the dark and wait to steal the data. Since most IDS (Intrusion Detection System) use simple file storage or database, it’s easy for hackers to hide their trails.</p><p><strong>Data Breaches due to Improper Management</strong></p><p>The most famous data breach so far is the Facebook-Cambridge Analytica data scandal in early 2018. Cambridge Analytica collected up to 87 million users’ data without users’ consent and used for political purposes. In the meantime, Facebook was reported aware of Cambridge Analytica’s action. The data was used by Donald Trump in the 2016 US election campaign and influenced the election result. Impacted by the scandal, Facebook’s share price dropped by 7% in one day and lost 36 billion dollars of market value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*ru_IkFmiSrfipxrWFuO-Hg.png" /></figure><h3><strong>What shall the service providers do?</strong></h3><p>There is one important principle: In the system architecture, the place that needs the highest security protection is the bottleneck of the system.</p><p><strong>The First Moat of Defense</strong></p><p>Most security protections are done in the API Gateway, and this follows the way we discussed above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXO8j7OtcQX5aCDoY3zKrg.png" /><figcaption>Typical App Arch</figcaption></figure><p>The current application development includes multi ends such as Web App, Android, iOS, Applet. To improve the development and management efficiency, usually the backend provides a standard API for all type of client ends. Since developers use different technologies stack, the API are usually very different and lead to the most frequent data breaches due to insecure API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7p_lY80rKIveac511zvrw.png" /><figcaption>API Disaster</figcaption></figure><p>limited results of common defense mechanism in API Gateway is also caused by the complex protocol layers and coding layers.</p><p><strong>The Second Moat of Defense</strong></p><p>If we reconsider the architecture of the backend development, we find that another bottleneck of the system is the database.</p><p>Most usable DBMS are developed in the last century. They lack fine-grained access control at the field level due to historical limitations. Since a database is hard to design and develop, developers often use patches to fix security vulnerabilities/bugs or improve usability or performance through DB proxy.</p><p>For example:</p><ul><li>ProxySQL: developed by well-known MySQL database service provider Percona</li><li>Vitess: developed by Youtube since 2011.</li></ul><p>However, even those top tech companies such as Percona or Google cannot make DB proxy become the mainstream solution. The reasons are listed below.</p><ul><li>The DB Proxy solution has a negative impact on system performance and stability because the execution steps are overlapped with the database.</li><li>The original intention of DB Proxy is mainly to solve the problem of database horizontal scalability. It solves some problems, but also introduce some other problems.</li></ul><p><strong>The Moat before First Moat</strong></p><p>In the Facebook-Cambridge Analytica scandal, Zuckerburg admitted that Facebook recognized Cambridge Analytica’s action of collecting user’s profiles before the news broke out, and this issue didn’t draw attention from Facebook’s management team. In the European Parliament hearing, Zuckerburg admitted that they “haven’t done enough to prevent these tools from being used for harm. And that goes for fake news, foreign interference in elections or developers misusing people’s information. We didn’t take a broad enough view of our responsibility. That was a mistake, and I’m sorry for it.” (Zuckerberg 2018)</p><p>Fairly speaking, Facebook is still leading in protecting user privacy in the world, no matter from a technical perspective or from a social awareness perspective. This didn’t prevent the scandal to happen and promote data protection from a matter in the internet industry to a hot topic in society globally.</p><h3><strong>Everyone’s Data Right</strong></h3><h4><strong>Overbearing Terms and Conditions of Use</strong></h4><p>Data rights must be protected starting from terms and conditions. For a long time, the ignorance of data rights in our society has caused a lot of vague or even overbearing terms and conditions of use on the internet. In the beginning of 2019, Google received a fine of 50 million Euro as Google failed to comply with GDPR. Google didn’t provide clear consent to the users when asking for essential information and the consent flow doesn’t comply with GDPR. Therefore, users are unclear how and where their data will be used.</p><p><strong>Data Rights</strong></p><p>Recognized as the new petroleum in this era, data is attractive to hackers. However, what is more, serious than hackers’ attack, is that rarely people realized the value of their data in the internet’s early stage. Internet companies intend to seduce users to agree with the terms and conditions so that they could use the data for profits. Now the internet giants are controlling most of the data, and they keep silent for their own goods.</p><p>The situation is different in Europe. Due to cultural and historical reasons, there is no internet giant which has huge impacts emerged in Europe. This makes Europe in a neutral position when dealing with user privacy issues, and this is why the toughest online privacy regulation was born in Europe.</p><p><strong>GDPR’s Requirements and Limitations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*iAmo-8Z8lWklFjJmwbxSXg.png" /></figure><p>To be simple, internet companies shall comply with GDPR in three ways.</p><p>1. Users have the right to know their data being used for certain purposes.</p><p>2. Users have the right to request stop processing and delete all their data</p><p>3. If internet companies do not comply with GDPR, they will be fined as much as the higher of 20 million euro or 4% of revenue in last year.</p><p>In general, GDPR is more like a guide rather than a regulation that specifies the detailed actions for companies. For example, how transparent shall the company inform the users of their data being used for certain purposes? The data is stored in an internet service provider’s database, how does the service provider proof that users’ data has been used properly? And how complicated is the process to delete user’s data? Facebook announced its new feature “Clear History”. However, this feature has not be implemented since the Cambridge Analytica scandal for months. Why this is so hard? Besides the technical challenges, one fact is that Facebook makes profits from advertisements. Stopping collecting users’ data or enabling deleting data would make Facebook lose a big revenue stream.</p><p><strong>Hong Kong’s Privacy Ordinance</strong></p><p>Reviewing different regulations, we think Hong Kong’s Privacy Ordinance set a good example for data protection. The core principle of Privacy Ordinance is that the purpose of data collection shall be consistent with data usage, and data shall be deleted after use. This is similar to GDPR but is more operational. As an international city, Hong Kong residents are also concerned with privacy. Back in 2013, Hong Kong developers published an application called “Do No Evil” which provides companies’ public information including government registration or lawsuits to users. However, this application was banned due to a privacy issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMRVwNicUcKtrPoqnPL8wA.png" /></figure><p>When Open Data come to our attention, data rights and privacy protection also remain an unresolved topic. As a tech team, we truly believe everyone’s data right will be guaranteed and protected with the development of technology one day.</p><h3><strong>Empowerment of Technology</strong></h3><h4><strong>Artificial Intelligence</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBiZi2ykzouXGYdlEaK_cQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BF5rRTIdpK7WdGIWGYUIRg.png" /></figure><p><em>F (gender, location, mobile model, searching keywords, product category, brand, price) = possibility of purchasing</em></p><p>Then rank the possibility of purchasing in all products. Put the product with the highest mark in the top of the list, and you will see what is recommended by the system. Artificial intelligence is actually predicting, or to be more precise, controlling what’s coming up to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fRf0w_K6VvMtofu7LPnMQQ.png" /><figcaption>AI Recommendation</figcaption></figure><p>Based on the same principle, Cambridge Analytica is able to analyze everyone’s preference based on the label they assigned to each one after collecting and analyzing the personal data. Like what Cambridge Analytica has done in Donald Trump’s campaign. People received the advertisement or news that are tailor-made according to their preference in the campaign, and these ads or news would impact people’s conscious and finally impact the election results.</p><h4><strong>Blockchain</strong></h4><p>The use of blockchain brings a turn to data right.</p><p><strong>Data Right Back to User</strong></p><p>In the future, all of our personal data can be stored in a decentralized database, such as bitcoin. We control our data with a private key. To make the data usable, a guideline for use of data shall be specified and set. The core of the guideline is to limited companies’ use of personal data in the designated way and delete after use. For example, if we trust Facebook, we grant Facebook access to read our name, age, and list of friends. Meanwhile, each time Facebook use our data will be recorded. If we find Facebook has done something out of scope, we could revoke the access. In this case, we fully control our personal data, and our privacy is protected.</p><p><strong>Circulation of Data</strong></p><p>Data is called new petroleum. What is different between data and petroleum is that data only possess huge value when it’s circulating or exchanging. Currently, the majority of data is possessed by government, companies, and individuals, and not shared, used, circulated for greater benefits. There is still a long way to go to maximize the value of data. The biggest headache for big data companies and research institutions is a lack of data. To create a win-win situation, individuals could sell their data by granting institutions access for research purposes. This would empower the data circulation and end the dispossession of data from their owners.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87e573eaa66d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CovenantSQL & Data Security | CSTC conference sharing]]></title>
            <link>https://medium.com/@covenant_labs/covenantsql-data-security-cstc-conference-sharing-ed14be362b79?source=rss-b4be9f949f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed14be362b79</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Covenant Labs]]></dc:creator>
            <pubDate>Mon, 11 Feb 2019 09:54:12 GMT</pubDate>
            <atom:updated>2019-02-11T09:54:12.671Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, CovenantSQL co-founder &amp; CTO Auxten Wang attended the 2018 China Software Technology Conference and delivered a speech titled “CovenantSQL, The Highly Available Database on the Internet”.</p><h3>Presenter’s Profile</h3><p>Auxten: CovenantSQL co-founder &amp; CTO; Former Baidu Noah data transmission project leader, 360 operation and maintenance automation project leader; former 360 traffic guard, 360 Tianji project initiator.</p><p>Auxten has worked at elong and the Fourth Paradigm as technical director. He holds over 10-year experiences in infrastructure and system security related field.</p><p>The following is a summary of some of the speeches:</p><h3>HA (High Available) levels</h3><p>First of all, there are four levels I defined according to my personal understanding of HA (high availability) database:</p><p>The first level is <strong>Time Irrelevant</strong>, which is a basic requirement that requires stand-alone stability and does not crash during operation. Taking <a href="https://baike.baidu.com/item/memcached">Mamcached</a> and <a href="https://baike.baidu.com/item/nginx/3817705?fr=aladdin">Nginx</a> as examples, according to our experience, almost no one has ever encountered their bugs.</p><p>The next level is <strong>Hardware Irrelevant</strong>, which means that database is not affected by hardware, which is what we often say in a distributed situation. A single machine failure will not cause the whole server to fall. If you compare the cost of letting them crash, the previous level can be done at almost no cost, just $0. But if you want the hardware to crash, you have to make the server down first. We estimate it will cost about $10,000.</p><p>Next one is the high availability of <strong>IDC Irrelevant.</strong> This is even more difficult. In mainland China, only a few large companies are able to do it and withstand HA breakdown at the IDC level.</p><p>There are two examples. One is the well-known BitTorrent, which has been banned many times but still alive and tort copyright in most cases. The other is Spanner, which is a globally distributed database developed by Google. It is very powerful to achieve global high-performance consistency. Google Drive is based on Spanner. But in my opinion, these are still not the highest level of high availability.</p><p>So here is level 4: <strong>Human Irrelevant</strong>, what does this mean? It is almost indestructible, it runs on the Internet and is resistant to a variety of malicious attacks. This should be the highest form of HA. Basically, only a planetary-level attack can destroy it. In other words: as long as the Earth does not explode, it will continue to run. A classical example is the controversial Bitcoin.</p><p>According to my personal experience, the first two are not too difficult to achieve, the third requires the support of big companies, and the last one, Planet Irrelevant is what we are doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ucxfA_JfGb_PZIQ" /></figure><h3>The root of data security issues</h3><p>Regardless of the size of the companies, there is one common problem: your data is stored in IDC (Internet Data Centre). In this case, companies face several problems. The first is the developer’s dilemma. IDC cannot prove that the user’s data is properly stored and secured.</p><p>For example, if I develop a mobile APP and get your contact list from your mobile phone, my purpose is just to make it easier for you to pay your phone bills, or to increase social interaction. However, I’m unable to prove what I did with your phone book. I might say: “ I am a very honest developer. I wouldn’t use your data to do anything illegal. Of course, I will not do any data mining to find out if you have any needs recently.”</p><p>But no one believes!</p><p>I will say again: “ Right! I took your data, but I didn’t sell it. Someone else sold it. Your personal data breach has nothing to do with me.” <strong>However, these guarantees cannot be traced and proved.</strong> It is impossible to let users believe in you from the mechanism. Everything relies on the credit and self-discipline of the development team. Therefore, this market is like a quagmire. Everyone is wallowing in the mud, and the one who stands next to them certainly will not be clean.</p><p>The second problem is the large exposure to safety issues. It’s very common that an application has hundreds of APIs, supporting iOS, Android and Web. The exposure caused by traditional API leads to very high requirements of protections. In addition, developers have their own protocols and formats for developing APIs in the software development process, which means that the security protection must be done case by case and is difficult to integrate.</p><p>The direct result is that many small and medium-sized companies are difficult to ensure data security. In general, it’s already good enough for developers to code correctly and without bugs. If you can do a good job on HA, you definitely can get a good income. Not surprisingly, if you can still also consider the security issues, you definitely can ask any pay you want.</p><p>The third problem is that your data is always stored in a third party database. Even if it is encrypted, it is difficult to avoid snooping on the data. For example, you have a startup company. You store the operational data on Tencent Cloud. If your startup is doing well and delivers great data growth, Tencent’s strategic investment department may show interest in your startup and talk to you about investment. As for how they know your operations, no one can give you the answer. In fact, either Tencent Cloud or Alibaba Cloud, they saw your data, so what？You can do nothing about it.</p><h3>Current data storage solutions</h3><p>Overall, with a centralized cloud database, data is always stored in a third-party database. Obvious benefits are that they can be synchronized, not easy to lose, whether it is PC or mobile, iOS or Android, even if the device is lost, as long as you log in, your data is always there. However, the problem is that the exposure is large and it is impossible to prove the data is safe with cloud, while the cost is high and the utilization rate is low. The current database of most small and medium-sized developers is relatively idle.</p><p>Then someone might say: I don’t need a cloud. I can save the data locally. The advantage for offline data storage is that I don’t have to deal with the Internet, and my data is safe offline. But the disadvantages are also obvious. You cannot synchronize, your data is easy to lose, and data security and reliability are completely linked to the device.</p><p>Another method is to store your data on public blockchain, but the cost is extremely high. Take the example of Ethereum. At present, one megabyte is basically 1000 dollars, while the storage capacity is limited, and the system performance is low, which is affected by system design. Currently, the public blockchain lacks structured support, which means that developers need to perform data serialization calculations themselves to store structured data. At a first look, it seems that there is no advantage for public blockchain. The only advantage is decentralization, which sounds tempting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j7IXyDOBM8ciet-Z" /></figure><h3>CovenantSQL: a wild database</h3><p>Therefore, we built a database with the decentralized blockchain.</p><p>Although SQL has a variety of problems and has not kept up with the trend in recent years, you will find that many startups are now trying to improve the high availability, scalability and other performance of traditional SQL databases.</p><p>Meanwhile, no matter what kind of database that we are comparing with, one of our characteristics is: wild (or we prefer to say security). For most of the databases you use, the servers are controlled by yourself or the cloud service providers. No one will encourage you to expose the database ports on the internet, otherwise you will soon be attacked by hackers. The SQL architecture is not very resistant to attacks, or high frequency queries. Therefore, we use the blockchain and cryptography techniques to ensure that SQL can run on the Internet. The solutions for security mainly include:</p><ul><li>Algorithm autonomy &amp; asymmetric encryption: guarantees that no data position can be located without authorization</li><li>Column-level access control, ETEE (end-to-end encryption), transport encryption, off-disk encryption</li><li>Read and write can be recorded and cannot be tampered with</li></ul><p>Another feature is the ease of integration. In addition to structured data support, for global synchronization, we let users customize the CAP and choose different CAP types based on their needs. At the same time, we are almost fully compatible with the SQL standard. Of course, the “wild” database also has the advantage of low cost. Just find a server and run it for “mining”.</p><p>There are a lot of technical details about how we actually implement the “wild” features. If you are interested in CovenantSQL, find us on Github <a href="https://github.com/CovenantSQL/CovenantSQL">here</a> or contact us at<a href="/service/mailto:webmaster@covenantsql.io"> our email</a>.</p><h3>Q &amp; A</h3><p><strong>1. What are the conditions for database deployment, and what are the requirements for the network if deployed separately?</strong></p><p><strong>Auxten: </strong>We have a testnet so that you don’t need to build anything, and we also have a docker compose. Actually, we are the database with the least requirement for the network. No matter how bad the network is, we can function, and even debug the database with worse network speed. Therefore, since it can run on the internet, you can also run in other server room. You can make a request on GitHub and try it out.</p><p><strong>2. Why don’t you use Raft to synchronize the database directly?</strong></p><p><strong>Auxten: </strong>The database can’t be used just using a raft. For the untrusted and public network, we have some special optimizations for CovenantSQL. The core of optimizing high concurrency is that you minimize the lock of the unsplitable transaction that might affect your speed. Due to the RTT (Round Trip Time) of the entire network, the normal Raft’s transaction speed cannot be lifted.</p><p>Our solution is different. In the stage of preparing the database (pre-confirmation phase), we have already been doing concurrency which is in a queue outside the database core lock. After queuing, there will be a window that receives the prepare confirmation and waits for the confirmation. For example, if two-thirds of the nodes receive the confirmation, a commit is initiated. In the process of initiating the commit, we don’t wait, so that in the whole process the lock is only locked in the core part of the transaction to achieve a high concurrency. The code can be viewed on <a href="https://github.com/CovenantSQL/CovenantSQL">GitHub</a>.</p><p><strong>3. Regarding database availability, is there a situation that miner shuts down or terminates the service and causes data loss. Is there any consideration in this regard?</strong></p><p><strong>Auxten: </strong>This involves a problem, what if the output node shut down? These nodes involved in mining are required to run the database to get the reward. So when you are mining, you need to take some tokens as deposit. There is one problem every time you run the SQL. How do you prove that you executed the particular SQL to get the data instead of randomly generating something? The records for the deposit and data will do peer rating, and then a signature will be signed on the returned results. After that, a confidence level will be calculated on the network. If you want a high degree of confidence, you need to check multiple nodes.</p><p>How to ensure that this data is the data that miner saved, not cheated with shoddy works? Here we use a verification mechanism similar to a zero-knowledge proof. Simply put, we have a question, the questioner calculates the actual answer of the question, and then let these people go to do this question separately, calculate an answer and then do the signature and verify the answer. If the answer is wrong, the deposit of mining will be deducted. Additionally, If you do not follow the normal process to quit, you will be punished economically. Under normal circumstances, we will record your behaviour on the blockchain. If you want to quit, we will detect this situation and arrange another miner to replace you, then synchronize the data and add to the network.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed14be362b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CovenantSQL Testnet Quickstart]]></title>
            <link>https://medium.com/@covenant_labs/covenantsql-testnet-quickstart-c02ca6fa310b?source=rss-b4be9f949f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c02ca6fa310b</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Covenant Labs]]></dc:creator>
            <pubDate>Thu, 01 Nov 2018 02:56:59 GMT</pubDate>
            <atom:updated>2018-11-01T02:56:59.056Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/CovenantSQL/CovenantSQL/blob/develop/README.md">CovenantSQL</a> is a decentralized, crowdsourcing SQL database on blockchain with features:</p><ol><li>SQL: most SQL-92 support.</li><li>Decentralized: decentralize with our consensus algorithm DH-RPC &amp; Kayak.</li><li>Privacy: access with granted permission and encryption pass.</li><li>Immutable: query history in CovenantSQL is immutable and trackable.</li></ol><p>We believe in <a href="https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e">the next Internet generation, everyone should have complete data rights</a></p><p>Here is how to start with CovenantSQL.</p><h3>0. Download CovenantSQL Tools</h3><p>Download latest release on <a href="https://github.com/CovenantSQL/CovenantSQL/releases">Github</a>.</p><h3>1. Generate config file with cql-utils to connect TestNet</h3><pre>$ cql-utils -tool confgen<br>Generating key pair...<br>Enter master key(press Enter for default: &quot;&quot;):<br>⏎<br>Private key file: conf/private.key<br>Public key&#39;s hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd<br>Generated key pair.<br>Generating nonce...<br>nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9}<br>node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9<br>Generated nonce.<br>Generating config file...<br>Generated nonce.</pre><p>After running cql-utils, it will generate a configured file in ./conf.</p><h3>2. Generate wallet address from private key</h3><p>The private key can be found in ./conf.</p><pre>$ cql-utils -tool addrgen -private ./conf/private.key<br>Enter master key(default: &quot;&quot;):<br>⏎<br>wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9</pre><h3>3. Get your PTC on Faucet</h3><p>The faucet address: <a href="https://testnet.covenantsql.io/">CovenantSQL Testnet Faucet</a>.</p><p>Use cql to check your wallet balance:</p><pre>$ cql -config conf/config.yaml -get-balance<br>INFO[0000] stable coin balance is: 100                   caller=&quot;main.go:246 main.main&quot;<br>INFO[0000] covenant coin balance is: 0                   caller=&quot;main.go:247 main.main&quot;</pre><p>Here, I got “stable coin balance is: 100”.</p><h3>4. Create a database using CLI</h3><pre>$ cql -config conf/config.yaml -create 1<br>INFO[0000] the newly created database is: covenantsql://0e9103318821b027f35b96c4fd5562683543276b72c488966d616bfe0fe4d213  caller=&quot;main.go:297 main.main&quot;</pre><p>Here, 1 refers that <em>one</em> node will be created for this database. covenantsql://... is a database address which is used by SDK and CLI to locate the database on the blockchain.</p><h3>5. Documents of CLI and SDK</h3><p>After creating a database, there are some documents and examples to help you build an application with our database.</p><ul><li>CLI Document: <a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/cmd/cli/README.md">CLI README.md</a></li><li>SDK Document: <a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/README.md">SDK README.md</a></li><li>SDK Demos: <a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/client/_example">SDK Demos</a></li></ul><h3>6. SQLChain Explorer</h3><p>Currently, the database on TestNet is permissionless, which means that if you know the DSN (address) of a database you can retrieve all modification history of the database and blocks information on blockchain through <a href="https://explorer.dbhub.org/">SQLChain Explorer</a>.</p><p>For more technique details of testnet, please visit:</p><blockquote><a href="https://github.com/CovenantSQL/CovenantSQL/wiki/Release-Notes"><em>TestNet Release Notes</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c02ca6fa310b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CovenantSQL: the SQL Database on Blockchain]]></title>
            <link>https://medium.com/good-audience/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e?source=rss-b4be9f949f2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/db027aaf1e0e</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Covenant Labs]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 08:13:01 GMT</pubDate>
            <atom:updated>2019-02-07T16:14:15.830Z</atom:updated>
            <content:encoded><![CDATA[<p>Show Me The Code: <a href="https://github.com/CovenantSQL/CovenantSQL">https://github.com/CovenantSQL/CovenantSQL</a></p><p>Author: Auxten Wang, Co-Founder of CovenantSQL</p><p>The idea of CovenantSQL rised in December 2017, in a cold windy day when Jing Mi came to have dinner with me in a BBQ restaurant. He brought me an interesting idea to build a SQL database on Blockchain. I was excited about this idea and decided immediately to quit my job and start this project.</p><h3>Past Experiences with Database</h3><p>I got to know about databases since I joined Baidu, one of the biggest internet companies in China. When I was working at Baidu, my proudest thing is to apply the idea of Dynamo distributed database to make a P2P transmission system that looks like a toy now: <a href="http://auxten.github.io/gingko/">auxten/Gingko @ GitHub</a>. At that time, Jing Mi was working on a database called Doris for Baidu statistics, so I often asked him questions about database, and we talked about MongoDB and MySQL. The Doris project was developed very well in Baidu and was <a href="https://incubator.apache.org/projects/doris.html">added in the Apache Incubator this year.</a></p><h3>Bitcoin</h3><p>In 2012, I joined China’s top security company 360.com to develop security-related products and researched encryption algorithms, SETI@home. From there I got to know “Bitcoin”. Occasionally, I read the book written by Friedrich Hayek — <em>Denationalization of Money</em>. Later, I was surprised to find that some of my friends who have invested in Bitcoin in the early days were also influenced by this book. At that time, I just felt that this idea was really genius and bought some bitcoin instantly when the value was only ¥8.</p><p>I learned about Bitcoin more and more since then: automated trading; assembled Bitcoin mining machines (today, there are still a bunch of AMD graphics cards in my home). I even built a Bitcoin trading market with one of my friends (called 42BTC, hosted on GAE). I have been basically involved in the entire industry chain of Bitcoin. Having experienced various collapses, bear and bull markets of Bitcoin in the past years, I didn’t seriously calculate how much money I earned or lost from Bitcoin.</p><p>Last year, The People’s Bank of China issued a variety of red-headed documents prohibiting Chinese commercial banks from investing funds from Bitcoin exchanges, and I was so tired and sold most of my BTC. The remaining hundreds of BTCs were lost in Mtgox.com because Mtgox.com went bankrupt. Not to mention the lost, I felt that I was lucky enough to be an early investor in Bitcoin. My biggest takeaway from that experience is that I don’t care much about money gains and losses as I did several years ago.</p><h3>Thunder Crystal</h3><p>I forgot in which year Jing Mi moved to Shenzhen (He used to live in Beijing, the city where I stay). We contacted each other less often after that as we were all busy with work. I only knew that he was in charge of a project called “Thunder Crystal” at Xunlei, the biggest P2P tech company in China. Simply explain what Thunder Crystal project is for:</p><blockquote>The project enables you to share your idle broadband resources to cache popular TV shows for Netflix and YouTube, and make money.</blockquote><p>One day in 2014, someone sent a photo in the group chat, and I recognized Jing Mi at a glance: he participated in Xunlei’s IPO and went to NASDAQ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*xuQ7KR3HUdHz-b7k.jpg" /><figcaption>jingmi@NASDAQ</figcaption></figure><p>My feeling is complicated:</p><blockquote>1. Wow, I finally got to know someone who went to NASDAQ to ring the bell!</blockquote><blockquote>2. Well, Jing Mi must be financially free. Can we still discuss various technical issues happily in the future?</blockquote><blockquote>3. Sigh, there is one more person with financial freedom in the world, but there may be one less great programmer…</blockquote><p>Papers published on ACM and IEEE for Thunder Crystal can be found here:</p><p><a href="https://ieeexplore.ieee.org/abstract/document/7762143/"><em>https://ieeexplore.ieee.org/abstract/document/7762143/</em></a></p><p><a href="https://dl.acm.org/author_page.cfm?id=99658692448"><em>https://dl.acm.org/author_page.cfm?id=99658692448</em></a></p><h3>Something Remarkable</h3><p>Jeff Hammerbacher said that:</p><blockquote>The best minds of my generation are thinking about how to make people click ads.</blockquote><p>As one of the best minds, when you no longer need to work hard for a living, what do you want to do most?</p><blockquote>The biggest risk is not taking any risk. The only strategy that is guaranteed to fail is not taking risks. — Mark Zuckerberg</blockquote><p>Becoming very excited about the idea of Bitcoin, I bought a lot of bitcoins, and then experienced the price fluctuation, and finally disappointed.<br>When the concept of Blockchain was abstracted from Bitcoin, I even thought about rewriting a version of <a href="https://boinc.berkeley.edu/">Boinc</a> with Blockchain’s idea (Berkeley’s Volunteer computing framework, which allows users to use various scientific calculations when idle, including “SETI@Home”) But in the end, I still couldn’t make up my mind…</p><p>In the winter of 2017, jingmi came to Beijing, and we met in a BBQ restaurant near Zhong Guan Cun in Beijing. As in the old times, Jing Mi and I had a hot pot and scorned MongoDB using BSON for storage, but this time he also came with an exciting idea. His idea reminded me of his 8th-grade syndrome signature that he put on our university BBS many years ago:</p><blockquote>Pioneers have changed the world. Things are silently evolving. Let us change the world again.</blockquote><p>Generally speaking, this is how the idea looks like:<br>Connect the idle resources and devices to form a distributed database that supports SQL queries through a set of Code Law. Users and database miners will be matched, and value will be exchanged, under the restrictions of Code Law.</p><p>With the born of Ethereum, people became more excited and devout about blockchain, but now it runs into a big crisis this summer. In the era that technology has a huge impact on human life, a lot of people wish to get rich overnight, but the collision of ideas takes time, the development of theory takes time, and coding and project launch take time as well.</p><p>In the late 90s, the Internet boom led to bubbles and speculations. Now the history is repeating itself, the bubbles of blockchain might be even bigger. However, like the internet bubble didn’t destroy companies such as Google, Amazon, PayPal and Netflix, the blockchain bubble won’t destroy those companies who focus on developing their intrinsic value.</p><p>This time, I decided to make all-out effort for an idea. Even if I failed, I hope we can leave something useful that the next generation engineers can change the world. After the dinner with Jing Mi, I decided to quit my job and do something interesting with him.</p><p>Looking back, the reason why we choose to build an infrastructure is partially from our little 8th-grade syndrome obsession about database, but more from the hope to change to current issues of data &amp; privacy protection:</p><blockquote><strong>on the next generation of Internet, everyone should have a complete Data Rights</strong></blockquote><h3>Data Rights</h3><p>It’s safer to store your data on an offline computer, but it’s also easy to accidentally lose it, and you would find it not easy to check. Whether it is on Facebook or WeChat, various cloud disks, the user’s data is almost always stored in a database controlled by a large company. The data belongs to you, but in the end, it is still under the control of the big Internet companies, and <strong>you have to</strong> <strong>confirm</strong> the terms of use.</p><p>The data on the Internet can be roughly divided into two categories:</p><p><strong>Personal Data</strong></p><ul><li>Examples of personal data: personal identity &amp; account information, private property, personally published content, historical data on applications, and websites.</li><li>Present situation: Privacy breaches, data mining abuse, and digital copyright infringement.</li><li>Our goal: Everyone should have control over reading and modifying personal data, as well as economic rights and authorization.</li></ul><p><strong>Public Data</strong></p><ul><li>Example of public data: Wikipedia and other co-create works, knowledge of human civilization, various data shared to everyone.</li><li>Present situation: Public wiki is sometimes malicious tampered and loses its credibility; papers, documents are used improperly to earn money; producers of valuable data receive no benefits, and sometimes lose control of copyright.</li><li>Our goal: The process of knowledge production often involves more than one individual, and each person’s contribution should be recorded.</li></ul><p>Richard in “Silicon Valley” described a “decentralized Internet”. To build a decentralized internet what is critical is to build a decentralized database. When the traditional database meets blockchain, the Insert, Update, and Delete actions of data become Append. “Append instead of Overwrite” allows the history of the data to be fully recorded.</p><h3>Read-Only</h3><p>To change the present situation, there is a long way to go. A decentralized database provides at least some possibilities for users to control their own data.</p><p>To give a simple example: in the future, our personal data can be stored in a decentralized cloud database. Like Bitcoin, we can completely control our data with a single key. We can develop a standard similar to the <strong>PCI DSS</strong> from the credit card industry. In this moment, we call it the <strong>GDSS (General Data Security Standard) </strong>temporarily. The core is to require companies to strictly limit the use of the user’s data and delete it after use. For example, suppose Facebook is our trusted vendor. Following <strong>GDSS</strong>, we can give Facebook an authorized key that can only read our name, age, and friends list. At the same time, Facebook should make a record every time our data is read. If we find that Facebook has used our data to do something that we don’t like, we can revoke this key, make a complaint, or take a legal action.</p><p>Another example: the biggest headache for start-ups or research organizations in the big data industry is that there is no data available. Users can authorize these research institutions to use their own data and receive a certain amount of money for compensation. This will create a win-win situation and avoid the monopoly control of data by the companies that store our data.</p><p>European Union is leading data protection in terms of regulations. EU published <strong>GDPR </strong>this year and set out clear standards to regulate misconducts of using personal data.</p><h3>Team Up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*rrJ1lvhZy34ifdRE.jpg" /></figure><p>Before starting CovenantSQL, we have done a lot of projects in this field and understand that program development is a very complicated job. We gained a consensus learned from our similar experiences:</p><p>1. Project development must have clear, quantifiable, fine-grained goals.</p><p>2. Do not perform a BIG rewrite. Refactoring must be done in modules and must ensure that the interfaces are consistent.<br>In project’s early stage, write less code and complete the function now rather than writing more code now for future use purpose.</p><p>In April 2018, CovenantSQL team started the first line of code. We named the project with CovenantSQL as the word covenant implies our vision that records shall not be tampered without owner’s agreement. The translation into Chinese is called “契约”. The english word “covenant” is not common to Chinese people. Last time it was mentioned commonly is because of the movie <a href="https://www.imdb.com/title/tt2316204/">Alien: Covenant (2017)</a>.</p><h3>Architecture</h3><p>Programmers who are familiar with the principles of distributed systems should know that from the perspective of the CAP theorem, Blockchain is a final consistency algorithm. The PoW used by Bitcoin for the typical Blockchain 1.0 is mainly for dealing with non-trusted networks and nodes. A lot of people have similar experience: “The fewer people involved, the more efficient is the decision-making.”</p><p>Blockchain developers seem to be aware of the same problem. The new generation of Blockchain systems led by EOS uses a “cabinet” like DPoS. We considered the issue with efficiency when we designed CovenantSQL at the beginning and used the layered architecture shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkkh2zu2nhIwG93maqMX6Q.png" /><figcaption>CovenantSQL Three-Layer Design</figcaption></figure><p>The architecture of CovenantSQL is designed with three layers:</p><ol><li><strong>Global consensus layer</strong> (the main chain, the middle cycle in the architecture diagram):<br>There will be only one main chain throughout the network.<br><em>Main Role</em>: Organizing database miners and match to users according to smart contract, dealing with transactions settlement, anti-cheating, recording the shard chain block hash on the main chain, and other global consensus matters.</li><li><strong>SQL consensus layer</strong> (shard chain, cycles on both sides):<br>Each database will have its own separate shard chain.<br><em>Main Role</em>: transaction signature, transmitting, and consistency of the various transactions of the database. The traceable data history is implemented here, and the hash lock is saved on the main chain.</li><li><strong>Datastore layer</strong>:<br>Each Database has its own independent distributed engine.<br><em>Main Role</em>: database storage &amp; encryption, querying &amp; signature, efficient indexing.</li></ol><p>The three-layer design is hash locked with each other to ensure that the data cannot be tampered. From top to bottom, according to different requirements, different consensus algorithms and smaller consensus scopes are adopted to achieve higher consensus efficiency and performance.</p><p>The so-called non-tamperable blockchain is not 100% theoretically non-tamperable, it’s tamperable because the cost of tampering increase drastically as the number of nodes increases. We need different level of data security protection in different circumstances, so in our design, the user decides the number of replicates of the database. Of course, the more copies, the higher the cost. For a single database, assuming that the number of instances required by the database creator is <em>N</em>, then there will be no less than <em>N</em> nodes running the database, and only the <em>N</em> nodes need to maintain the full data of the database. The correspondence between the database and miners is anonymous to reduce the possibility of being attacked.</p><h3>How We Work</h3><p>Observing the commit history of <a href="https://github.com/CovenantSQL/CovenantSQL"><strong>CovenantSQL</strong></a>, you will find that the construction of CovenantSQL is a bottom-up process. First of all, we developed independent modules and test tools. After more than four months of intensive development, we finally built the main program. The benefits of doing this are obvious: CovenantSQL’s module single-test coverage is basically more than 75%, and many CovenantSQL modules can be used separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/0*VUErQZW8mbafyfZ3.jpg" /><figcaption>CovenantSQL test coverage</figcaption></figure><h3><a href="https://github.com/CovenantSQL/GNTE">CovenantSQL/GNTE</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*SplXOHDv39VJx3Jr.jpg" /></figure><p>In order to simulate the network environment where CovenantSQL nodes are distributed all over the world, we also made a gadget called GNTE (Global Network Topology Emulator). By writing a YAML configuration and running a command, we can simulate a complicated container from China to the United States for testing, for example: 1Mbps bandwidth, delay 1200ms, 1% probability ±10ms.</p><p>This project was released for two months and has gained 171 Stars on Github.</p><p>Github: <a href="https://github.com/CovenantSQL/GNTE"><strong>CovenantSQL/GNTE</strong></a></p><p>Going forward, the release of all new versions of CovenantSQL will proceed:</p><ol><li>Automated unit testing close to 80% line coverage</li><li>Various integration tests including linear consistent testing</li><li>GNTE simulates global network environment for integration testing</li></ol><h3><a href="https://github.com/CovenantSQL/HashStablePack">CovenantSQL/HashStablePack</a></h3><p>HSP is another gadget we built. We can automatically generate serialized interface `<em>func(v *Type) MarshalHash() ([]byte, error)</em>` according to the various types of Golang we define. No matter how complex is the Struct, as long as the stored content is the same, the content of `<em>[]byte</em>` is consistent.</p><p>The main principle is to analyze the golang code, generate an AST (abstract syntax tree), and generate different `MarshalHash` functions according to different types on the AST. This avoids the slowdown of approximately two orders of magnitude caused by the `<em>Reflect</em>` reflection at runtime. CovenantSQL mainly uses this tool to generate code that computes block hashes.</p><p>Of course, even the unit test code is automatically generated. For more detailed usage please check out here: <a href="https://github.com/CovenantSQL/HashStablePack">CovenantSQL/HashStablePack</a></p><h3><a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/rpc">DH-RPC</a></h3><p>DH-RPC is a secp256k1-ECDH-AES encrypted P2P RPC framework for decentralized applications written in golang.</p><p>CovenantSQL is built on DH-RPC, including:</p><ul><li>Byzantine Fault Tolerance consensus protocol <a href="https://godoc.org/github.com/CovenantSQL/CovenantSQL/kayak">Kayak</a></li><li>Consistent Secure DHT</li><li>DB API</li><li>Metric Collect</li><li>Blocks sync</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/0*VXWTKW_yhCVwLws-.gif" /></figure><ul><li>Demo Code see <a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/rpc#example">Example</a></li></ul><h3>Features</h3><ul><li>75%+ code testing coverage.</li><li>100% compatible with Go <a href="https://link.zhihu.com/?target=https%3A//golang.org/pkg/net/rpc/">net/rpc</a> standard.</li><li>ID-based routing and Key exchange built on Secure Enhanced DHT.</li><li>Use MessagePack for serialization which supports most types without writing Marshal Unmarshal.</li><li>Crypto Schema</li><li>Use Elliptic Curve Secp256k1 for Asymmetric Encryption</li><li>ECDH for Key Exchange</li><li>PKCS#7 for padding</li><li>AES-256-CBC for Symmetric Encryption</li><li>Private key protected by the master key</li><li>The anonymous connection is also supported</li><li>DHT persistence layer has 2 implementations:</li><li>BoltDB based simple traditional DHT</li><li>Kayak based 2PC strong consistent DHT</li><li>Connection pool based on <a href="https://link.zhihu.com/?target=https%3A//github.com/hashicorp/yamux">Yamux</a>, make thousands of connections multiplexed over One TCP connection.</li></ul><p>see: <a href="https://github.com/CovenantSQL/CovenantSQL/tree/develop/rpc">CovenantSQL/DH-RPC</a></p><p>So far, we have completed about 90% of the main functions. The test network is also under construction. For more updates, please follow us on Github:</p><h3><a href="https://github.com/CovenantSQL/CovenantSQL">CovenantSQL/CovenantSQL</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*SJt_NdZka_jONwKJta3EWw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db027aaf1e0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/good-audience/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e">CovenantSQL: the SQL Database on Blockchain</a> was originally published in <a href="https://medium.com/good-audience">Good Audience</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>