Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webinar #27

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions .env.sample

This file was deleted.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ If you want to deploy to the test stores using fastlane, which is the recommende

## Available Scripts

If you are rebuilding the app, you may want to clean the cache and remove the **node_modules** folder:

### `yarn cache clean`

And if you are on Linux, do:

### `rm -rf node_modules`

In the project directory, you can run:

### `yarn start`

Starts the Metro bundler to serve the Javascript code in the development environment.
Starts the Metro bundler to serve the Javascript code in the development environment. Then in a different terminal, run one of the following:

### `yarn run-ios`

Expand Down
Binary file modified android/app/src/main/jniLibs/x86/libzenroom.so
Binary file not shown.
2 changes: 1 addition & 1 deletion ios/Zenroom.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ @implementation Zenroom
size_t errorSize = 1024 * 128;
char *z_error = (char*)malloc(errorSize * sizeof(char));

zenroom_exec_tobuf(c, NULL, k, d, 3, z_output, outputSize, z_error, errorSize);
zenroom_exec_tobuf(c, NULL, k, d, z_output, outputSize, z_error, errorSize);

NSLog(@"output: %s", z_output);
NSLog(@"error: %s", z_error);
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"graceful-fs": "^4.2.4",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-native-dotenv": "^0.2.0",
"react-test-renderer": "16.10.2"
},
"resolutions": {
"graceful-fs": "4.2.4"
},
"jest": {
"preset": "react-native",
"setupFiles": [
Expand Down
11 changes: 11 additions & 0 deletions src/api/zenroom/dp3t/generate-ephids.zen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default () => `
scenario 'dp3t': Decentralized Privacy-Preserving Proximity Tracing
rule check version 1.0.0
rule input encoding hex
rule output encoding hex
Given I have a valid 'secret day key'
and I have a valid number in 'moments'
When I create the ephemeral ids for each moment of the day
and I randomize the 'ephemeral ids' array
Then print the 'ephemeral ids'
`;
10 changes: 10 additions & 0 deletions src/api/zenroom/dp3t/generate-sk1.zen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default () => `
rule check version 1.0.0
rule input encoding hex
rule output encoding hex
Given nothing
When I create the random object of '256' bits
and I rename the 'random object' to 'secret day key'
Then print the 'secret day key'
`;

10 changes: 10 additions & 0 deletions src/api/zenroom/dp3t/generate-sk2.zen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default () => `
scenario 'dp3t': Decentralized Privacy-Preserving Proximity Tracing
rule check version 1.0.0
rule input encoding hex
rule output encoding hex
Given I have a valid 'secret day key'
When I renew the secret day key to a new day
Then print the 'secret day key'
`;

3 changes: 3 additions & 0 deletions src/api/zenroom/dp3t/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export generatesk1 from './generate-sk1.zen';
export generatesk2 from './generate-sk2.zen';
export generateEphids from './generate-ephids.zen';
1 change: 1 addition & 0 deletions src/api/zenroom/webinar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export keypairGen from './keypairGen';
6 changes: 6 additions & 0 deletions src/api/zenroom/webinar/keypairGen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default () => `
Scenario 'ecdh': Create the keypair
Given that I am known as 'Alice'
When I create the keypair
Then print my data
`;
197 changes: 197 additions & 0 deletions src/redux/modules/applications/covid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import { createSelector } from 'reselect';
import { path, prop, append } from 'ramda';
import moment from 'moment';
import uuid from 'uuid/v4';
import { toggle } from 'lib/utils';
import loginApi from 'api/login-client';
import { APPLICATION_ACTIONS } from './actions';
import { debugLog } from 'lib/utils';
import zenroom from 'api/zenroom-client';
import {
generatesk1,
generatesk2,
generateEphids
} from 'api/zenroom/dp3t';

export const initialState = {
loading: false,
loggedIn: false,
selectedAttributes: [],
uses: [],
certificates: {},
error: null,
steps: 2,
step: 1,
sk1: null,
sk2: null,
moments: { moments: '8' },
ephids: null
};


export const ACTIONS = {
SK_SUCCESS: 'SK_SUCCESS',
SK2_GENERATE: 'SK2_GENERATE',
EPHIDS_GENERATE: 'EPHIDS_GENERATE',
LOGIN_REQUEST: 'LOGIN_REQUEST',
LOGIN_SUCCESS: 'LOGIN_SUCCESS',
LOGIN_FAILURE: 'LOGIN_FAILURE',
TOGGLE_SELECTED_ATTRIBUTE: 'TOGGLE_SELECTED_ATTRIBUTE',
CLEANUP_STATE: 'CLEANUP_STATE',
};

export const getGeneratedEphids = (data, key) => async (dispatch) => {

let ephids = null;
if(data && key){
try {
const tmpData = JSON.stringify(data);
const tmpKey = JSON.stringify(key);
ephids = await zenroom.execute(generateEphids(), tmpData, tmpKey);

} catch (e) {
console.log('********** REDUX ACTION getGeneratedEphids error found!');
console.log(e);
}
}

dispatch({
type: ACTIONS.EPHIDS_GENERATE,
ephids
});
}

export const getGeneratedSK2 = (sk1) => async (dispatch) => {
let sk2 = null
if (sk1) {
try {
sk2 = await zenroom.execute(generatesk2(), sk1, '');
} catch (e) {
console.log('********** REDUX ACTION generateSK2 error found!');
console.log(e);
}
}
dispatch({
type: ACTIONS.SK2_GENERATE,
sk2
});

}

export const getGeneratedSK1 = () => async (dispatch) => {
let sk1 = null;
try {
sk1 = await zenroom.execute(generatesk1(), '', '');
} catch (e) {
console.log('********** REDUX ACTION callZenroom error found!');
console.log(e);
}
dispatch({
type: ACTIONS.SK_SUCCESS,
sk1
});
};


const getBranch = path(['applications', 'covid']);

export const getSk1 = createSelector(
getBranch,
prop('sk1'),
);

export const getSk2 = createSelector(
getBranch,
prop('sk2'),
);

export const getMoments = createSelector(
getBranch,
prop('moments'),
);

export const getEphids = createSelector(
getBranch,
prop('ephids'),
);


export default (state = initialState, action) => {
switch (action.type) {
case APPLICATION_ACTIONS.INIT_APPLICATION: {
if (action.id !== 'covidtwo') return state;
return {
...state,
loading: false,
error: null,
loggedIn: false,
step: 1,
};
}
case ACTIONS.LOGIN_REQUEST: {
return {
...state,
loading: true,
error: null,
loggedIn: false,
};
}
case ACTIONS.LOGIN_SUCCESS: {
const { certificate } = action;
const { petitionId = uuid() } = certificate;
const { uses, selectedAttributes, certificates } = state;
return {
...state,
loading: false,
loggedIn: true,
step: 2,
uses: append({
date: +moment(),
sharedData: selectedAttributes,
},
uses),
certificates: {
...certificates,
[petitionId]: certificate,
},
};
}
case ACTIONS.LOGIN_FAILURE: {
return {
...state,
loading: false,
error: action.error,
};
}
case ACTIONS.TOGGLE_SELECTED_ATTRIBUTE: {
const { selectedAttributes } = state;
return {
...state,
selectedAttributes: toggle(action.id, selectedAttributes),
};
}
case ACTIONS.SK_SUCCESS: {
const { sk1 } = action;
return {
...state,
sk1
};
}
case ACTIONS.SK2_GENERATE: {
const { sk2 } = action;
return {
...state,
sk2
};
}
case ACTIONS.EPHIDS_GENERATE: {
const { ephids } = action;
return {
...state,
ephids
};
}
default:
return state;
}
};
3 changes: 3 additions & 0 deletions src/redux/modules/applications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { listApplications, getApplication } from 'api/atlas-client';
import { upperFirst } from 'lib/utils';
import dddc, { initialState as dddcInitialState } from './dddc';
import bcnnow, { initialState as bcnnowInitialState } from './bcnnow';
import covid, { initialState as covidInitialState } from './covid';
import { APPLICATION_ACTIONS } from './actions';

const defaultStats = {
Expand Down Expand Up @@ -191,9 +192,11 @@ export const getProgress = applicationId => createSelector(
export const initialApplicationState = {
dddc: dddcInitialState,
bcnnow: bcnnowInitialState,
covid: covidInitialState,
};

export default combineReducers({
dddc,
bcnnow,
covid,
});
1 change: 1 addition & 0 deletions src/redux/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export * as attributes from './attributes';
export * as applications from './applications';
export * as walkthrough from './walkthrough';
export * as dummy from './dummy';
export * as webinar from './webinar';
Loading