diff --git a/Dockerfile b/Dockerfile index 05688af..029ddc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ RUN brownie networks add LUCE luce host=http://ganache_db:8545 chainid=72 COPY . . +# RUN cd luce_vm/brownie && brownie compile # RUN pip install -e . diff --git a/README.md b/README.md index 2370822..ce7af7e 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,15 @@ ## How to launch LUCE (Debug purpose) -### install docker +### 1. Install docker - [for linux](https://docs.docker.com/desktop/install/linux-install/) - [for mac](https://docs.docker.com/desktop/install/mac-install/) - [for windows](https://docs.docker.com/desktop/install/windows-install/) +### 2. Launch LUCE +To launch LUCE, run: `docker compose up`. + ### database LUCE use PostgresQL to keep user information, just run: diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle index 3cbc503..9a0c94d 100644 Binary files a/docs/build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ diff --git a/luce_vm/js/Dockerfile b/luce_vm/js/Dockerfile index 427fe97..2d0b78a 100644 --- a/luce_vm/js/Dockerfile +++ b/luce_vm/js/Dockerfile @@ -1,14 +1,24 @@ -FROM node:16 - +FROM node:20 WORKDIR /usr/src/js -COPY package*.json ./ +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -RUN npm install +# # Add Rust to PATH +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN git clone https://github.com/iden3/circom.git +RUN cd circom && git checkout tags/v2.1.6 && cargo build --release +RUN cd circom && cargo install --path circom + +# COPY package*.json ./ + +# RUN npm install COPY . . +RUN npm install + EXPOSE 8888 CMD ["node", "src/koa/koa.js"] -# RUN node ./src/koa.js \ No newline at end of file diff --git a/luce_vm/js/package.json b/luce_vm/js/package.json index 8473916..bdae323 100644 --- a/luce_vm/js/package.json +++ b/luce_vm/js/package.json @@ -26,7 +26,7 @@ "koa": "^2.13.0", "koa-router": "12.0.0", "koa-bodyparser": "4.4.0", - "circom_tester": "^0.0.13", + "circom_tester": "^0.0.20", "mocha": "^9.1.3", "chai": "^4.3.4" } diff --git a/luce_vm/js/src/koa/koa.js b/luce_vm/js/src/koa/koa.js index 34c56ac..ce047c8 100644 --- a/luce_vm/js/src/koa/koa.js +++ b/luce_vm/js/src/koa/koa.js @@ -34,8 +34,8 @@ const compute_commitment = async ctx => { const { proof, publicSignals } = await snarkjs.plonk.fullProve(input, wasm, zkey) - // console.log(publicSignals) - // console.log(proof) + console.log(publicSignals) + console.log(proof) const r = { proof: proof, diff --git a/luce_vm/luce_django/luce/accounts/tests/test_Registration.py b/luce_vm/luce_django/luce/accounts/tests/test_Registration.py index fc5e844..11c821c 100644 --- a/luce_vm/luce_django/luce/accounts/tests/test_Registration.py +++ b/luce_vm/luce_django/luce/accounts/tests/test_Registration.py @@ -11,7 +11,7 @@ def test_valid_registration(self): 'email': 'test@email.com', 'password': 'testpassword', } - response = self.client.post(reverse('register'), data) + response = self.client.post(reverse('user_registration'), data) # print("here") # print(response.data) self.assertEqual(response.status_code, 200) # expecting a redirect diff --git a/luce_vm/luce_django/luce/blockchain/models.py b/luce_vm/luce_django/luce/blockchain/models.py index 32cdbe8..1cb7bf7 100644 --- a/luce_vm/luce_django/luce/blockchain/models.py +++ b/luce_vm/luce_django/luce/blockchain/models.py @@ -247,9 +247,11 @@ def retrieve_contract_owner(self): def deploy(self): from brownie.project.BrownieProject import ConsentCode - # private_key = self.user.ethereum_private_key - # new_account = accounts.add(private_key=private_key) - new_account = self.get_a_new_account() + new_account = self.get_a_new_account(amount=1e17) + + print("new_account: " + str(new_account)) + print("new_account: " + str(new_account)) + print("balance: " + str(new_account.balance())) contract = ConsentCode.deploy({'from': new_account}) self.contract_address = contract.address @@ -348,7 +350,7 @@ def get_a_new_account(self): disposable_address_service = DisposableAddressService() user_account = accounts.at(self.user.ethereum_public_key) new_account = disposable_address_service.get_a_new_address_with_balance( - sender=user_account, amount=1e15) + sender=user_account, amount=1e17) # new_account = accounts.add() # accounts[0].transfer(new_account, 1e18) @@ -391,9 +393,8 @@ def deploy(self): # print("proof\n" + str(proof)) print("proof\n" + str(proof['public_signals'])) commitment = { - "public_signals": [ - '16279978653553831575017442062517458639822344791369834134794885970235221444339' - ] + "public_signals": proof['public_signals'] + } contract = LuceMain.deploy(verifier_address, diff --git a/luce_vm/luce_django/luce/healthcare/tests/test_UploadDataView.py b/luce_vm/luce_django/luce/healthcare/tests/test_UploadDataView.py index 14695fc..b6c7c7e 100644 --- a/luce_vm/luce_django/luce/healthcare/tests/test_UploadDataView.py +++ b/luce_vm/luce_django/luce/healthcare/tests/test_UploadDataView.py @@ -58,15 +58,15 @@ def login_user(self, data_login): def test_upload_data_view(self): registration_response = self.register_user(self.data_registration) - print("registration_response", registration_response.data) + # print("registration_response", registration_response.data) user = User.objects.get(email=self.data_registration['email']) self.client.force_authenticate(user=user) deployed_registry = self.deploy_registry() - print("deployed_registry", deployed_registry) + # print("deployed_registry", deployed_registry) response = self.client.post(self.upload_data_url, self.data, format='json') - print("response", response.data) \ No newline at end of file + # print("response", response.data) \ No newline at end of file diff --git a/luce_vm/luce_django/luce/healthcare/views.py b/luce_vm/luce_django/luce/healthcare/views.py index cd18c9b..3596c6f 100644 --- a/luce_vm/luce_django/luce/healthcare/views.py +++ b/luce_vm/luce_django/luce/healthcare/views.py @@ -50,15 +50,16 @@ def is_luce_registry_deployed(self): def get_luce_registry(self): return LuceRegistry.objects.get(pk=1) + def get_disposable_address(self, user_account, amount): + disposable_address_service = DisposableAddressService() + return disposable_address_service.get_a_new_address_with_balance( + user_account, amount) + def post(self, request, format=None): user = request.user estimate = request.data.get("estimate", False) link = request.data.get("link", False) - print("###########") - # print(request.data) - print("request.data:\n", request.data) - logger.info("Upload data from: " + link) if not link: @@ -70,21 +71,18 @@ def post(self, request, format=None): # new_account = self.get_a_new_account() user_account = accounts.at(user.ethereum_public_key) - print("user_account:\n", user_account) + print("User account:\n", user_account) user_balance = user_account.balance() - print("user_balance:\n", user_balance) + print("User balance:\n", user_balance) - disposable_address_service = DisposableAddressService() - new_account = disposable_address_service.get_a_new_address_with_balance( - user_account, 1e15) - # print("new_account:\n", new_account) + new_account = self.get_disposable_address(user_account, 1e15) balance_of_new_account = new_account.balance() - print(f"balance_of_new_account: {balance_of_new_account}") + # print(f"balance_of_new_account: {balance_of_new_account}") user_balance = user_account.balance() - print("user_balance after deposit:\n", user_balance) + # print("user_balance after deposit:\n", user_balance) - user.ethereum_private_key = new_account.private_key + # user.ethereum_private_key = new_account.private_key tx_receipts = [] @@ -107,7 +105,7 @@ def post(self, request, format=None): }, partial=True) - print("serializer:\n", serializer) + # print("serializer:\n", serializer) restriction_serializer = RestrictionsSerializer(data=request.data) # check that user is registered in LuceRegistry, if not register him @@ -133,7 +131,7 @@ def post(self, request, format=None): datacontract = serializer.save() - print("datacontract licence:\n", datacontract.licence) + # print("datacontract licence:\n", datacontract.licence) # print("###########") logger.info("Start to deploy ConsentCode smart contract") tx_receipt = datacontract.consent_contract.deploy() diff --git a/luce_vm/luce_django/luce/lucehome/settings.py b/luce_vm/luce_django/luce/lucehome/settings.py index b09daef..9c920f1 100644 --- a/luce_vm/luce_django/luce/lucehome/settings.py +++ b/luce_vm/luce_django/luce/lucehome/settings.py @@ -19,6 +19,8 @@ brownie_folder = Path(__file__).parent.parent.parent.parent brownie_path = brownie_folder / 'brownie' p = project.load(brownie_path, name="BrownieProject") + +# It seems that we can load config and connect to network at other places. If so, we can remove these two lines p.load_config() network.connect('luce') diff --git a/luce_vm/luce_django/luce/requirements.txt b/luce_vm/luce_django/luce/requirements.txt index 13eb77c..8c3995a 100644 --- a/luce_vm/luce_django/luce/requirements.txt +++ b/luce_vm/luce_django/luce/requirements.txt @@ -1,112 +1,11 @@ -aiohttp==3.8.1 -aiosignal==1.2.0 -async-timeout==4.0.2 -asynctest==0.13.0 -attrdict==2.0.1 -attrs==19.1.0 -backcall==0.1.0 -base58==2.1.1 -bitarray==1.2.2 -bleach==3.1.0 -certifi==2019.6.16 -cffi==1.15.0 -chardet==3.0.4 -charset-normalizer==2.0.11 -cryptography==36.0.1 -cycler==0.11.0 -cytoolz==0.11.2 -decorator==4.4.0 -defusedxml==0.6.0 -Django==2.2 -django-cors-headers==3.11.0 -django-extensions==2.2.1 -django-filter==21.1 -djangorestframework==3.12.4 -entrypoints==0.3 -eth-abi==1.3.0 -eth-account==0.3.0 -# eth-hash==0.2.0 -eth-keyfile==0.5.1 -eth-keys==0.2.4 -eth-rlp==0.1.2 -eth-typing==2.3.0 -eth-utils==1.10.0 -fonttools==4.29.1 -frozenlist==1.3.0 +Brownie==0.5.1 +Django==4.1.12 +djangorestframework==3.14.0 +hexbytes==0.2.3 hexbytes==0.2.0 -idna==2.8 -importlib-metadata==4.10.1 -ipfshttpclient==0.8.0a2 -ipykernel==5.1.1 -ipython==7.6.1 -ipython-genutils==0.2.0 -ipywidgets==7.5.0 -jedi==0.13.3 -Jinja2==2.10.1 -jsonschema==3.2.0 -jupyter==1.0.0 -jupyter-client==5.3.1 -jupyter-console==6.0.0 -jupyter-contrib-core==0.3.3 -jupyter-contrib-nbextensions==0.5.1 -jupyter-core==4.5.0 -jupyter-highlight-selected-word==0.2.0 -jupyter-latex-envs==1.4.4 -jupyter-nbextensions-configurator==0.4.1 -kiwisolver==1.3.2 -lru-dict==1.1.6 -lxml==4.4.0 -MarkupSafe==1.1.1 matplotlib==3.5.1 -mistune==0.8.4 -multiaddr==0.0.9 -multidict==6.0.2 -nbconvert==5.5.0 -nbformat==4.4.0 -netaddr==0.8.0 -notebook==5.7.8 -numpy==1.21.5 -packaging==21.3 -pandocfilters==1.4.2 -parsimonious==0.8.1 -parso==0.5.0 -pexpect==4.7.0 -pickleshare==0.7.5 -Pillow==9.0.1 -prometheus-client==0.7.1 -prompt-toolkit==2.0.9 -protobuf==3.19.4 -psycopg2 -ptyprocess==0.6.0 -py-solc-x==1.1.1 -pycparser==2.21 -pycryptodome==3.8.2 -Pygments==2.4.2 -pyparsing==3.0.7 -pyrsistent==0.14.11 -python-dateutil==2.8.0 -pytz==2019.1 -PyYAML==5.1.1 -pyzmq -qtconsole==4.5.2 -requests==2.22.0 -rlp==1.1.0 -semantic-version==2.8.5 -Send2Trash==1.5.0 -six==1.12.0 -sqlparse==0.3.0 -terminado==0.8.2 -testpath==0.4.2 -toolz==0.10.0 -tornado==6.0.3 -traitlets==4.3.2 -typing-extensions==4.0.1 +py_solc_x==1.1.1 +Requests==2.31.0 +urllib3==1.26.12 +urllib3==1.26.14 urllib3==1.25.3 -varint==1.0.2 -wcwidth==0.1.7 -web3==4.9.2 -webencodings==0.5.1 -websockets==6.0 -widgetsnbextension==3.5.0 -yarl==1.7.2 -zipp==3.7.0