mirror of https://github.com/nucypher/nucypher.git
remove stale demos
parent
e7db1b0881
commit
4bcdf6d37e
|
@ -25,18 +25,12 @@ and adding your provider and wallet details. To set the variables in your curre
|
|||
Optionally, you can change the network the demo is running on by changing the value of `L1_NETWORK` and `L2_NETWORK`.
|
||||
If you change these values be sure to also change `L1_PROVIDER_URI` and `L2_PROVIDER_URI` accordingly.
|
||||
|
||||
Available options for `L1_NETOWKR` are `ibex` or `mainnet`.
|
||||
Available options for `L1_NETWORK` are `ibex` or `mainnet`.
|
||||
Available options for `L2_NETWORK` are `mumbai` or `mainnet`
|
||||
|
||||
To execute the demo run:
|
||||
Ensure Alice's account has a bit of MATIC on polygon to pay for the policy.
|
||||
|
||||
Subsequently, to execute the demo run:
|
||||
`python3 finnegans-wake-demo-l2.py`
|
||||
|
||||
For more detailed logging change the value of `LOG_LEVEL` to `'debug'`.
|
||||
|
||||
### Federated Network Demo
|
||||
|
||||
First run the local federated network:
|
||||
`python ../run_demo_ursula_fleet.py`
|
||||
|
||||
Then run the demo:
|
||||
`python finnegans-wake-demo-federated.py`
|
||||
|
|
|
@ -84,6 +84,7 @@ encrypting_key = bob.public_keys(DecryptingPower)
|
|||
|
||||
# Connect to the ethereum provider.
|
||||
connect_web3_provider(eth_provider_uri=L1_PROVIDER)
|
||||
# Connect to the layer 2 provider.
|
||||
connect_web3_provider(eth_provider_uri=L2_PROVIDER)
|
||||
|
||||
# Setup and unlock alice's ethereum wallet.
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This file is part of nucypher.
|
||||
|
||||
nucypher is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
nucypher is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
from nucypher.characters.lawful import Enrico
|
||||
from nucypher.cli.actions import make_cli_character
|
||||
from nucypher.config.characters import AliceConfiguration
|
||||
from nucypher.crypto.powers import SigningPower
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--plaintext-dir', type=click.STRING, required=True)
|
||||
@click.option('--outfile', type=click.STRING)
|
||||
@click.option('--alice-config', type=click.STRING)
|
||||
@click.option('--label', type=click.STRING, required=True)
|
||||
def mario_box_cli(plaintext_dir, alice_config, label, outfile):
|
||||
|
||||
# Derive Policy Encrypting Key
|
||||
alice_configuration = AliceConfiguration.from_configuration_file(filepath=alice_config)
|
||||
alice = make_cli_character(character_config=alice_configuration)
|
||||
alice_signing_key = alice.public_keys(SigningPower)
|
||||
policy_encrypting_key = alice.get_policy_encrypting_key_from_label(label=label.encode())
|
||||
policy_encrypting_key_hex = bytes(policy_encrypting_key).hex()
|
||||
|
||||
output = list()
|
||||
paths = list(plaintext_dir.iterdir())
|
||||
click.secho(f"Encrypting {len(paths)} files for policy {policy_encrypting_key_hex}", fg='blue')
|
||||
|
||||
with click.progressbar(paths) as bar:
|
||||
for path in bar:
|
||||
filepath = Path(plaintext_dir, path)
|
||||
with open(filepath, 'rb') as file:
|
||||
plaintext = file.read()
|
||||
encoded_plaintext = base64.b64encode(plaintext)
|
||||
|
||||
enrico = Enrico(policy_encrypting_key=policy_encrypting_key)
|
||||
message_kit = enrico.encrypt_message(plaintext=encoded_plaintext)
|
||||
base64_message_kit = base64.b64encode(bytes(message_kit)).decode()
|
||||
|
||||
# Collect Bob Retrieve JSON Requests
|
||||
retrieve_payload = {'label': label,
|
||||
'policy-encrypting-key': policy_encrypting_key_hex,
|
||||
'alice-verifying-key': bytes(alice_signing_key).hex(),
|
||||
'message-kit': base64_message_kit}
|
||||
|
||||
output.append(retrieve_payload)
|
||||
|
||||
if not outfile:
|
||||
outfile = f'{policy_encrypting_key_hex}.json'
|
||||
|
||||
with open(outfile, 'w') as file:
|
||||
file.write(json.dumps(output, indent=2))
|
||||
click.secho(f"Successfully wrote output to {outfile}", fg='green')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mario_box_cli()
|
|
@ -1,199 +0,0 @@
|
|||
{
|
||||
"info": {
|
||||
"_postman_id": "10f6b241-d6e8-4151-9a26-aa466ab76951",
|
||||
"name": "NuCypher",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [{
|
||||
"name": "Alice/derive_policy_pubkey",
|
||||
"event": [{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "04cdbe20-68cd-479b-81a2-b146d614d426",
|
||||
"exec": [
|
||||
"var jsonData = JSON.parse(responseBody);",
|
||||
"console.log(jsonData.result);",
|
||||
"postman.setEnvironmentVariable(\"policy_encrypting_key\", jsonData.result.policy_encrypting_key);"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_uri}}:{{alice_port}}/derive_policy_pubkey/{{label}}",
|
||||
"host": [
|
||||
"{{base_uri}}"
|
||||
],
|
||||
"port": "{{alice_port}}",
|
||||
"path": [
|
||||
"derive_policy_pubkey",
|
||||
"{{label}}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Enrico/encrypt_message",
|
||||
"event": [{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "2771b0c4-3755-47cc-ac35-58105453bf46",
|
||||
"exec": [
|
||||
"var jsonData = JSON.parse(responseBody);",
|
||||
"console.log(jsonData.result);",
|
||||
"postman.setEnvironmentVariable(\"enrico_message_kit\", jsonData.result.message_kit);",
|
||||
"postman.setEnvironmentVariable(\"enrico_signature\", jsonData.result.signature)"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"message\":\"NuVault Rocks\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_uri}}:{{enrico_port}}/encrypt_message",
|
||||
"host": [
|
||||
"{{base_uri}}"
|
||||
],
|
||||
"port": "{{enrico_port}}",
|
||||
"path": [
|
||||
"encrypt_message"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Bob/public_keys",
|
||||
"event": [{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "435cfc59-27a4-4391-8f1b-ae0ba63c36bc",
|
||||
"exec": [
|
||||
"var jsonData = JSON.parse(responseBody);",
|
||||
"console.log(jsonData.result);",
|
||||
"postman.setEnvironmentVariable(\"bob_encrypting_key\", jsonData.result.bob_encrypting_key);",
|
||||
"postman.setEnvironmentVariable(\"bob_verifying_key\", jsonData.result.bob_verifying_key);"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}],
|
||||
"protocolProfileBehavior": {
|
||||
"disableBodyPruning": true
|
||||
},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "\n"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_uri}}:{{bob_port}}/public_keys",
|
||||
"host": [
|
||||
"{{base_uri}}"
|
||||
],
|
||||
"port": "{{bob_port}}",
|
||||
"path": [
|
||||
"public_keys"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Alice/grant",
|
||||
"event": [{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "d5a7dcd3-7eba-4b50-acba-fb106af01426",
|
||||
"exec": [
|
||||
"var jsonData = JSON.parse(responseBody);",
|
||||
"console.log(jsonData.result);",
|
||||
"postman.setEnvironmentVariable(\"alice_treasure_map\", jsonData.result.treasure_map);",
|
||||
"postman.setEnvironmentVariable(\"alice_policy_encrypting_key\", jsonData.result.policy_encrypting_key)",
|
||||
"postman.setEnvironmentVariable(\"alice_verifying_key\", jsonData.result.alice_verifying_key)"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}],
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"header": [{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"bob_verifying_key\": \"{{bob_verifying_key}}\",\n \"bob_encrypting_key\": \"{{bob_encrypting_key}}\",\n \"m\": 1,\n \"n\": 1,\n \"label\": \"{{label}}\",\n \"expiration_time\": \"2019-02-19T12:56:26.976816\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_uri}}:{{alice_port}}/grant",
|
||||
"host": [
|
||||
"{{base_uri}}"
|
||||
],
|
||||
"port": "{{alice_port}}",
|
||||
"path": [
|
||||
"grant"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Bob/retrieve",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [{
|
||||
"key": "Content-Type",
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n\t\"label\": \"{{label}}\",\n\t\"policy_encrypting_key\": \"{{alice_policy_encrypting_key}}\",\n\t\"alice_verifying_key\": \"{{alice_verifying_key}}\",\n\t\"datasource_signing_pubkey\": \"{{enrico_signature}}\",\n\t\"message_kit\": \"{{enrico_message_kit}}\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_uri}}:{{bob_port}}/retrieve",
|
||||
"host": [
|
||||
"{{base_uri}}"
|
||||
],
|
||||
"port": "{{bob_port}}",
|
||||
"path": [
|
||||
"retrieve"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
## Postman collection
|
||||
|
||||
This collection is designed to help in testing the nucypher encryption workflow.
|
||||
Each item is linked to environment variables that are injected into future calls.
|
||||
|
||||
The order to call the collection is as follows
|
||||
|
||||
- Alice/derive_policy_pubkey (create a policy)
|
||||
- Enrico/encrypt_message (encrypt some data inside the policy)
|
||||
- Bob/public_keys (Get Bob's keys so alice can grant him permission)
|
||||
- Alice/grant (Grant bob permission to see the policy's data)
|
||||
- Bob/retrieve (Get alice's data)
|
||||
|
||||
If you try to receive the data before you are granted access you will be returned a 500.
|
|
@ -1,114 +0,0 @@
|
|||
{
|
||||
"id": "578a3d66-560a-4eb8-ba59-db439946f3f4",
|
||||
"name": "dev",
|
||||
"values": [{
|
||||
"key": "label",
|
||||
"value": "ETHDENVER",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "base_uri",
|
||||
"value": "http://localhost",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "alice_port",
|
||||
"value": "8151",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "bob_port",
|
||||
"value": "11151",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "enrico_port",
|
||||
"value": "5151",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "derive_policy_pubkey",
|
||||
"value": "",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "policy_encrypting_key",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "enrico_message_kit",
|
||||
"value": "",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "enrico_signature",
|
||||
"value": "",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "bob_encrypting_key",
|
||||
"value": "",
|
||||
"description": {
|
||||
"content": "",
|
||||
"type": "text/plain"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "bob_verifying_key",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "alice_policy_encrypting_key",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "alice_verifying_key",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "alice_treasure_map",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"_postman_variable_scope": "environment",
|
||||
"_postman_exported_at": "2019-02-18T16:37:46.501Z",
|
||||
"_postman_exported_using": "Postman/6.5.2"
|
||||
}
|
Loading…
Reference in New Issue