Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set the default line endings for all text files to LF
* text=auto

# Always checkout with LF
*.sh text eol=lf
gradlew text eol=lf

# Always checkout with CRLF
*.bat text eol=crlf
4 changes: 2 additions & 2 deletions .github/workflows/deploy_jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
increment: ${{ env.increment }}

upload_release:
if: github.repository == 'adwise-fiu/Secure_Indoor_Localization'
needs: [ create_release ]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -71,10 +72,9 @@ jobs:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
VERSION: ${{ env.RELEASE_VERSION }}

# You want to use the 'ciphercraft-<version>.jar' for your uses
- name: Release the JAR file
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create_release.outputs.v-version }}
files: REUServer/build/libs/fingerprint_localization*.jar
files: REUServer/build/libs/*.jar
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .github/workflows/parallel_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ jobs:
chmod +x gradlew
./gradlew test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

test-android:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions REU2017/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
<!-- The top two lines are needed to scale all images -->

<activity
android:name="ui.MainActivity"
android:name="edu.fiu.adwise.fingerprint_localization.ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="ui.TrainActivity"
<activity android:name="edu.fiu.adwise.fingerprint_localization.ui.TrainActivity"
android:exported="true">
<intent-filter>
<action android:name="ui.TrainActivity" />
</intent-filter>
</activity>

<activity android:name="ui.LocalizeActivity"
<activity android:name="edu.fiu.adwise.fingerprint_localization.ui.LocalizeActivity"
android:exported="true">
<intent-filter>
<action android:name="ui.LocalizeActivity" />
</intent-filter>
</activity>

<activity
android:name="ui.AddMapActivity"
android:name="edu.fiu.adwise.fingerprint_localization.ui.AddMapActivity"
android:exported="true">
<intent-filter>
<action android:name="ui.AddMapActivity" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Localization;
package edu.fiu.adwise.fingerprint_localization.localization;

import android.util.Log;

Expand All @@ -14,12 +14,12 @@
import edu.fiu.adwise.fingerprint_localization.structs.LocalizationResult;
import edu.fiu.adwise.fingerprint_localization.structs.SendTrainingData;
import edu.fiu.adwise.homomorphic_encryption.misc.HomomorphicException;
import ui.MainActivity;
import ui.TrainActivity;
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;
import edu.fiu.adwise.fingerprint_localization.ui.TrainActivity;


import static ui.MainActivity.SQLDatabase;
import static ui.MainActivity.portNumber;
import static edu.fiu.adwise.fingerprint_localization.ui.MainActivity.SQLDatabase;
import static edu.fiu.adwise.fingerprint_localization.ui.MainActivity.portNumber;
import edu.fiu.adwise.fingerprint_localization.distance_computation.LOCALIZATION_SCHEME;

import edu.fiu.adwise.homomorphic_encryption.dgk.DGKOperations;
Expand All @@ -30,31 +30,21 @@
import edu.fiu.adwise.homomorphic_encryption.paillier.PaillierPublicKey;
import edu.fiu.adwise.homomorphic_encryption.socialistmillionaire.bob;

public class ClientThread implements Runnable
{
public class ClientThread implements Runnable {
private final static String TAG = "CLIENT_THREAD";

private ObjectOutputStream toServer = null;
private ObjectInputStream fromServer = null;

//Pass Data back to class by reference...
private background findMe;
private TrainActivity trainMe;
private background getColumns;

//Data Objects
private SendTrainingData sendTraining; //Training Data
private SendLocalizationData transmission; //For Encrypted Paillier/DGK Transmission

private SendTrainingData sendTraining;
private SendLocalizationData transmission;
// Have all Keys in case comparison is needed!!
private final DGKPublicKey pubKey = KeyMaster.DGKpk;
private final DGKPrivateKey privKey = KeyMaster.DGKsk;
private final PaillierPublicKey pk = KeyMaster.pk;
private final PaillierPrivateKey sk = KeyMaster.sk;

private final LOCALIZATION_SCHEME LOCALIZATIONSCHEME;
private Socket clientSocket;

// Get all currently trained points
public ClientThread(TrainActivity trainActivity) {
this.LOCALIZATIONSCHEME = LOCALIZATION_SCHEME.from_int(-3);
Expand All @@ -66,8 +56,7 @@ public ClientThread(TrainActivity trainActivity) {
Purpose: Force mySQL Database to process data from
training data.
*/
public ClientThread()
{
public ClientThread() {
this.LOCALIZATIONSCHEME = LOCALIZATION_SCHEME.from_int(-2);
}

Expand All @@ -93,12 +82,11 @@ public ClientThread (SendTrainingData in) {

public void run () {
Object in;
try
{
clientSocket = new Socket(SQLDatabase, portNumber);
// Prepare I/O Stream
this.toServer = new ObjectOutputStream(clientSocket.getOutputStream());
this.fromServer = new ObjectInputStream(clientSocket.getInputStream());
try (
Socket clientSocket = new Socket(SQLDatabase, portNumber);
ObjectOutputStream toServer = new ObjectOutputStream(clientSocket.getOutputStream());
ObjectInputStream fromServer = new ObjectInputStream(clientSocket.getInputStream())
) {
Log.d(TAG, "I/O Streams set!");

switch(LOCALIZATIONSCHEME) {
Expand All @@ -110,16 +98,6 @@ public void run () {
toServer.writeObject(KeyMaster.map_name);
toServer.flush();

// Following this patch the server needs to know the Phone as well
if(MainActivity.multi_phone) {
String [] phone_data = MainActivity.getPhoneData();
for (String s: phone_data) {
Log.d(TAG, s);
}
toServer.writeObject(phone_data);
toServer.flush();
}

in = fromServer.readObject();
if(in instanceof Double []) {
trainMe.existingX = (Double []) in;
Expand Down Expand Up @@ -155,7 +133,6 @@ public void run () {
break;
case GET_COLUMN:
toServer.writeObject("Get Lookup Columns");

// Send the Map with all (x, y)
toServer.writeObject(KeyMaster.map_name);
toServer.flush();
Expand All @@ -179,7 +156,6 @@ public void run () {
MainActivity.bad_train.show();
}
break;

case PLAIN_MIN:
case PLAIN_DMA:
case PLAIN_MCA:
Expand All @@ -189,7 +165,7 @@ public void run () {
case DGK_MIN:
case DGK_MCA:
case DGK_DMA:
localize();
localize(clientSocket, toServer, fromServer);
break;
default:
Log.d(TAG, "Error at Thread run: No Valid Object was sent here");
Expand All @@ -209,7 +185,11 @@ public void run () {
}
}

private void localize() throws IOException, ClassNotFoundException, HomomorphicException {
private void localize(
Socket clientSocket,
ObjectOutputStream toServer,
ObjectInputStream fromServer
) throws IOException, ClassNotFoundException, HomomorphicException {
bob andrew;
BigInteger [] location;
BigInteger divisor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Localization;
package edu.fiu.adwise.fingerprint_localization.localization;

import android.graphics.Bitmap;

Expand Down Expand Up @@ -50,8 +50,7 @@ public static void init() throws HomomorphicException {
finished = true;
}

public void run()
{
public void run() {
try {
init();
} catch (HomomorphicException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Localization;
package edu.fiu.adwise.fingerprint_localization.localization;

import android.graphics.Bitmap;
import android.graphics.Canvas;
Expand All @@ -25,7 +25,7 @@
import edu.fiu.adwise.fingerprint_localization.structs.SendLocalizationData;
import edu.fiu.adwise.fingerprint_localization.structs.LocalizationResult;
import edu.fiu.adwise.homomorphic_encryption.misc.HomomorphicException;
import ui.MainActivity;
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;

import edu.fiu.adwise.homomorphic_encryption.dgk.DGKOperations;
import edu.fiu.adwise.homomorphic_encryption.dgk.DGKPrivateKey;
Expand All @@ -36,7 +36,7 @@

import static android.graphics.Color.RED;
import static edu.fiu.adwise.fingerprint_localization.distance_computation.LOCALIZATION_SCHEME.*;
import static ui.LocalizeActivity.off_map;
import static edu.fiu.adwise.fingerprint_localization.ui.LocalizeActivity.off_map;

public final class background {
private final static String TAG = "LOCALIZE";
Expand All @@ -45,7 +45,6 @@ public final class background {
List<LocalizationResult> fromServer = new ArrayList<>();
Double [] coordinates = new Double[2];
private final LOCALIZATION_SCHEME LOCALIZATION_SCHEME;

//Keys and read Keys
private static final PaillierPublicKey pk = KeyMaster.pk;
private static final DGKPublicKey DGKpk = KeyMaster.DGKpk;
Expand Down Expand Up @@ -197,8 +196,7 @@ private Float[] doInBackground() {
location[1] = fromServer.get(0).getY().floatValue();
}
else {
Phase3();
return location;
return Phase3();
}
publishProgress(10);
}
Expand All @@ -211,8 +209,8 @@ private Float[] doInBackground() {
try {
if(LOCALIZATION_SCHEME == DGK_DMA) {
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
S2[i] = DGKOperations.encrypt(-2 * RSS_send[i], DGKpk);
S3_comp[i] = DGKOperations.encrypt(RSS_send[i] * RSS_send[i], DGKpk);
S2[i] = DGKOperations.encrypt(-2L * RSS_send[i], DGKpk);
S3_comp[i] = DGKOperations.encrypt((long) RSS_send[i] * RSS_send[i], DGKpk);
}
t = new Thread( new ClientThread(
new SendLocalizationData(MAC_send, S2, null, S3_comp,
Expand All @@ -222,8 +220,8 @@ private Float[] doInBackground() {
}
else {
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
S2[i] = DGKOperations.encrypt(-2 * RSS_send[i], DGKpk);
S3_plaintext += RSS_send[i] * RSS_send[i];
S2[i] = DGKOperations.encrypt(-2L * RSS_send[i], DGKpk);
S3_plaintext += (long) RSS_send[i] * RSS_send[i];
}

try {
Expand Down Expand Up @@ -292,8 +290,8 @@ private Float[] doInBackground() {
try {
if(LOCALIZATION_SCHEME == PAILLIER_DMA) {
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
S2[i] = PaillierCipher.encrypt(-2 * RSS_send[i], pk);
S3_comp[i] = PaillierCipher.encrypt(RSS_send[i] * RSS_send[i], pk);
S2[i] = PaillierCipher.encrypt(-2L * RSS_send[i], pk);
S3_comp[i] = PaillierCipher.encrypt((long) RSS_send[i] * RSS_send[i], pk);
}
(t = new Thread(new ClientThread(
new SendLocalizationData(MAC_send, S2, null, S3_comp,
Expand All @@ -304,8 +302,8 @@ private Float[] doInBackground() {
}
else {
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
S2[i] = PaillierCipher.encrypt(-2 * RSS_send[i], pk);
S3_plaintext += RSS_send[i] * RSS_send[i];
S2[i] = PaillierCipher.encrypt(-2L * RSS_send[i], pk);
S3_plaintext += (long) RSS_send[i] * RSS_send[i];
}
S3 = PaillierCipher.encrypt(S3_plaintext, pk);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sensors;
package edu.fiu.adwise.fingerprint_localization.sensors;


import android.Manifest;
Expand All @@ -16,7 +16,7 @@

import java.util.List;

import ui.MainActivity;
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;

import static android.widget.Toast.*;

Expand Down Expand Up @@ -66,8 +66,7 @@ public void unregisterReceiver(Context context) {

// Try this...
// https://stackoverflow.com/questions/13238600/use-registerreceiver-for-non-activity-and-non-service-class
public void onReceive(Context context, Intent intent)
{
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) {
get_data();
Expand Down
Loading