Skip to content

Commit

Permalink
Merge pull request #174 from Tribler/CS4160/class-of-2024
Browse files Browse the repository at this point in the history
blockchain Engineering: Class of 2024
  • Loading branch information
InvictusRMC authored Feb 13, 2024
2 parents 8169773 + 83bd270 commit d19fe97
Show file tree
Hide file tree
Showing 162 changed files with 9,734 additions and 23 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ This repository contains a collection of Android apps built on top of [IPv8](htt

## Apps

### On-Chain Democracy
We build a DAO for a better world. On-Chain Democracy is an Android application built on top of [IPv8](https://github.com/Tribler/kotlin-ipv8) and [Trustchain](https://github.com/Tribler/kotlin-ipv8/blob/master/doc/TrustChainCommunity.md), and is integrated into the [Trustchain Superapp](https://github.com/Tribler/trustchain-superapp). It is a proof-of-concept implementation of a DAO system using Trustchain and Bitcoin. Trustchain is used for communication and bookkeeping while the Bitcoin blockchain is used to have collective multi-signature wallets for each DAO. The content of the app is split up in several tabs:
* **First Time Launch**: The first time the app is launched, the user must setup his bitcoin wallet. Afterwhich the chain will sync and he is routed to the main screens.
* **My DAO's**: A list of all DAO's that the user participates in. Selecting a DAO will allow a user to create a transfer proposal from that DAO.
* **All DAO's**: A list of all discovered DAO's in the network which the user can propose to join.
* **Proposals**: A list of all proposals that the user can vote on. This can either be join proposals or proposals from someone else to transfer funds from one of the DAO's.
* **My Wallet**: Overview of the used Bitcoin wallet and the ability to chain this to another.
* **Duplicate Wallet**: In case the user has wallet files for TestNet, Production or Regtest, the user is allowed to select which one to keep. After the user selected either one, the files belonging to other network type are backed up. This, thus, ensures that the wallet is not lost.

Currently, the On-Chain Democracy app only allows Regtest, since it uses a future update of Bitcoin called Taproot. Once Taproot is officially released, the app can support TestNet or Production again. Taproot allows the DAO to scale to thousands or even millions of users. The beauty of Taproot is that it uses Schnorr signatures for each transaction. This enables transaction sizes that are equal independent of the number of users in a DAO, since each user combines their signature collaberatively into one for the whole DAO. This also ensures privacy, since it is no longer possible to tell if a transaction's is from a single person, or a million of persons.

<img src="currencyii/docs/images/screenshot_7.png" width="200px"> <img src="currencyii/docs/images/screenshot_6.png" width="200px"> <img src="currencyii/docs/images/screenshot_10.png" width="200px">
<br />

<p float="left">
<img src="https://user-images.githubusercontent.com/23526224/111478102-0c54dc00-8730-11eb-9fbb-3cd65e2ee7ad.gif" width="200"/>
<img src="https://user-images.githubusercontent.com/23526224/111478323-42925b80-8730-11eb-9bb9-d90b703385a3.jpeg" width="200"/>
<img src="https://user-images.githubusercontent.com/23526224/111479002-e2e88000-8730-11eb-9246-dc487e5268b4.jpeg" width="200"/>
</p>
<br />

https://user-images.githubusercontent.com/23526224/116259903-85efd900-a776-11eb-93b1-384936d215c4.mp4


[More about Currency II](currencyii/README.md)


### PeerChat

PeerChat implements a fully functional prototype of a distributed messaging app. First, the users have to exchange the public keys by scanning each other's QR code, or by copy-pasting the hexadecimal public keys. This guarantees authenticity of all messages which are signed by their author. It prevents man-in-the-middle and impersonation attacks.
Expand Down
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {

defaultConfig {
applicationId "nl.tudelft.trustchain"
minSdkVersion 22
minSdkVersion 24
targetSdkVersion 33
versionCode generateVersionCode()
versionName "0.3.3"
Expand Down Expand Up @@ -122,6 +122,9 @@ dependencies {
api(project(':common-ethereum')) {
exclude group: 'net.java.dev.jna'
}
api(project(':currencyii')) {
exclude group: 'net.java.dev.jna'
}
api(project(':musicdao')) {
exclude group: 'net.java.dev.jna'
}
Expand Down Expand Up @@ -163,6 +166,7 @@ dependencies {
implementation('com.github.tony19:logback-android:2.0.0')

implementation 'com.github.MattSkala:recyclerview-itemadapter:0.4'
implementation project(':currencyii')

// Testing
testImplementation 'junit:junit:4.13.2'
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
android:name="nl.tudelft.trustchain.debug.DebugActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity" />

<activity
android:name="nl.tudelft.trustchain.currencyii.CurrencyIIMainActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity" />

<activity
android:name="nl.tudelft.trustchain.eurotoken.EuroTokenMainActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity"
Expand Down Expand Up @@ -114,15 +118,15 @@
android:label="Music App"
android:parentActivityName=".ui.dashboard.DashboardActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.MusicDaoTheme"></activity>
android:theme="@style/Theme.MusicDaoTheme" />


<activity
android:name="nl.tudelft.trustchain.peerai.PeerAIActivity"
android:exported="true"
android:label="PeerAI App"
android:parentActivityName=".ui.dashboard.DashboardActivity"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />

<service
android:name="nl.tudelft.trustchain.app.service.TrustChainService"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/nl/tudelft/trustchain/app/AppDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.DrawableRes
import nl.tudelft.trustchain.musicdao.MusicActivity
import nl.tudelft.trustchain.FOC.MainActivityFOC
import nl.tudelft.trustchain.common.R
import nl.tudelft.trustchain.currencyii.CurrencyIIMainActivity
import nl.tudelft.trustchain.debug.DebugActivity
import nl.tudelft.trustchain.eurotoken.EuroTokenMainActivity
import nl.tudelft.trustchain.valuetransfer.ValueTransferMainActivity
Expand All @@ -18,6 +19,12 @@ enum class AppDefinition(
val activity: Class<out Activity>,
val disableImageTint: Boolean = false,
) {
CURRENCY_II(
R.drawable.ic_baseline_how_to_vote_24,
"On-Chain Democracy",
R.color.democracy_blue,
CurrencyIIMainActivity::class.java,
),
DEBUG(
R.drawable.ic_bug_report_black_24dp,
"Debug",
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/nl/tudelft/trustchain/app/AppLoader.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package nl.tudelft.trustchain.app

import android.annotation.SuppressLint
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
Expand Down Expand Up @@ -59,7 +58,6 @@ class AppLoader(
}
}

@SuppressLint("NewApi")
private suspend fun setPreferredAppList(newPreferences: Set<String>) {
dataStore.edit { settings ->
settings[PREFERRED_APPS] = newPreferences
Expand All @@ -72,6 +70,7 @@ class AppLoader(
companion object {
val PREFERRED_APPS = stringSetPreferencesKey("preferred_apps")
val DEFAULT_APPS = setOf(
AppDefinition.CURRENCY_II.appName,
AppDefinition.VALUETRANSFER.appName,
AppDefinition.MUSIC_DAO.appName,
AppDefinition.EUROTOKEN.appName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package nl.tudelft.trustchain.app

import android.annotation.SuppressLint
import android.app.Application
import android.bluetooth.BluetoothManager
import android.content.Context
Expand All @@ -14,18 +13,16 @@ import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.preferencesDataStore
import androidx.preference.PreferenceManager
import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity
import nl.tudelft.trustchain.musicdao.core.dao.DaoCommunity
import com.squareup.sqldelight.android.AndroidSqliteDriver
import com.squareup.sqldelight.db.SqlDriver
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import nl.tudelft.ipv8.IPv8Configuration
import nl.tudelft.ipv8.Overlay
import nl.tudelft.ipv8.OverlayConfiguration
Expand All @@ -34,7 +31,11 @@ import nl.tudelft.ipv8.android.keyvault.AndroidCryptoProvider
import nl.tudelft.ipv8.android.messaging.bluetooth.BluetoothLeDiscovery
import nl.tudelft.ipv8.android.peerdiscovery.NetworkServiceDiscovery
import nl.tudelft.ipv8.attestation.schema.SchemaManager
import nl.tudelft.ipv8.attestation.trustchain.*
import nl.tudelft.ipv8.attestation.trustchain.BlockListener
import nl.tudelft.ipv8.attestation.trustchain.BlockSigner
import nl.tudelft.ipv8.attestation.trustchain.TrustChainBlock
import nl.tudelft.ipv8.attestation.trustchain.TrustChainCommunity
import nl.tudelft.ipv8.attestation.trustchain.TrustChainSettings
import nl.tudelft.ipv8.attestation.trustchain.store.TrustChainSQLiteStore
import nl.tudelft.ipv8.attestation.trustchain.store.TrustChainStore
import nl.tudelft.ipv8.attestation.trustchain.validation.TransactionValidator
Expand All @@ -59,13 +60,15 @@ import nl.tudelft.trustchain.common.MarketCommunity
import nl.tudelft.trustchain.common.bitcoin.WalletService
import nl.tudelft.trustchain.common.eurotoken.GatewayStore
import nl.tudelft.trustchain.common.eurotoken.TransactionRepository
import nl.tudelft.trustchain.musicdao.core.dao.CoinCommunity
import nl.tudelft.trustchain.currencyii.CoinCommunity
import nl.tudelft.trustchain.eurotoken.community.EuroTokenCommunity
import nl.tudelft.trustchain.eurotoken.db.TrustStore
import nl.tudelft.trustchain.valuetransfer.community.PeerChatCommunity
import nl.tudelft.trustchain.valuetransfer.util.PeerChatStore
import nl.tudelft.trustchain.musicdao.core.dao.DaoCommunity
import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity
import nl.tudelft.trustchain.valuetransfer.community.IdentityCommunity
import nl.tudelft.trustchain.valuetransfer.community.PeerChatCommunity
import nl.tudelft.trustchain.valuetransfer.db.IdentityStore
import nl.tudelft.trustchain.valuetransfer.util.PeerChatStore

val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")

Expand Down
2 changes: 1 addition & 1 deletion common-bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
compileSdkVersion 33

defaultConfig {
minSdkVersion 22
minSdkVersion 24
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion common-ethereum/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
}

defaultConfig {
minSdkVersion 22
minSdkVersion 24
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
compileSdkVersion 33

defaultConfig {
minSdkVersion 22
minSdkVersion 24
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/res/drawable/ic_baseline_how_to_vote_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,13h-0.68l-2,2h1.91L19,17L5,17l1.78,-2h2.05l-2,-2L6,13l-3,3v4c0,1.1 0.89,2 1.99,2L19,22c1.1,0 2,-0.89 2,-2v-4l-3,-3zM17,7.95l-4.95,4.95 -3.54,-3.54 4.95,-4.95L17,7.95zM12.76,2.29L6.39,8.66c-0.39,0.39 -0.39,1.02 0,1.41l4.95,4.95c0.39,0.39 1.02,0.39 1.41,0l6.36,-6.36c0.39,-0.39 0.39,-1.02 0,-1.41L14.16,2.3c-0.38,-0.4 -1.01,-0.4 -1.4,-0.01z"/>
</vector>
1 change: 1 addition & 0 deletions common/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<color name="metallic_gold">#D4AF37</color>
<color name="black">#000000</color>
<color name="white">#ffffff</color>
<color name="democracy_blue">#0056b3</color>

<array name="colorsChain">
<item>#EF5350</item>
Expand Down
3 changes: 3 additions & 0 deletions currencyii/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
*.spvchain
*.wallet
Loading

0 comments on commit d19fe97

Please sign in to comment.