├── .circleci └── config.yml ├── AUTHORS ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── README.rst ├── bbc1 ├── __init__.py └── core │ ├── README.md │ ├── __init__.py │ ├── bbc_app.py │ ├── bbc_config.py │ ├── bbc_core.py │ ├── bbc_error.py │ ├── bbc_network.py │ ├── bbc_stats.py │ ├── bbclib.py │ ├── command.py │ ├── compat │ ├── bbc_app.py │ └── bbclib.py │ ├── data_handler.py │ ├── domain0_manager.py │ ├── key_exchange_manager.py │ ├── logger.py │ ├── message_key_types.py │ ├── query_management.py │ ├── repair_manager.py │ ├── topology_manager.py │ └── user_message_routing.py ├── docker ├── Dockerfile_git ├── Dockerfile_pip ├── README.md ├── docker-bbc1.sh └── entrypoint.sh ├── docs ├── BBc-1_analysis.pdf ├── BBc-1_design_paper.pdf ├── BBc-1_transaction_data_ja.md ├── BBc-trust.pdf ├── BBc-trust_ja.pdf ├── BBc1_consensus_consideration_v1.0_ja.pdf ├── BBc1_core_tutorial_file_proof_ja.md ├── BBc1_core_tutorial_installation_ja.md ├── BBc1_data_format_ja.md ├── BBc1_design_document_v1.0_ja.pdf ├── BBc1_programming_guide_v1.3_ja.md ├── BBc1_pybbclib_programming_guide_v1.4.1_ja.md ├── BBc1_system_design_guide_v1.0_ja.pdf ├── How_BBc1_works_v1.0.2_ja.pdf ├── How_to_use_BBc1_v1.0.2_ja.pdf ├── IDs.md ├── README.md ├── api │ ├── Makefile │ ├── _build │ │ ├── doctrees │ │ │ ├── bbc1.core.bbc_app.doctree │ │ │ ├── bbc1.core.bbc_config.doctree │ │ │ ├── bbc1.core.bbc_core.doctree │ │ │ ├── bbc1.core.bbc_error.doctree │ │ │ ├── bbc1.core.bbc_network.doctree │ │ │ ├── bbc1.core.bbc_stats.doctree │ │ │ ├── bbc1.core.bbclib.doctree │ │ │ ├── bbc1.core.command.doctree │ │ │ ├── bbc1.core.data_handler.doctree │ │ │ ├── bbc1.core.doctree │ │ │ ├── bbc1.core.domain0_manager.doctree │ │ │ ├── bbc1.core.key_exchange_manager.doctree │ │ │ ├── bbc1.core.logger.doctree │ │ │ ├── bbc1.core.message_key_types.doctree │ │ │ ├── bbc1.core.query_management.doctree │ │ │ ├── bbc1.core.repair_manager.doctree │ │ │ ├── bbc1.core.topology_manager.doctree │ │ │ ├── bbc1.core.user_message_routing.doctree │ │ │ ├── bbc1.doctree │ │ │ ├── environment.pickle │ │ │ └── index.doctree │ │ └── html │ │ │ ├── .buildinfo │ │ │ ├── .nojekyll │ │ │ ├── _modules │ │ │ ├── bbc1 │ │ │ │ └── core │ │ │ │ │ ├── bbc_app.html │ │ │ │ │ ├── bbc_config.html │ │ │ │ │ ├── bbc_core.html │ │ │ │ │ ├── bbc_network.html │ │ │ │ │ ├── bbc_stats.html │ │ │ │ │ ├── bbclib.html │ │ │ │ │ ├── command.html │ │ │ │ │ ├── data_handler.html │ │ │ │ │ ├── domain0_manager.html │ │ │ │ │ ├── key_exchange_manager.html │ │ │ │ │ ├── logger.html │ │ │ │ │ ├── message_key_types.html │ │ │ │ │ ├── query_management.html │ │ │ │ │ ├── repair_manager.html │ │ │ │ │ ├── topology_manager.html │ │ │ │ │ └── user_message_routing.html │ │ │ └── index.html │ │ │ ├── _sources │ │ │ ├── bbc1.core.bbc_app.rst.txt │ │ │ ├── bbc1.core.bbc_config.rst.txt │ │ │ ├── bbc1.core.bbc_core.rst.txt │ │ │ ├── bbc1.core.bbc_error.rst.txt │ │ │ ├── bbc1.core.bbc_network.rst.txt │ │ │ ├── bbc1.core.bbc_stats.rst.txt │ │ │ ├── bbc1.core.bbclib.rst.txt │ │ │ ├── bbc1.core.command.rst.txt │ │ │ ├── bbc1.core.data_handler.rst.txt │ │ │ ├── bbc1.core.domain0_manager.rst.txt │ │ │ ├── bbc1.core.key_exchange_manager.rst.txt │ │ │ ├── bbc1.core.logger.rst.txt │ │ │ ├── bbc1.core.message_key_types.rst.txt │ │ │ ├── bbc1.core.query_management.rst.txt │ │ │ ├── bbc1.core.repair_manager.rst.txt │ │ │ ├── bbc1.core.rst.txt │ │ │ ├── bbc1.core.topology_manager.rst.txt │ │ │ ├── bbc1.core.user_message_routing.rst.txt │ │ │ ├── bbc1.rst.txt │ │ │ └── index.rst.txt │ │ │ ├── _static │ │ │ ├── basic.css │ │ │ ├── css │ │ │ │ ├── badge_only.css │ │ │ │ └── theme.css │ │ │ ├── doctools.js │ │ │ ├── documentation_options.js │ │ │ ├── file.png │ │ │ ├── fonts │ │ │ │ ├── Inconsolata-Bold.ttf │ │ │ │ ├── Inconsolata-Regular.ttf │ │ │ │ ├── Inconsolata.ttf │ │ │ │ ├── Lato-Bold.ttf │ │ │ │ ├── Lato-Regular.ttf │ │ │ │ ├── Lato │ │ │ │ │ ├── lato-bold.eot │ │ │ │ │ ├── lato-bold.ttf │ │ │ │ │ ├── lato-bold.woff │ │ │ │ │ ├── lato-bold.woff2 │ │ │ │ │ ├── lato-bolditalic.eot │ │ │ │ │ ├── lato-bolditalic.ttf │ │ │ │ │ ├── lato-bolditalic.woff │ │ │ │ │ ├── lato-bolditalic.woff2 │ │ │ │ │ ├── lato-italic.eot │ │ │ │ │ ├── lato-italic.ttf │ │ │ │ │ ├── lato-italic.woff │ │ │ │ │ ├── lato-italic.woff2 │ │ │ │ │ ├── lato-regular.eot │ │ │ │ │ ├── lato-regular.ttf │ │ │ │ │ ├── lato-regular.woff │ │ │ │ │ └── lato-regular.woff2 │ │ │ │ ├── RobotoSlab-Bold.ttf │ │ │ │ ├── RobotoSlab-Regular.ttf │ │ │ │ ├── RobotoSlab │ │ │ │ │ ├── roboto-slab-v7-bold.eot │ │ │ │ │ ├── roboto-slab-v7-bold.ttf │ │ │ │ │ ├── roboto-slab-v7-bold.woff │ │ │ │ │ ├── roboto-slab-v7-bold.woff2 │ │ │ │ │ ├── roboto-slab-v7-regular.eot │ │ │ │ │ ├── roboto-slab-v7-regular.ttf │ │ │ │ │ ├── roboto-slab-v7-regular.woff │ │ │ │ │ └── roboto-slab-v7-regular.woff2 │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ ├── jquery-3.2.1.js │ │ │ ├── jquery.js │ │ │ ├── js │ │ │ │ ├── modernizr.min.js │ │ │ │ └── theme.js │ │ │ ├── language_data.js │ │ │ ├── minus.png │ │ │ ├── plus.png │ │ │ ├── pygments.css │ │ │ ├── searchtools.js │ │ │ ├── underscore-1.3.1.js │ │ │ └── underscore.js │ │ │ ├── bbc1.core.bbc_app.html │ │ │ ├── bbc1.core.bbc_config.html │ │ │ ├── bbc1.core.bbc_core.html │ │ │ ├── bbc1.core.bbc_error.html │ │ │ ├── bbc1.core.bbc_network.html │ │ │ ├── bbc1.core.bbc_stats.html │ │ │ ├── bbc1.core.bbclib.html │ │ │ ├── bbc1.core.command.html │ │ │ ├── bbc1.core.data_handler.html │ │ │ ├── bbc1.core.domain0_manager.html │ │ │ ├── bbc1.core.html │ │ │ ├── bbc1.core.key_exchange_manager.html │ │ │ ├── bbc1.core.logger.html │ │ │ ├── bbc1.core.message_key_types.html │ │ │ ├── bbc1.core.query_management.html │ │ │ ├── bbc1.core.repair_manager.html │ │ │ ├── bbc1.core.topology_manager.html │ │ │ ├── bbc1.core.user_message_routing.html │ │ │ ├── bbc1.html │ │ │ ├── genindex.html │ │ │ ├── index.html │ │ │ ├── objects.inv │ │ │ ├── py-modindex.html │ │ │ ├── search.html │ │ │ └── searchindex.js │ ├── bbc1.core.bbc_app.rst │ ├── bbc1.core.bbc_config.rst │ ├── bbc1.core.bbc_core.rst │ ├── bbc1.core.bbc_error.rst │ ├── bbc1.core.bbc_network.rst │ ├── bbc1.core.bbc_stats.rst │ ├── bbc1.core.bbclib.rst │ ├── bbc1.core.command.rst │ ├── bbc1.core.data_handler.rst │ ├── bbc1.core.domain0_manager.rst │ ├── bbc1.core.key_exchange_manager.rst │ ├── bbc1.core.logger.rst │ ├── bbc1.core.message_key_types.rst │ ├── bbc1.core.query_management.rst │ ├── bbc1.core.repair_manager.rst │ ├── bbc1.core.rst │ ├── bbc1.core.topology_manager.rst │ ├── bbc1.core.user_message_routing.rst │ ├── bbc1.rst │ ├── conf.py │ ├── index.rst │ └── make.bat ├── how_to_use_in_nat_environment.md ├── images │ └── BBc1_format.png └── libbbcsig_dll_build_for_Windows_x64_ja.md ├── examples ├── README.md ├── file_proof │ ├── README.md │ └── file_proof.py └── starter │ ├── README.md │ ├── requirements.txt │ ├── scripts │ ├── create_userid_keypair.py │ ├── print_transaction.py │ ├── register_a_transaction.py │ ├── run_script.sh │ └── show_transactions.py │ └── starter.sh ├── prepare-apidoc.sh ├── prepare.py ├── renovate.json ├── requirements.txt ├── setup.py ├── tests ├── compat │ ├── test_bbc_app_multi_core_compat.py │ ├── test_bbc_app_multi_core_many_transactions_bson.py │ ├── test_bbc_app_multiclient_traverse_bson.py │ ├── test_bbclib_bson.py │ ├── test_bbclib_compat.py │ └── testutils.py ├── pytest.ini ├── sample_config.json ├── test_bbc_app.py ├── test_bbc_app_admin_tools.py ├── test_bbc_app_domain_setup.py ├── test_bbc_app_encryption.py ├── test_bbc_app_multi_core.py ├── test_bbc_app_multi_core_anycast.py ├── test_bbc_app_multi_core_compromising_data.py ├── test_bbc_app_multi_core_many_transactions.py ├── test_bbc_app_multi_core_notification.py ├── test_bbc_app_multi_core_notification_with_cancelation.py ├── test_bbc_app_multi_core_notification_with_disconnection.py ├── test_bbc_app_multiclient.py ├── test_bbc_app_multiclient_traverse.py ├── test_bbc_app_search_with_timestamp.py ├── test_bbc_config.py ├── test_bbc_core.py ├── test_bbc_domain_config.py ├── test_bbc_network.py ├── test_bbc_network_encryption.py ├── test_bbc_network_encryption_domain_key.py ├── test_bbc_ping.py ├── test_bbc_stats.py ├── test_cross_ref.py ├── test_cross_ref_multi_domain0nodes.py ├── test_data_handler_mysql.py ├── test_data_handler_sqlite.py ├── test_domain_info_adv.py ├── test_fileproof_multi_core.py ├── test_key_exchange_manager.py ├── test_message_key_types.py ├── test_msg_serializer.py ├── test_pending_request.py ├── test_user_message_routing.py └── testutils.py └── utils ├── README.md ├── bbc_domain_config.py ├── bbc_domain_update.py ├── bbc_info.py ├── bbc_ping.py ├── db_migration_tool.py ├── domain_key_setup.py └── id_create.py /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | workflows: 3 | build_and_deploy: 4 | jobs: 5 | - test: 6 | filters: 7 | tags: 8 | only: /.*/ 9 | - deploy: 10 | requires: 11 | - test 12 | filters: 13 | tags: 14 | only: /^v.*/ 15 | branches: 16 | ignore: /.*/ 17 | jobs: 18 | test: 19 | docker: 20 | - image: circleci/python:3.9 21 | steps: 22 | - checkout 23 | - run: 24 | name: install python dependencies 25 | command: | 26 | python3 -m venv venv 27 | . venv/bin/activate 28 | pip install -r requirements.txt 29 | - run: 30 | name: Perform test 31 | command: | 32 | . venv/bin/activate 33 | cd tests 34 | pytest test_bbc_app.py 35 | pytest test_bbc_app_multi_core.py 36 | pytest test_bbc_app_multi_core_many_transactions.py 37 | pytest test_bbc_app_multi_core_notification_with_cancelation.py 38 | pytest test_bbc_app_multi_core_notification_with_disconnection.py 39 | pytest test_bbc_app_multiclient.py 40 | pytest test_bbc_app_multiclient_traverse.py 41 | pytest test_bbc_app_admin_tools.py 42 | pytest test_bbc_app_multi_core_compromising_data.py 43 | pytest test_bbc_app_multi_core_anycast.py 44 | pytest test_domain_info_adv.py 45 | pytest test_fileproof_multi_core.py 46 | pytest test_bbc_config.py 47 | pytest test_user_message_routing.py 48 | pytest test_bbc_core.py 49 | pytest test_bbc_network.py 50 | pytest test_bbc_network_encryption.py 51 | pytest test_data_handler_sqlite.py 52 | pytest test_key_exchange_manager.py 53 | pytest test_pending_request.py 54 | pytest test_bbc_ping.py 55 | pytest test_bbc_stats.py 56 | - save_cache: 57 | key: v1-dependency-cache-{{ checksum "setup.py" }} 58 | paths: 59 | - "venv" 60 | deploy: 61 | docker: 62 | - image: circleci/python:3.9 63 | steps: 64 | - checkout 65 | - restore_cache: 66 | key: v1-dependency-cache-{{ checksum "setup.py" }} 67 | - run: 68 | name: verify version 69 | command: | 70 | . venv/bin/activate 71 | python setup.py verify 72 | - run: 73 | name: init .pypirc 74 | command: | 75 | echo -e "[pypi]" >> ~/.pypirc 76 | echo -e "username = __token__" >> ~/.pypirc 77 | echo -e "password = $PYPI_TOKEN" >> ~/.pypirc 78 | - run: 79 | name: deploy in PyPI 80 | command: | 81 | . venv/bin/activate 82 | pip install wheel twine 83 | rm -rf dist/ bbc1.egg-info/ 84 | python setup.py sdist 85 | python setup.py bdist_wheel 86 | twine upload --repository pypi dist/* 87 | - save_cache: 88 | key: v1-dependency-cache-{{ checksum "setup.py" }} 89 | paths: 90 | - "venv" 91 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | BBc-1 was originally created in late 2017 by Beyond Blockchain Inc. in Tokyo, Japan. 2 | 3 | Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS -- 4 | people who have submitted patches, reported bugs, added translations, helped 5 | answer newbie questions, and generally made BBc-1 that much better: 6 | 7 | Takeshi Kubo 8 | Kenji Saito 9 | Michihito Kato 10 | Ryosuke Abe 11 | Jun Kurihara 12 | Takeshi Hashimoto 13 | kichinosukey 14 | houeda 15 | Kazuki Watanabe 16 | Atsushi Ota 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change log 2 | ====== 3 | 4 | ## v1.5.1 5 | * Fix problem regarding new version of gevent 6 | * Fix codes in deprecated usage 7 | 8 | ## v1.5 9 | * Support BBcAssetRaw and BBcAssetHash defined in py-bbclib v1.5 or later 10 | * bug fix 11 | 12 | ## v1.4 13 | * Decouple bbclib from bbc1/core 14 | * import py-bbclib 15 | * Skip signature verification if no public key included in BBcSignature 16 | 17 | ## v1.3 18 | * Support timestamp-based transaction search 19 | * search_transaction_with_condition() method in bbc_app.py is upgraded to include start\_from and until params 20 | * DB meta table (asset_info_table) is upgraded (timestamp column is added) 21 | * Migration tool is implemented (utils/db_migration_tool.py) 22 | * Add a new step-by-step style example in github (examples/starter) 23 | * Bug fixes 24 | 25 | ## v1.2 26 | * Re-design and refactor bbclib.py 27 | * serializing transaction object consists of packing object into binary and serializing it into wire format. (new format types are 0x0000 and 0x0010) 28 | 29 | ## v1.1.1 30 | * Fix bug on installation with pip in Linux environment 31 | 32 | ## v1.1 33 | * ID truncation (ID length less than 256-bit) support 34 | * X509 certificate for public key 35 | * KeyPair class in bbclib.py can receive X509 self-signed certificate 36 | * ECC Prime-256 v1 support for private/public key 37 | * libbbcsig is decoupled to https://github.com/beyond-blockchain/libbbcsig 38 | * default config is introduced 39 | * search count upper limit is configurable 40 | * Extend transaction search functions (#94) 41 | * Bug fixes 42 | 43 | ## v1.0.1 44 | * Bug fixes 45 | * pip install bug is fixed but pipenv install still has some troubles. 46 | * Bug of serialization/deserialization of BBcSignature in some cases is fixed 47 | 48 | ## v1.0 49 | * Restructure the whole package 50 | * Only bbc1/core/ remains 51 | * Ledger_subsystem related codes and libraries are separated into other repositories 52 | * Support BSON (binary JSON) format for transaction data structure 53 | * Documents are updated 54 | * Utilities are re-designed 55 | * Bug fixes 56 | 57 | ## v0.10 58 | * The core part is totally re-designed 59 | * user_message_routing.py, data_handler.py, topology_manager.py, key_exchange_manager.py, key_exchange_manager.py are newley added 60 | * inter-nodes and core-app communications are secured by AES256 encryption 61 | * Implement domain/node key verification for administrative messages 62 | * Scheme for recovery of forged transaction data is modified 63 | * A user (bbc_app) explicitly triggers the recovery when it obtains forged transaction data 64 | * Anycast support 65 | * Add currency library (token_lib) 66 | * Add a new search method to obtain series of transaction data 67 | * Cross_ref support 68 | 69 | ## v0.9.1 70 | * Add libraries for token and id management 71 | 72 | ## v0.9 73 | * Change APIs in bbc_app.py (remove asset_group_id options) 74 | * Modify schemas of bbc_ledger tables 75 | * Introduce BBcRelation/BBcPointer/BBcWitness class as parts of BBcTransaction 76 | * Fix several bugs 77 | 78 | ## v0.8.2 79 | * Eliminate the concept of "registering asset_group_id" to bbc_core 80 | * Unlimit the size of BBcAsset body 81 | * Default off for ledger_subsystem ('use_ledger_subsystem' item is introduced in config.json) 82 | * Fix several bugs 83 | 84 | ## v0.8.1 85 | * IPv6 support 86 | * Fix several bugs 87 | 88 | ## v0.8 89 | * Implement system statistics API #8 90 | * Notification of transaction insertion is implemented #9 91 | * NAT traversal support (only for simple port forwarding) #11 92 | * user_id based transaction search #16 93 | * Windows support for libbbcsig library 94 | 95 | ## v0.7.4 96 | * Fix issues regarding ledger_subsystem #26, #27 97 | * Refactor ledger_subsystem 98 | * Fix populus version in requrements.txt 99 | 100 | ## v0.7.3 101 | * Fix issues regarding installation #17, #21 102 | * Modify sign/verify scheme in bbclib.py internally and add read function for PEM format key 103 | * Remove unnecessary python module from requirements.txt 104 | 105 | ## v0.7.2 106 | * Use OpenSSL for signing/verifying a transaction 107 | 108 | ## v0.7.1 109 | * Bug fix 110 | - TCP message wait loop in bbc_network.py 111 | 112 | ## v0.7 113 | Initial version 114 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | 19 | ## Code of Conduct 20 | 21 | ### Our Pledge 22 | 23 | In the interest of fostering an open and welcoming environment, we as 24 | contributors and maintainers pledge to making participation in our project and 25 | our community a harassment-free experience for everyone, regardless of age, body 26 | size, disability, ethnicity, gender identity and expression, level of experience, 27 | nationality, personal appearance, race, religion, or sexual identity and 28 | orientation. 29 | 30 | ### Our Standards 31 | 32 | Examples of behavior that contributes to creating a positive environment 33 | include: 34 | 35 | * Using welcoming and inclusive language 36 | * Being respectful of differing viewpoints and experiences 37 | * Gracefully accepting constructive criticism 38 | * Focusing on what is best for the community 39 | * Showing empathy towards other community members 40 | 41 | Examples of unacceptable behavior by participants include: 42 | 43 | * The use of sexualized language or imagery and unwelcome sexual attention or 44 | advances 45 | * Trolling, insulting/derogatory comments, and personal or political attacks 46 | * Public or private harassment 47 | * Publishing others' private information, such as a physical or electronic 48 | address, without explicit permission 49 | * Other conduct which could reasonably be considered inappropriate in a 50 | professional setting 51 | 52 | ### Our Responsibilities 53 | 54 | Project maintainers are responsible for clarifying the standards of acceptable 55 | behavior and are expected to take appropriate and fair corrective action in 56 | response to any instances of unacceptable behavior. 57 | 58 | Project maintainers have the right and responsibility to remove, edit, or 59 | reject comments, commits, code, wiki edits, issues, and other contributions 60 | that are not aligned to this Code of Conduct, or to ban temporarily or 61 | permanently any contributor for other behaviors that they deem inappropriate, 62 | threatening, offensive, or harmful. 63 | 64 | ### Scope 65 | 66 | This Code of Conduct applies both within project spaces and in public spaces 67 | when an individual is representing the project or its community. Examples of 68 | representing a project or community include using an official project e-mail 69 | address, posting via an official social media account, or acting as an appointed 70 | representative at an online or offline event. Representation of a project may be 71 | further defined and clarified by project maintainers. 72 | 73 | ### Enforcement 74 | 75 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 76 | reported by contacting the project team at office@beyond-blockchain.org. All 77 | complaints will be reviewed and investigated and will result in a response that 78 | is deemed necessary and appropriate to the circumstances. The project team is 79 | obligated to maintain confidentiality with regard to the reporter of an incident. 80 | Further details of specific enforcement policies may be posted separately. 81 | 82 | Project maintainers who do not follow or enforce the Code of Conduct in good 83 | faith may face temporary or permanent repercussions as determined by other 84 | members of the project's leadership. 85 | 86 | ### Attribution 87 | 88 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 89 | available at [http://contributor-covenant.org/version/1/4][version] 90 | 91 | [homepage]: http://contributor-covenant.org 92 | [version]: http://contributor-covenant.org/version/1/4/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 beyond-blockchain.org. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include INSTALL 3 | include LICENSE 4 | include LICENSE.python 5 | include MANIFEST.in 6 | include package.json 7 | include *.rst 8 | include prepare.py 9 | graft scripts 10 | prune tests 11 | prune docs 12 | global-exclude __pycache__ 13 | global-exclude *.py[co] 14 | -------------------------------------------------------------------------------- /bbc1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/bbc1/__init__.py -------------------------------------------------------------------------------- /bbc1/core/README.md: -------------------------------------------------------------------------------- 1 | The core of BBc-1 2 | ================= 3 | The files in this directory is the main codes of BBc-1. 4 | 5 | ## BBc core codes 6 | * bbc_core.py 7 | - The core of BBc-1 that processes transaction and communicates with applications (e.g., bbc_app) 8 | - The messages between BBcAppClient and BBcCoreService (in bbc_core.py) depends on [pickle](https://docs.python.org/3.6/library/pickle.html#module-pickle), data serialization tool in Python, because this project shows a reference of the implementation of BBc-1 and the concrete implementation of messaging is fully left to developers. The important thing here is *what function of bbc_core the application can use*. Therefore, the reference use pickle to show it simply. (Of course, the reference implementation will work fine.) 9 | * bbc_app.py 10 | - Base interface for BBc-1 application 11 | - bbc_app connects to bbc_core to send/receive messages 12 | - All applications and management tools are based on it 13 | * bbc_network.py 14 | - Communication management between other bbc_core nodes 15 | - BBcNetwork provides an interface to BBcCoreService to encapsulate the network layer functions, such as P2P topology management and message forwarding. 16 | - DomainBase class is a base class for networking functions. By overriding it, any kind of networking layer can be implemented. This project includes a simple networking function with full-mesh topology (see [Network module below](#nwmodule)). 17 | * data_handler.py 18 | - Database manipulation for storing/searching transaction data, asset IDs, etc.. 19 | - An auxiliary database is also managed here. It manages various useful information regarding transactions to improve efficiency of processing transactions. 20 | - Asset file management 21 | * topology_manager.py 22 | - Neighbor node management for each domain 23 | * user_message_routing.py 24 | - Message routing among users 25 | * repair_manager.py 26 | - Perform forged data recovery when client application gives it a trigger 27 | * domain0_manager.py 28 | - Processing cross_ref messages among domain_global_0 nodes, meaning that it works as a gateway node for a 29 | cross_ref messages 30 | 31 | ## Others 32 | * query_management.py 33 | - Utility classes for managing timer operation such as message retransmission 34 | - Ticker class is a simple scheduler that counts the present time and fires the callback method if a timer object expires. 35 | - QueryEntry class is for a single timer object. It can hold some callbacks and parameter data for the callbacks. 36 | * key_exchange_manager.py 37 | - Secret key exchange manager using ECDH 38 | - Keys are used for securing communication channel between core nodes, and between core node and bbc_app client 39 | * bbc_config.py 40 | - Configuration management 41 | - A BBcConfig object creates and a read config file and the object is shared among BBcXXX objects. 42 | * bbc_stats.py 43 | - Manage statistics information of bbc_core 44 | * command.py 45 | - Argument parser of bbc_core.py 46 | -------------------------------------------------------------------------------- /bbc1/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/bbc1/core/__init__.py -------------------------------------------------------------------------------- /bbc1/core/bbc_error.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2017 beyond-blockchain.org. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | ESUCCESS = 0 19 | EINVALID_COMMAND = -1 20 | ENODESTINATION = -2 21 | EUNAUTHORIZED_COMMAND = -3 22 | ENOSUBSYSTEM = -4 23 | 24 | ENOASSET = -11 25 | EBADASSETDIGEST = -12 26 | EASSET_INSERT = -13 27 | ENOTRANSACTION = -14 28 | EBADTRANSACTION = -15 29 | EBADTXDIGEST = -16 30 | EBADTXSIGNATURE = -17 31 | ELEDGER_INSERT = -18 32 | ESTORAGE_PUT = -19 33 | ENOTINSTORAGE = -20 34 | 35 | EBADKEYPAIR = -30 36 | EBADSIGNNUMBER = -31 37 | 38 | 39 | 40 | EOTHER = -255 41 | -------------------------------------------------------------------------------- /bbc1/core/bbc_stats.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2017 beyond-blockchain.org. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | 19 | class BBcStats: 20 | def __init__(self): 21 | self.statistics = dict() 22 | 23 | def clear_stats(self): 24 | self.statistics = dict() 25 | 26 | def remove_stat_item(self, category, name): 27 | if category not in self.statistics: 28 | return 29 | self.statistics[category].pop(name, None) 30 | 31 | def remove_stat_category(self, category): 32 | self.statistics.pop(category, None) 33 | 34 | def update_stats(self, category, name, value): 35 | self.statistics.setdefault(category, dict())[name] = value 36 | 37 | def update_stats_increment(self, category, name, value): 38 | self.statistics.setdefault(category, dict()).setdefault(name, 0) 39 | self.statistics[category][name] += value 40 | 41 | def update_stats_decrement(self, category, name, value): 42 | self.statistics.setdefault(category, dict()).setdefault(name, 0) 43 | self.statistics[category][name] -= value 44 | 45 | def get_stats(self): 46 | return self.statistics 47 | -------------------------------------------------------------------------------- /bbc1/core/bbclib.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2017 beyond-blockchain.org. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | 18 | import binascii 19 | import bbc1.core.bbc_error as bbc_error 20 | 21 | 22 | domain_global_0 = binascii.a2b_hex("0000000000000000000000000000000000000000000000000000000000000000") 23 | 24 | error_code = -1 25 | error_text = "" 26 | 27 | 28 | import bbclib.libs.bbclib_keypair as bbclib_keypair 29 | import bbclib.libs.bbclib_binary as bbclib_binary 30 | import bbclib.libs.bbclib_utils as bbclib_utils 31 | import bbclib.libs.bbclib_transaction as bbclib_transaction 32 | import bbclib.libs.bbclib_signature as bbclib_signature 33 | import bbclib.libs.bbclib_asset as bbclib_asset 34 | import bbclib.libs.bbclib_asset_raw as bbclib_asset_raw 35 | import bbclib.libs.bbclib_asset_hash as bbclib_asset_hash 36 | import bbclib.libs.bbclib_crossref as bbclib_crossref 37 | import bbclib.libs.bbclib_event as bbclib_event 38 | import bbclib.libs.bbclib_msgtype as bbclib_msgtype 39 | import bbclib.libs.bbclib_pointer as bbclib_pointer 40 | import bbclib.libs.bbclib_relation as bbclib_relation 41 | import bbclib.libs.bbclib_reference as bbclib_reference 42 | import bbclib.libs.bbclib_witness as bbclib_witness 43 | import bbclib.compat.bbclib as bbclib_compat 44 | import bbclib.libs.bbclib_wire as bbclib_wire 45 | import bbclib 46 | 47 | 48 | def _set_error(code=-1, txt=""): 49 | global error_code 50 | global error_text 51 | error_code = code 52 | error_text = txt 53 | 54 | 55 | def _reset_error(): 56 | global error_code 57 | global error_text 58 | error_code = bbc_error.ESUCCESS 59 | error_text = "" 60 | 61 | 62 | # ---- 63 | # Codes below are for backward compatibility with v1.1.x or earlier 64 | # These codes will be removed in the future. 65 | 66 | DEFAULT_CURVETYPE = bbclib_signature.DEFAULT_CURVETYPE 67 | 68 | get_new_id = bbclib_utils.get_new_id 69 | get_random_id = bbclib_utils.get_random_id 70 | get_random_value = bbclib_binary.get_random_value 71 | convert_id_to_string = bbclib_utils.convert_id_to_string 72 | convert_idstring_to_bytes = bbclib_utils.convert_idstring_to_bytes 73 | deep_copy_with_key_stringify = bbclib_utils.deep_copy_with_key_stringify 74 | make_transaction = bbclib_utils.make_transaction 75 | add_relation_asset = bbclib_utils.add_relation_asset 76 | add_relation_asset_raw = bbclib_utils.add_relation_asset_raw 77 | add_relation_asset_hash = bbclib_utils.add_relation_asset_hash 78 | add_relation_pointer = bbclib_utils.add_relation_pointer 79 | add_reference_to_transaction = bbclib_utils.add_reference_to_transaction 80 | add_event_asset = bbclib_utils.add_event_asset 81 | make_relation_with_asset = bbclib_utils.make_relation_with_asset 82 | make_relation_with_asset_raw = bbclib_utils.make_relation_with_asset_raw 83 | make_relation_with_asset_hash = bbclib_utils.make_relation_with_asset_hash 84 | add_pointer_in_relation = bbclib_utils.add_pointer_in_relation 85 | recover_signature_object = bbclib_utils.recover_signature_object 86 | validate_transaction_object = bbclib_utils.validate_transaction_object 87 | verify_using_cross_ref = bbclib_utils.verify_using_cross_ref 88 | 89 | serialize = bbclib.serialize 90 | deserialize = bbclib.deserialize 91 | 92 | KeyType = bbclib_keypair.KeyType 93 | MsgType = bbclib_msgtype.MsgType 94 | 95 | BBcFormat = bbclib_compat.BBcFormat 96 | 97 | KeyPair = bbclib_keypair.KeyPair 98 | BBcSignature = bbclib_signature.BBcSignature 99 | BBcTransaction = bbclib_transaction.BBcTransaction 100 | BBcEvent = bbclib_event.BBcEvent 101 | BBcReference = bbclib_reference.BBcReference 102 | BBcRelation = bbclib_relation.BBcRelation 103 | BBcPointer = bbclib_pointer.BBcPointer 104 | BBcWitness = bbclib_witness.BBcWitness 105 | BBcAsset = bbclib_asset.BBcAsset 106 | BBcCrossRef = bbclib_crossref.BBcCrossRef 107 | 108 | -------------------------------------------------------------------------------- /bbc1/core/command.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2017 beyond-blockchain.org. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | from argparse import ArgumentParser 18 | import sys 19 | sys.path.extend(["../../"]) 20 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT, DEFAULT_P2P_PORT 21 | 22 | 23 | DEFAULT_SERV_ADDR = '127.0.0.1' 24 | 25 | 26 | def parser(): 27 | usage = 'python {} [--coreport ] [--p2pport ] [--workingdir ] ' \ 28 | '[--config ] [--default_config ] [--nodekey] [--no_nodekey] [--domain0] ' \ 29 | '[--ledgersubsystem] [--ip4addr ] [--ip6addr ] ' \ 30 | '[--log ] [--verbose_level ] [--daemon] [--kill] [--help]'.format(__file__) 31 | argparser = ArgumentParser(usage=usage) 32 | argparser.add_argument('-cp', '--coreport', type=int, default=DEFAULT_CORE_PORT, help='waiting TCP port') 33 | argparser.add_argument('-pp', '--p2pport', type=int, default=DEFAULT_P2P_PORT, help='waiting TCP port') 34 | argparser.add_argument('-w', '--workingdir', type=str, default=".bbc1", help='working directory name') 35 | argparser.add_argument('-c', '--config', type=str, default=None, help='config file name') 36 | argparser.add_argument('--default_config', type=str, default=None, help='default config file') 37 | argparser.add_argument('--nodekey', action='store_true', help='use node_key for admin command') 38 | argparser.add_argument('--no_nodekey', action='store_true', help='don\'t use node_key for admin command') 39 | argparser.add_argument('--domain0', action='store_true', help='connect to domain_global_0') 40 | argparser.add_argument('--ledgersubsystem', action='store_true', help='use ledger_subsystem') 41 | argparser.add_argument('--ip4addr', type=str, default=None, help='IPv4 address exposed to the external network') 42 | argparser.add_argument('--ip6addr', type=str, default=None, help='IPv6 address exposed to the external network') 43 | argparser.add_argument('-l', '--log', type=str, default="-", help='log filename/"-" means STDOUT') 44 | argparser.add_argument('-d', '--daemon', action='store_true', help='run in background') 45 | argparser.add_argument('-k', '--kill', action='store_true', help='kill the daemon') 46 | argparser.add_argument('-v', '--verbose_level', type=str, default="debug", 47 | help='log level all/debug/info/warning/error/critical/none') 48 | args = argparser.parse_args() 49 | return args 50 | -------------------------------------------------------------------------------- /bbc1/core/logger.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2017 beyond-blockchain.org. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | """ 17 | import logging 18 | 19 | 20 | def get_logger(key="", logname="-", level="none"): 21 | 22 | LEVELS = { 'all': logging.NOTSET, 23 | 'debug':logging.DEBUG, 24 | 'info':logging.INFO, 25 | 'warning':logging.WARNING, 26 | 'error':logging.ERROR, 27 | 'critical':logging.CRITICAL, 28 | 'none': 99, 29 | } 30 | 31 | if logname == "-": 32 | logname = None 33 | 34 | logging.basicConfig( 35 | format='%(asctime)s| %(levelname)-8s| %(name)s| %(message)s', 36 | datefmt='%Y/%m/%d %H:%M:%S', 37 | filename=logname, 38 | level=LEVELS.get(level, logging.NOTSET), 39 | ) 40 | 41 | return logging.getLogger(key) 42 | -------------------------------------------------------------------------------- /docker/Dockerfile_git: -------------------------------------------------------------------------------- 1 | # for ubuntu 2 | FROM ubuntu:bionic 3 | 4 | LABEL maintainer "Michihito Kato " 5 | 6 | ENV DEBIAN_FRONTEND noninteractive 7 | ENV PASSWORD=bbc1 PYTHONIOENCODING="utf-8" 8 | ENV SHARE_DIR=/root/.bbc1 VENV_DIR=/root/.pythonenv 9 | 10 | VOLUME ${SHARE_DIR} 11 | EXPOSE 22 9000 6641 12 | 13 | ADD requirements.txt /tmp/ 14 | ADD entrypoint.sh / 15 | WORKDIR /root/ 16 | 17 | # for ubuntu 18 | RUN apt-get update && apt-get install -y git tzdata openssh-server python3.6 python3.6-dev python3-pip python3-distutils python3.6-venv libffi-dev net-tools autoconf automake libtool libssl-dev make pkg-config 19 | 20 | RUN mkdir -p ${SHARE_DIR} && echo "root:${PASSWORD}" | chpasswd 21 | 22 | RUN rm /usr/bin/python3 && ln -s /usr/bin/python3.6 /usr/bin/python3 && ln -s /usr/bin/python3.6 /usr/bin/python 23 | 24 | # for ubuntu 25 | RUN sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config 26 | 27 | RUN /bin/bash -c "python3 -m venv ${VENV_DIR} && . ${VENV_DIR}/bin/activate && python3 -m pip install --upgrade pip setuptools && python3 -m pip install wheel && python3 -m pip install pystan && python3 -m pip install -r /tmp/requirements.txt && rm -r ~/.cache && deactivate && echo \". ${VENV_DIR}/bin/activate\" >> /root/.bashrc" 28 | 29 | RUN mkdir -p ${SHARE_DIR} 30 | 31 | ADD bbc1.tar.gz /root/ 32 | 33 | WORKDIR /root/bbc1/ 34 | 35 | RUN sh prepare.sh 36 | RUN cp -R /root/bbc1/libs/* /root/bbc1/bbc1/core/ 37 | 38 | CMD bash /entrypoint.sh 39 | -------------------------------------------------------------------------------- /docker/Dockerfile_pip: -------------------------------------------------------------------------------- 1 | # for ubuntu 2 | FROM ubuntu:bionic 3 | 4 | LABEL maintainer "Michihito Kato " 5 | 6 | ENV DEBIAN_FRONTEND noninteractive 7 | ENV PASSWORD=bbc1 PYTHONIOENCODING="utf-8" 8 | ENV SHARE_DIR=/root/.bbc1 VENV_DIR=/root/.pythonenv 9 | 10 | VOLUME ${SHARE_DIR} 11 | EXPOSE 22 9000 6641 12 | 13 | ADD requirements.txt /tmp/ 14 | ADD entrypoint.sh / 15 | WORKDIR /root/ 16 | 17 | #for ubuntu 18 | RUN apt-get update && apt-get install -y git tzdata openssh-server python3.6 python3.6-dev python3-pip python3-distutils python3.6-venv libffi-dev net-tools autoconf automake libtool libssl-dev make pkg-config 19 | 20 | RUN mkdir -p ${SHARE_DIR} && echo "root:${PASSWORD}" | chpasswd 21 | 22 | RUN rm /usr/bin/python3 && ln -s /usr/bin/python3.6 /usr/bin/python3 && ln -s /usr/bin/python3.6 /usr/bin/python 23 | 24 | # for ubuntu 25 | RUN sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config 26 | 27 | RUN /bin/bash -c "python3 -m venv ${VENV_DIR} && . ${VENV_DIR}/bin/activate && python3 -m pip install --upgrade pip setuptools && python3 -m pip install wheel && python3 -m pip install pystan && python3 -m pip install -r /tmp/requirements.txt && rm -r ~/.cache && deactivate && echo \". ${VENV_DIR}/bin/activate\" >> /root/.bashrc" 28 | 29 | RUN mkdir -p ${SHARE_DIR} 30 | 31 | CMD bash /entrypoint.sh 32 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | Run a bbc_core on a docker container 2 | ================ 3 | This directory includes Dockerfiles and utility to create and execute a docker container that runs bbc_core. 4 | 5 | ## Utility script 6 | docker-bbc1.sh is a utility to control docker container. You can find the usege of it by the command without any arguments (```./docker-bbc1.sh```). 7 | 8 | * gitbuild 9 | - build docker container with BBc-1 sources 10 | * pipbuild 11 | - build docker container with pip installation of bbc_core and so on 12 | * gitbuild_v6, pipbuild_v6 13 | - build docker container with enabling IPv6 option 14 | * start 15 | - start the created docker whose name is bbc1 16 | * stop 17 | - stop the docker container 18 | * restart 19 | - stop and start the docker container again 20 | * rm 21 | - remove the docker container 22 | * shell 23 | - log in to the container by attaching it with bash 24 | 25 | 26 | ## Base distribution 27 | The Dockerfiles build Ubuntu 17.04 based container with python3 and virtualenv. The entrypoint.sh will be copied in the container, so do not delete it. In the created container, bbc_core runs by root. You can log in to the container by either ssh or attaching to the docker container. *Note that the ssh port on the host is 10022 by default.* 28 | 29 | ## BBc-1 installation 30 | There are two Dockerfiles. One of them copies BBc-1 sources (the parent directory of here) in /root/bbc1/ of the container. In the other one, bbc_core and other tools are installed by pip. In both cases, bbc_core.py is automatically invoked when the container starts. 31 | 32 | ## Working directory 33 | The working directory on the container is /root/.bbc1/, and the directory is mounted on data/.bbc1 on the host. 34 | 35 | ## Port configuration 36 | BBc-1 uses two port numbers 9000 and 6641 of both TCP and UDP by default. Port 9000 is for communication between core and app. Port 6641 is for communication among bbc_cores to form P2P topologies. 37 | 38 | The container is configured to expose those ports to the same port numbers of the host. If you want to run multiple BBc-1 containers on a single host, you need to change the ports to expose on the host (e.g., 6641 -> 6641 and 9000 -> 9001). 39 | -------------------------------------------------------------------------------- /docker/docker-bbc1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TIMEZONE=Asia/Tokyo 4 | 5 | IMAGE_NAME=bbc1 6 | CONTAINER_NAME=bbc1 7 | SSH_PORT=10022 8 | CORE_PORT=9000 9 | P2PNW_PORT=6641 10 | 11 | 12 | case $1 in 13 | start) 14 | docker run --name ${CONTAINER_NAME} -d -v ${PWD}/data/.bbc1:/root/.bbc1 -p ${SSH_PORT}:22 -p ${CORE_PORT}:9000 -p ${P2PNW_PORT}:6641 -e TZ=${TIMEZONE} ${IMAGE_NAME} 15 | ;; 16 | 17 | stop) 18 | docker stop ${CONTAINER_NAME} 19 | ;; 20 | 21 | restart) 22 | docker restart ${CONTAINER_NAME} 23 | ;; 24 | 25 | rm) 26 | docker rm ${CONTAINER_NAME} 27 | ;; 28 | 29 | shell) 30 | docker exec -it ${CONTAINER_NAME} /bin/bash 31 | ;; 32 | 33 | gitbuild) 34 | cp ../requirements.txt . 35 | cd .. 36 | git archive --prefix="bbc1/" HEAD > docker/bbc1.tar 37 | tar -rf bbc1.tar 38 | gzip bbc1.tar 39 | docker build -t ${CONTAINER_NAME} -f Dockerfile_git . 40 | rm requirements.txt bbc1.tar.gz 41 | ;; 42 | 43 | pipbuild) 44 | cp ../requirements.txt . 45 | docker build -t ${CONTAINER_NAME} -f Dockerfile_pip . 46 | rm requirements.txt 47 | ;; 48 | 49 | *) 50 | echo "$0 [start|stop|restart|rm|shell|gitbuild|pipbuild]" 51 | echo 52 | ;; 53 | esac 54 | -------------------------------------------------------------------------------- /docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # generate host keys if not present 3 | ssh-keygen -A 4 | 5 | # for ubuntu 6 | if [ ! -e /var/run/sshd ]; then 7 | mkdir /var/run/sshd 8 | fi 9 | 10 | # do not detach (-D), log to stderr (-e), passthrough other arguments 11 | /usr/sbin/sshd -D -e & 12 | 13 | . /root/.pythonenv/bin/activate 14 | if [ -e /root/bbc1 ]; then 15 | cd /root/bbc1/bbc1/core 16 | exec python bbc_core.py -w /root/.bbc1 17 | else 18 | pip install bbc1 19 | exec bbc_core.py -w /root/.bbc1 20 | fi 21 | -------------------------------------------------------------------------------- /docs/BBc-1_analysis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc-1_analysis.pdf -------------------------------------------------------------------------------- /docs/BBc-1_design_paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc-1_design_paper.pdf -------------------------------------------------------------------------------- /docs/BBc-trust.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc-trust.pdf -------------------------------------------------------------------------------- /docs/BBc-trust_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc-trust_ja.pdf -------------------------------------------------------------------------------- /docs/BBc1_consensus_consideration_v1.0_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc1_consensus_consideration_v1.0_ja.pdf -------------------------------------------------------------------------------- /docs/BBc1_core_tutorial_file_proof_ja.md: -------------------------------------------------------------------------------- 1 | 2 | # BBc-1 Core チュートリアル : file_proof を用いて 3 | 4 | 10 | 11 | ## 1. はじめに 12 | BBc-1 Core では、記録の存在を証明するとともに、権限をもつ本人であることをデジタル署名で証明可能な場合に限り、その記録を更新することができます。 13 | 14 | このチュートリアルでは、以下のことを説明しています。 15 | * file_proof サンプルアプリケーションの使用 16 | 17 | #### 誰にとって有益か 18 | * BBc-1 Core を初めて動かして試してみたい方 19 | * BBc-1 Core の基本的な機能の使い方を知りたい方 20 | 21 | ## 2. BBc-1 Core のインストールと起動 22 | 「BBc-1 Core チュートリアル: インストールガイド」( BBc1_core_tutorial_installation_ja_r2.md) を参照してください。 23 | 24 | ## 3. file_proof サンプルアプリケーションを使う 25 | file_proof は、BBc-1 Core の機能をデモンストレートするために開発されたサンプルアプリケーションです。BBc-1 Core の機能を網羅的に用いています。 26 | 27 | * 記録 (この場合はファイル) を保存できます 28 | * ファイルを読み出せます 29 | * ファイルが改ざんされていないかの確認ができます 30 | * 保存されているファイルの内容を更新できます (保存したユーザのみ) 31 | * ファイルの送受信ができます (受け手が受理する場合のみ) 32 | 33 | ### 3-1. 準備 34 | bbc_core.py を動かしているのとは別のターミナルウィンドウを開きましょう。 35 | 36 | ※ インストール時に venv を使用した場合、今回 file_proof 用に立ち上げたウィンドウでも例えば ```$ source bbcenv/bin/activate``` によって仮想環境に入ってください。 37 | 38 | BBc-1 core をインストールしたディレクトリから file_proof サンプルアプリケーションのディレクトリに移動します。 39 | ``` 40 | $ cd examples/file_proof 41 | ``` 42 | 43 | ### 3-2. file_proof を使う 44 | 45 | 基本的な使い方は --help で見ることができます。 46 | ``` 47 | $ python file_proof.py --help 48 | ``` 49 | 50 | #### セットアップする 51 | まず「鍵ペア」を生成し、それから「ドメイン」をセットアップします。 52 | ``` 53 | $ python file_proof.py keypair 54 | $ python file_proof.py setup 55 | ``` 56 | 鍵ペア (公開鍵と秘密鍵のペア) のうち、秘密鍵はユーザとしてトランザクションに署名する際に用いられます。公開鍵は署名の検証に必要となります。鍵ペアの使用は file_proof のユーザからは隠蔽されていますが、トランザクションを発生させる場合に必ず使われています (ぜひコードで確認してみてください)。 57 | 58 | ドメインは BBc-1 におけるネットワークの単位です。 59 | 60 | ※ setup を実行しても処理が進まない場合は、bbc_core.py を起動する際に domain_key を設定してないことが原因と考えられます。立ち上げている bbc_core を停止 (Ctrl + C) した後に再度 ```$ python bbc_core.py --no_nodekey``` を実行してください。 61 | 62 | #### ファイルを保存する 63 | まず、保存するためのファイルをつくります。 64 | ``` 65 | $ cat > test.txt 66 | BBC HEAVEN. 67 | ^D 68 | $ more test.txt 69 | BBC HEAVEN. 70 | ``` 71 | file_proof.py を用いて BBc-1 Core にファイルを保存します。 72 | ``` 73 | $ python file_proof.py store test.txt 74 | ``` 75 | (トランザクションが生成され、ユーザによるデジタル署名が施された上で BBc-1 Core に投入されます。) 76 | 77 | #### ファイルを取得する 78 | 手元のファイルを消してから、BBc-1 Core に保存しているファイルの内容で復元してみましょう。 79 | ``` 80 | $ rm test.txt 81 | $ python file_proof.py get test.txt 82 | ``` 83 | 84 | #### ファイルの正当性を検証する 85 | 手元のファイルが BBc-1 Core に保存されている内容と一致しているかどうかを確認します。 86 | ``` 87 | $ python file_proof.py verify test.txt 88 | ``` 89 | 出力の 1行目に 90 | ``` 91 | test.txt is valid 92 | ``` 93 | が表示されます。 94 | 95 | 手元のファイルの内容を変更してから試してみましょう。 96 | ``` 97 | $ cat > test.txt 98 | BBC HEAVY. 99 | ^D 100 | $ more test.txt 101 | BBC HEAVY. 102 | $ python file_proof.py verify test.txt 103 | ``` 104 | 今度は出力の1行目が 105 | ``` 106 | test.txt is invalid 107 | ``` 108 | となります。 109 | 110 | #### ファイルを更新する 111 | 変更したファイルで BBc-1 Core に保存されている内容を更新してみましょう。その後、verify コマンドで確認してみてください。 112 | ``` 113 | $ python file_proof.py update test.txt 114 | ``` 115 | (トランザクションが生成され、ユーザによるデジタル署名が施された上で BBc-1 Core に投入されます。) 116 | ``` 117 | $ python file_proof.py verify test.txt 118 | ``` 119 | 120 | #### ファイルを送る/受け取る 121 | もうひとつ別のターミナルウィンドウを開いて、file_proof のディレクトリに移動してから次のようにしてファイルを待ち受けてください (別のソースディレクトリ、または別のマシンで実行すると実際にファイルが送られることを体験できるでしょう)。 122 | ``` 123 | $ python file_proof.py wait -o someone 124 | ``` 125 | 待ち受けているユーザの名前と ID が表示されます。 126 | 127 | 元のターミナルウィンドウから次のようにしてファイルを送ってみてください。 128 | ``` 129 | $ python file_proof.py send test.txt 130 | ``` 131 | ファイルを受け取るユーザを聞かれるので、"someone" と入力してください。 132 | 133 | 待ち受け側のターミナルウィンドウに次のようにプロンプトが表示されます。 134 | ``` 135 | -------------------------- 136 | File digest written in the transaction data: d866539f224896613df91023f0a9e226085451d6adf1dc5282cbba129d553713 137 | File digest calculated from the received file: d866539f224896613df91023f0a9e226085451d6adf1dc5282cbba129d553713 138 | -------------------------- 139 | ====> Do you want to accept the file? 140 | (Y/N) >> 141 | ``` 142 | 143 | "Y" または "N" で返答してください。"Y" を返答する (デジタル署名を施したメッセージを返す) とファイルが送られます (同じソースツリー上で実行している場合は変化は起きません)。 144 | 145 | ## 4. おわりに 146 | file_proof サンプルアプリケーションでは、BBc-1 Core の基本的な使い方が網羅されています。ぜひコードをご覧になって、みなさん自身のアプリケーションの開発にお役立てください。 147 | 148 | > Written with [StackEdit](https://stackedit.io/). 149 | -------------------------------------------------------------------------------- /docs/BBc1_core_tutorial_installation_ja.md: -------------------------------------------------------------------------------- 1 | # BBc-1 Core チュートリアル: インストールガイド 2 | 3 | 10 | 11 | ## 1. はじめに 12 | BBc-1 Core では、記録の存在を証明するとともに、権限をもつ本人であることをデジタル署名で証明可能な場合に限り、その記録を更新することができます。 13 | 14 | このチュートリアルでは、以下のことを説明しています。 15 | * BBc-1 Core のインストールと起動 16 | 17 | #### 誰にとって有益か 18 | * BBc-1 Core を初めて動かして試してみたい方 19 | 20 | ## 2. 前準備 21 | 以下の説明では bash の利用を前提とします。 22 | 23 | ### 2-1. 前提となる環境 24 | * Python 25 | * python 3.5.0 以降 (3.6.0以降推奨) 26 | * pipenv を使用できます (README を参照ください) 27 | * macOS の場合 (Homebrew の使用を前提として説明します) 28 | ``` 29 | $ brew install libtool automake pkg-config libffi autoconf openssl 30 | ``` 31 | 32 | * Linux の場合 (Ubuntu 16.04 LTS の使用を前提として説明します) 33 | ``` 34 | $ sudo apt install -y git tzdata openssh-server libffi-dev net-tools autoconf automake libtool libssl-dev pkg-config make 35 | ``` 36 | 37 | * Windows 10 の場合 (Linux サブシステムの使用を前提とします) 38 | Linux サブシステムのインストールはこちらを参照してください。 39 | * https://qiita.com/yukio_tokuyoshi/items/042546812c663ceeccf3 40 | * すでにインストールされているサブシステムをリセットする場合は、コマンドプロンプト (または Windows PowerShell) から以下を実行し、 41 | ``` 42 | C:> lxrun /uninstall /full 43 | ``` 44 | さらに以下を実行してください (エラーが出る場合もありますが、その場合は Windows を再起動してから試してみてください)。 45 | ``` 46 | C:> lxrun /install 47 | ``` 48 | 次のコマンドで bash を起動できます (cd コマンドで Linux ユーザのホームディレクトリに移動してください)。 49 | ``` 50 | C:> bash 51 | $ cd 52 | ``` 53 | Ubuntu 16.04 LTS がインストールされていますので、以降は Linux の方法に従ってください。 54 | 55 | * geth (Ethereum クライアント) と solidity (Ethereum のスマートコントラクトのプログラミング言語コンパイラ) についてはこのチュートリアルでは使用しません。レッジャーサブシステムのチュートリアルを参照してください。 56 | 57 | ### 2-2. Python3 環境の構築 58 | 59 | #### macOS 60 | ``` 61 | $ brew install python3 62 | ``` 63 | 69 | #### Linux 70 | ``` 71 | $ sudo add-apt-repository ppa:deadsnakes/ppa 72 | $ sudo apt update 73 | $ sudo apt install python3.6 python3.6-dev python3.6-venv 74 | ``` 75 | ※ 16.10 以降の版では python3 (python3.6) をそのまま apt でインストールできます。 76 | 82 | 83 | #### Python 仮想環境の利用 84 | macOS の場合は 'python3.6' を 'python3' と読み替えてください。 85 | ``` 86 | $ python3.6 -m venv bbcenv 87 | $ source bbcenv/bin/activate 88 | (bbcenv) $ pip install -U pip 89 | ``` 90 | 仮想環境から出る場合は次のコマンドを用います。 91 | ``` 92 | (bbcenv) $ deactivate 93 | ``` 94 | 95 | ## 3. BBc-1 Core のインストール 96 | BBc-1 Core をインストールするためには以下を実行します。 97 | 98 | #### ソースツリーの取得 99 | ``` 100 | $ git clone git@github.com:beyond-blockchain/bbc1.git 101 | ``` 102 | または 103 | ``` 104 | $ git clone https://github.com/beyond-blockchain/bbc1.git 105 | ``` 106 | #### ソースツリーのトップへ 107 | ``` 108 | $ cd bbc1 109 | ``` 110 | 117 | 118 | #### 一部C言語で記述されている部分のコンパイル等をして実行準備を整えます 119 | ``` 120 | $ sh prepare.sh 121 | ``` 122 | #### 必要な Python パッケージをインストールします 123 | ``` 124 | $ pip install -r requirements.txt 125 | ``` 126 | 127 | #### 開発中の pip インストールの方法 128 | ソースツリーから tar ボールを作成し、pip インストールすることもできます。ソースツリーのトップで次を行ってください。 129 | ``` 130 | $ python setup.py sdist 131 | $ pip install dist/bbc1-<バージョン>.tar.gz 132 | ``` 133 | 134 | ## 4. bbc_core の起動 135 | 136 | bbc_core.py があるディレクトリに移動し、起動します (pip インストールされている場合は、任意の場所で bbc_core.py をコマンドとして起動できます)。 137 | ``` 138 | $ cd bbc1/core 139 | $ python bbc_core.py --no_nodekey 140 | ``` 141 | "`--no_nodekey`" はノードに対するアクセス制御を行わないことを指定する起動オプションです。ここでは簡単なサンプルの試用を想定して、このオプションを指定しています。 142 | 143 | ターミナルにはログが表示されます。 144 | 145 | 終了させたい場合は Ctrl+C を押します。 146 | 147 | ## 5. おわりに 148 | 以上が BBc-1 Core のインストールと単体での起動の説明です。次はぜひサンプルアプリケーションを通して実際に BBc-1 Core の機能を試してみてください。 149 | 150 | * 「BBc-1 Core チュートリアル : file_proof を用いて」( BBc1_core_tutorial_file_proof_ja_r3.md ) 151 | 152 | > Written with [StackEdit](https://stackedit.io/). 153 | 154 | -------------------------------------------------------------------------------- /docs/BBc1_data_format_ja.md: -------------------------------------------------------------------------------- 1 | Data format of serialized BBc-1 transaction 2 | ======== 3 | 4 | BBc-1のトランザクションは、DBに保存したり、他者に送付したりするために、トランザクションデータをシリアライズする必要があります。 5 | シリアライズされた情報はさらに圧縮等の変換を施してデータ化できる。データの関係性を下図に示す。 6 | 7 | ![Serialize](images/BBc1_format.png) 8 | 9 | BBcTransactionオブジェクトをpackすると、バイナリフォーマットのデータに変換される(図の真ん中)。バイナリフォーマットのデータをさらに圧縮するなどの変換を施し、ヘッダを付加して、最終的なデータフォーマット (wire-format)とする。 10 | 11 | なお、header部は2バイトの数値で、BBcFormatとして定義されており、serialize/deserializeのデータ変換方法を示す。 12 | 13 | |数値|内容| 14 | |----------|-------------| 15 | |0x0000|無変換(packされたデータそのまま)| 16 | |0x0010|packされたデータをzlibで圧縮| 17 | 18 | ### 非推奨のヘッダ値 19 | version 1.1.1以前は、ヘッダの値(すなわちBBcFormatの値)として0x0001〜0x0006が定義されており、bson (binary Json)やmsgpackなどの形式を利用できるようになっていた。 20 | しかし、署名範囲の計算方法がヘッダの値(packed binary dataの形式)に左右されてしまい、混乱をきたす可能性があるため、これらを非推奨としバイナリ形式を一本化することとした。 21 | 22 | format\_type=BBcFormat.FORMAT\_BINARY(0x0000)を利用していた場合(デフォルト値なので意識していなければこれになっている)、この問題は特に発生しない。 23 | それ以外を利用していた場合、v1.2のbbclib.pyはこれまでに作成されたトランザクションデータを読み込むことは可能であるが、 24 | 新しく作成するトランザクションはヘッダ値0x0000または0x0010のみに対応する。 25 | 26 | ## Programming 27 | 中間のpacked binary dataはbbclib.pyの中で隠蔽される。シリアライズデータ(txdata)を取得するには、下記のようにすれば良い。なお、txobjはBBcTransactionオブジェクトとする。 28 | ```python 29 | from bbc1.core import bbclib 30 | 31 | txdata = bbclib.serialize(txobj) 32 | ``` 33 | 34 | シリアライズデータをBBcTransactionオブジェクトに戻すには、下記のようにすれば良い。 35 | ```python 36 | from bbc1.core import bbclib 37 | 38 | txobj, fmt_type = bbclib.deserialize(txdata) 39 | ``` 40 | 41 | fmt_typeにはヘッダ値がセットされる。 42 | 43 | ## Backward comptibility 44 | v1.2以前は、pack/unpackおよびserialize/deserializeが明確に分離されておらず、bbclib.pyですべての処理を行っていた。v1.2ではこれらを機能として明確に分離したため、上述のようにserializeとdeserializeの実施方法が変更になった。 45 | 46 | v1.2以前のbbclib.pyを組み込んだアプリケーションコードを、そのままv1.2で利用できるようにするために、暫定的にcompatというモジュールを用意している。 47 | v1.2以前のアプリケーションコードの冒頭で、 48 | ```python 49 | from bbc1.core import bbclib 50 | ``` 51 | となっている部分を、 52 | ```python 53 | from bbc1.core.compat import bbclib 54 | ``` 55 | に置き換えればよい。 56 | 57 | なお、format\_type=BBcFormat.FORMAT\_BINARY(0x0000)以外を用いている場合は、bbc1.core.compat.bbclibを利用しなければ同じフォーマットでのトランザクションのシリアライズができない。 58 | -------------------------------------------------------------------------------- /docs/BBc1_design_document_v1.0_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc1_design_document_v1.0_ja.pdf -------------------------------------------------------------------------------- /docs/BBc1_system_design_guide_v1.0_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/BBc1_system_design_guide_v1.0_ja.pdf -------------------------------------------------------------------------------- /docs/How_BBc1_works_v1.0.2_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/How_BBc1_works_v1.0.2_ja.pdf -------------------------------------------------------------------------------- /docs/How_to_use_BBc1_v1.0.2_ja.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/How_to_use_BBc1_v1.0.2_ja.pdf -------------------------------------------------------------------------------- /docs/IDs.md: -------------------------------------------------------------------------------- 1 | Identifiers in BBc-1 2 | ==================== 3 | In BBc-1, various kinds of identifiers are defined. All of them are 256-bit value (basically calculated by SHA-256 or now). 4 | 5 | * transaction_id 6 | - ID of a transaction data 7 | * asset_id 8 | - ID of an asset 9 | - If the asset is in a storage as a file, the file name is the asset_id. 10 | * asset_group_id 11 | - ID of an asset group 12 | * domain_id 13 | - ID of a domain 14 | - A domain corresponds to a set of bbc_nodes where transaction data and asset files are shared. 15 | - A bbc_node can accommodate any number of domains. 16 | - An application can use one or more domains and several applications can use a single domain. 17 | * user_id 18 | - ID of a user (or an user of a asset) 19 | - A user_id is also used as a destination and a source to exchange messages between application users. 20 | * node_id 21 | - ID of a bbc_node 22 | - A node_id is used as a destination and a source to exchange messages between bbc_nodes. 23 | 24 | ## Uniqueness 25 | A name space is defined in a single asset_group. So, each ID such as user_id, asset_id and transaction_id, must be unique in the asset_group. 26 | As for node_id, it must be unique in a domain. 27 | An asset_group_id and a domain_id must be unique globally if the domain connects to domain_global_0. If the domain is completely isolated from the domain_global_0, they must be unique within the isolated world. 28 | 29 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Documents 2 | ========= 3 | This directory includes documents, slide decks and API documents in HTML format. 4 | 5 | ## API documents 6 | The API documents are created by [sphinx](http://www.sphinx-doc.org/en/stable/). You can read the doc by accessing api/_build/html/index.html. 7 | Of course, you can create various types of API doc by using make command as follows: 8 | ``` 9 | make **builder** 10 | ``` 11 | *\*builder\** could be html, latex and so on. You can find the list of builder by just executing `make`. 12 | -------------------------------------------------------------------------------- /docs/api/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_app.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_app.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_config.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_config.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_core.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_core.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_error.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_error.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_network.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_network.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbc_stats.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbc_stats.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.bbclib.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.bbclib.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.command.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.command.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.data_handler.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.data_handler.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.domain0_manager.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.domain0_manager.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.key_exchange_manager.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.key_exchange_manager.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.logger.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.logger.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.message_key_types.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.message_key_types.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.query_management.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.query_management.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.repair_manager.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.repair_manager.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.topology_manager.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.topology_manager.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.core.user_message_routing.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.core.user_message_routing.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/bbc1.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/bbc1.doctree -------------------------------------------------------------------------------- /docs/api/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/api/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/api/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: fbe671c16393bdb021d160b4ccda4a4d 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/api/_build/html/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/.nojekyll -------------------------------------------------------------------------------- /docs/api/_build/html/_modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Overview: module code — BBc1 1.4 documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 95 | 96 |
97 | 98 | 99 | 105 | 106 | 107 |
108 | 109 |
110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
128 | 129 |
    130 | 131 |
  • Docs »
  • 132 | 133 |
  • Overview: module code
  • 134 | 135 | 136 |
  • 137 | 138 |
  • 139 | 140 |
141 | 142 | 143 |
144 |
145 | 170 |
171 | 172 | 173 |
174 | 175 |
176 |

177 | © Copyright 2018, beyond-blockchain.org 178 | 179 |

180 |
181 | Built with Sphinx using a theme provided by Read the Docs. 182 | 183 |
184 | 185 |
186 |
187 | 188 |
189 | 190 |
191 | 192 | 193 | 194 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_app.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_app module 2 | ========================= 3 | 4 | .. automodule:: bbc1.core.bbc_app 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_config.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_config module 2 | ============================ 3 | 4 | .. automodule:: bbc1.core.bbc_config 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_core.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_core module 2 | ========================== 3 | 4 | .. automodule:: bbc1.core.bbc_core 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_error.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_error module 2 | =========================== 3 | 4 | .. automodule:: bbc1.core.bbc_error 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_network.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_network module 2 | ============================= 3 | 4 | .. automodule:: bbc1.core.bbc_network 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbc_stats.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_stats module 2 | =========================== 3 | 4 | .. automodule:: bbc1.core.bbc_stats 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.bbclib.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.bbclib module 2 | ======================= 3 | 4 | .. automodule:: bbc1.core.bbclib 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.command.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.command module 2 | ======================== 3 | 4 | .. automodule:: bbc1.core.command 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.data_handler.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.data\_handler module 2 | ============================== 3 | 4 | .. automodule:: bbc1.core.data_handler 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.domain0_manager.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.domain0\_manager module 2 | ================================= 3 | 4 | .. automodule:: bbc1.core.domain0_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.key_exchange_manager.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.key\_exchange\_manager module 2 | ======================================= 3 | 4 | .. automodule:: bbc1.core.key_exchange_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.logger.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.logger module 2 | ======================= 3 | 4 | .. automodule:: bbc1.core.logger 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.message_key_types.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.message\_key\_types module 2 | ==================================== 3 | 4 | .. automodule:: bbc1.core.message_key_types 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.query_management.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.query\_management module 2 | ================================== 3 | 4 | .. automodule:: bbc1.core.query_management 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.repair_manager.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.repair\_manager module 2 | ================================ 3 | 4 | .. automodule:: bbc1.core.repair_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core package 2 | ================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | bbc1.core.bbc_app 10 | bbc1.core.bbc_config 11 | bbc1.core.bbc_core 12 | bbc1.core.bbc_error 13 | bbc1.core.bbc_network 14 | bbc1.core.bbc_stats 15 | bbc1.core.bbclib 16 | bbc1.core.command 17 | bbc1.core.data_handler 18 | bbc1.core.domain0_manager 19 | bbc1.core.key_exchange_manager 20 | bbc1.core.logger 21 | bbc1.core.message_key_types 22 | bbc1.core.query_management 23 | bbc1.core.repair_manager 24 | bbc1.core.topology_manager 25 | bbc1.core.user_message_routing 26 | 27 | Module contents 28 | --------------- 29 | 30 | .. automodule:: bbc1.core 31 | :members: 32 | :undoc-members: 33 | :show-inheritance: 34 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.topology_manager.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.topology\_manager module 2 | ================================== 3 | 4 | .. automodule:: bbc1.core.topology_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.core.user_message_routing.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1.core.user\_message\_routing module 2 | ======================================= 3 | 4 | .. automodule:: bbc1.core.user_message_routing 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/bbc1.rst.txt: -------------------------------------------------------------------------------- 1 | bbc1 package 2 | ============ 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | bbc1.core 10 | 11 | Module contents 12 | --------------- 13 | 14 | .. automodule:: bbc1 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: 18 | -------------------------------------------------------------------------------- /docs/api/_build/html/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. bbc1 documentation master file, created by 2 | sphinx-quickstart on Wed Jul 31 01:12:36 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to bbc1's documentation! 7 | ================================ 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | :caption: Contents: 12 | 13 | bbc1 14 | 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /docs/api/_build/html/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-weight:normal;font-style:normal;src:url("../fonts/fontawesome-webfont.eot");src:url("../fonts/fontawesome-webfont.eot?#iefix") format("embedded-opentype"),url("../fonts/fontawesome-webfont.woff") format("woff"),url("../fonts/fontawesome-webfont.ttf") format("truetype"),url("../fonts/fontawesome-webfont.svg#FontAwesome") format("svg")}.fa:before{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;text-decoration:inherit}a .fa{display:inline-block;text-decoration:inherit}li .fa{display:inline-block}li .fa-large:before,li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-0.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before,ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before{content:""}.icon-book:before{content:""}.fa-caret-down:before{content:""}.icon-caret-down:before{content:""}.fa-caret-up:before{content:""}.icon-caret-up:before{content:""}.fa-caret-left:before{content:""}.icon-caret-left:before{content:""}.fa-caret-right:before{content:""}.icon-caret-right:before{content:""}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;z-index:400}.rst-versions a{color:#2980B9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1}.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book{float:left}.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .icon-book{float:none}.rst-versions.rst-badge .fa-book{float:none}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book{float:left}.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge .rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width: 768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} 2 | -------------------------------------------------------------------------------- /docs/api/_build/html/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '1.4', 4 | LANGUAGE: 'en', 5 | COLLAPSE_INDEX: false, 6 | FILE_SUFFIX: '.html', 7 | HAS_SOURCE: true, 8 | SOURCELINK_SUFFIX: '.txt', 9 | NAVIGATION_WITH_KEYS: false 10 | }; -------------------------------------------------------------------------------- /docs/api/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/file.png -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Inconsolata-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Inconsolata-Bold.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Inconsolata.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Inconsolata.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato-Bold.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato-Regular.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bold.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bold.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bold.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-bolditalic.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-italic.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-italic.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-italic.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-italic.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-regular.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-regular.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-regular.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/Lato/lato-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/Lato/lato-regular.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab-Bold.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab-Regular.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/api/_build/html/_static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/api/_build/html/_static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/api/_build/html/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | /* sphinx_rtd_theme version 0.4.3 | MIT license */ 2 | /* Built 20190212 16:02 */ 3 | require=function r(s,a,l){function c(e,n){if(!a[e]){if(!s[e]){var i="function"==typeof require&&require;if(!n&&i)return i(e,!0);if(u)return u(e,!0);var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}var o=a[e]={exports:{}};s[e][0].call(o.exports,function(n){return c(s[e][1][n]||n)},o,o.exports,r,s,a,l)}return a[e].exports}for(var u="function"==typeof require&&require,n=0;n"),i("table.docutils.footnote").wrap("
"),i("table.docutils.citation").wrap("
"),i(".wy-menu-vertical ul").not(".simple").siblings("a").each(function(){var e=i(this);expand=i(''),expand.on("click",function(n){return t.toggleCurrent(e),n.stopPropagation(),!1}),e.prepend(expand)})},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),i=e.find('[href="'+n+'"]');if(0===i.length){var t=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(i=e.find('[href="#'+t.attr("id")+'"]')).length&&(i=e.find('[href="#"]'))}0this.docHeight||(this.navBar.scrollTop(i),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",function(){this.linkScroll=!1})},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current"),e.siblings().find("li.current").removeClass("current"),e.find("> ul li.current").removeClass("current"),e.toggleClass("current")}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:e.exports.ThemeNav,StickyNav:e.exports.ThemeNav}),function(){for(var r=0,n=["ms","moz","webkit","o"],e=0;e 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Search — BBc1 1.4 documentation 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 96 | 97 |
98 | 99 | 100 | 106 | 107 | 108 |
109 | 110 |
111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
129 | 130 |
    131 | 132 |
  • Docs »
  • 133 | 134 |
  • Search
  • 135 | 136 | 137 |
  • 138 | 139 | 140 | 141 |
  • 142 | 143 |
144 | 145 | 146 |
147 |
148 |
149 |
150 | 151 | 159 | 160 | 161 |
162 | 163 |
164 | 165 |
166 | 167 |
168 |
169 | 170 | 171 |
172 | 173 |
174 |

175 | © Copyright 2018, beyond-blockchain.org 176 | 177 |

178 |
179 | Built with Sphinx using a theme provided by Read the Docs. 180 | 181 |
182 | 183 |
184 |
185 | 186 |
187 | 188 |
189 | 190 | 191 | 192 | 197 | 198 | 199 | 200 | 201 | 202 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_app.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_app module 2 | ========================= 3 | 4 | .. automodule:: bbc1.core.bbc_app 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_config.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_config module 2 | ============================ 3 | 4 | .. automodule:: bbc1.core.bbc_config 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_core.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_core module 2 | ========================== 3 | 4 | .. automodule:: bbc1.core.bbc_core 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_error.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_error module 2 | =========================== 3 | 4 | .. automodule:: bbc1.core.bbc_error 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_network.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_network module 2 | ============================= 3 | 4 | .. automodule:: bbc1.core.bbc_network 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbc_stats.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbc\_stats module 2 | =========================== 3 | 4 | .. automodule:: bbc1.core.bbc_stats 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.bbclib.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.bbclib module 2 | ======================= 3 | 4 | .. automodule:: bbc1.core.bbclib 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.command.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.command module 2 | ======================== 3 | 4 | .. automodule:: bbc1.core.command 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.data_handler.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.data\_handler module 2 | ============================== 3 | 4 | .. automodule:: bbc1.core.data_handler 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.domain0_manager.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.domain0\_manager module 2 | ================================= 3 | 4 | .. automodule:: bbc1.core.domain0_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.key_exchange_manager.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.key\_exchange\_manager module 2 | ======================================= 3 | 4 | .. automodule:: bbc1.core.key_exchange_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.logger.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.logger module 2 | ======================= 3 | 4 | .. automodule:: bbc1.core.logger 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.message_key_types.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.message\_key\_types module 2 | ==================================== 3 | 4 | .. automodule:: bbc1.core.message_key_types 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.query_management.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.query\_management module 2 | ================================== 3 | 4 | .. automodule:: bbc1.core.query_management 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.repair_manager.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.repair\_manager module 2 | ================================ 3 | 4 | .. automodule:: bbc1.core.repair_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.rst: -------------------------------------------------------------------------------- 1 | bbc1.core package 2 | ================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | bbc1.core.bbc_app 10 | bbc1.core.bbc_config 11 | bbc1.core.bbc_core 12 | bbc1.core.bbc_error 13 | bbc1.core.bbc_network 14 | bbc1.core.bbc_stats 15 | bbc1.core.bbclib 16 | bbc1.core.command 17 | bbc1.core.data_handler 18 | bbc1.core.domain0_manager 19 | bbc1.core.key_exchange_manager 20 | bbc1.core.logger 21 | bbc1.core.message_key_types 22 | bbc1.core.query_management 23 | bbc1.core.repair_manager 24 | bbc1.core.topology_manager 25 | bbc1.core.user_message_routing 26 | 27 | Module contents 28 | --------------- 29 | 30 | .. automodule:: bbc1.core 31 | :members: 32 | :undoc-members: 33 | :show-inheritance: 34 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.topology_manager.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.topology\_manager module 2 | ================================== 3 | 4 | .. automodule:: bbc1.core.topology_manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.core.user_message_routing.rst: -------------------------------------------------------------------------------- 1 | bbc1.core.user\_message\_routing module 2 | ======================================= 3 | 4 | .. automodule:: bbc1.core.user_message_routing 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/bbc1.rst: -------------------------------------------------------------------------------- 1 | bbc1 package 2 | ============ 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | bbc1.core 10 | 11 | Module contents 12 | --------------- 13 | 14 | .. automodule:: bbc1 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: 18 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | .. bbc1 documentation master file, created by 2 | sphinx-quickstart on Wed Jul 31 01:12:36 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to bbc1's documentation! 7 | ================================ 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | :caption: Contents: 12 | 13 | bbc1 14 | 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /docs/api/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/images/BBc1_format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beyond-blockchain/bbc1/3294047b2dad44768c2ef3fcb411be0d5453a4f0/docs/images/BBc1_format.png -------------------------------------------------------------------------------- /docs/libbbcsig_dll_build_for_Windows_x64_ja.md: -------------------------------------------------------------------------------- 1 | libbbcsig の 64bit Windows DLL ビルドについて 2 | ========= 3 | ここでは、libbbcsig を 64bit Windows DLL にビルドする方法について記載する。 4 | libbbcsig は内部で OpenSSL の関数を使用しているため、まず、OpenSSL を Windows 向けにビルドする必要がある。 5 | 6 | ## OpenSSL のビルド 7 | 8 | ### ビルド環境の構築 9 | 10 | 以下のソフトウェアが必要になる。インストールを行う。 11 | 12 | * [Visual Studio Community 2017](https://www.microsoft.com/ja-jp/dev/products/community.aspx) 13 | * [ActiveParl](https://www.activestate.com/activeperl) 14 | 15 | ### OpenSSL ソースダウンロード & ビルド 16 | 17 | [https://www.openssl.org/](https://www.openssl.org/) からソースをダウンロードする。 18 | 19 | ※ 以下、 1.0.2n の場合について記載する。 20 | 21 | ソースの展開ディレクトリに移動し、以下のコマンドを実行する。 22 | 23 | `cd <<ソースの展開ディレクトリ>>\openssl-1.0.2n` 24 | 25 | `perl Configure no-asm --prefix=..\x64 VC-WIN64A` 26 | 27 | `ms\do_win64a.bat` 28 | 29 | `nmake -f ms\nt.mak clean` 30 | 31 | `nmake -f ms\nt.mak install` 32 | 33 | ※ **nt.mak** を指定し、スタティックライブラリにすること。 34 | ※ `..\x64\lib` ディレクトリに、libeay32.lib と ssleay32.lib ができれば OK 35 | 36 | ## libbbcsig のビルド 37 | 38 | ### libbbcsig の Visual Studio プロジェクト生成 39 | 40 | Visual Studio で空のプロジェクトを新規作成する。(名称: libbbcsig) 41 | 42 | `bbc1/common/libbbcsig` にある以下のファイルをプロジェクトに追加する。 43 | 44 | * libbbcsig.h 45 | * libbbcsig.c 46 | * dllmain.c 47 | * libbbcsig.def 48 | 49 | ### libbbcsig プロジェクトの設定 50 | 51 | プロジェクトのプロパティを以下のように設定する。 52 | 53 | |項目|設定値| 54 | |:-:|:-:| 55 | |プラットフォーム| x64| 56 | |構成の種類|dll| 57 | |追加のインクルードディレクトリ|<<ソースの展開ディレクトリ>>\x64\include| 58 | |追加のインクルードディレクトリ|<<ソースの展開ディレクトリ>>\openssl-1.0.2n| 59 | |ランタイムライブラリ|/MT| 60 | |追加の依存ファイル|<<ソースの展開ディレクトリ>>\x64\lib\libeay32.lib| 61 | |追加の依存ファイル|<<ソースの展開ディレクトリ>>\x64\lib\ssleay32.lib| 62 | |モジュール定義ファイル|libbbcsig.def| 63 | 64 | ### ビルド 65 | 66 | ビルドを行い、`x64\Debug` または `x64\Release` ディレクトリに libbbcsig.dll が出来ることを確認する。 67 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Sample applications 2 | === 3 | Three types of sample applications are available here. 4 | 5 | # File proof 6 | This app allows a user to do the following: 7 | * store a file in bbc_core 8 | * update a file in bbc_core 9 | * get a file from bbc_core 10 | * verify a file 11 | * send/receive a file to another user through bbc_core and transfer the possession of it 12 | 13 | # Starter example 14 | This example includes setup scripts and application. 15 | * install modules 16 | * create bbc1 configuration 17 | * create a domain 18 | * run a single bbc_core.py 19 | * create and register a transaction 20 | * search transactions and show the list 21 | * search a transaction and print the dump of the transaction 22 | -------------------------------------------------------------------------------- /examples/file_proof/README.md: -------------------------------------------------------------------------------- 1 | File proof2 2 | ========== 3 | This app allows a user to do the following: 4 | * store a file in bbc_core 5 | * update a file in bbc_core 6 | * get a file from bbc_core 7 | * verify a file 8 | * send/receive a file to another user through bbc_core and transfer the possession of it 9 | 10 | # How to use 11 | 1. Start bbc_core.py in a terminal 12 | ``` 13 | cd ../../core 14 | python bbc_core.py 15 | ``` 16 | 2. Create a key pair, and set up a domain and an asset group 17 | ``` 18 | python file_proof.py keypair 19 | python file_proof.py setup 20 | ``` 21 | .private_key and .public_key are created. 22 | 3. Execute commands in another terminal 23 | The commands must be executed in the directory having the key pair. 24 | * Store a file 25 | ``` 26 | python file_proof.py store [filename] 27 | ``` 28 | You can specify your user name by -o option. 29 | ``` 30 | python file_proof.py store [filename] -o [username] 31 | ``` 32 | username is converted into SHA-256 digest in the application. 33 | * Get a file 34 | ``` 35 | python file_proof.py get [filename] 36 | ``` 37 | You need to have stored the file before this command. 38 | * Update a file 39 | edit/update a file that has already been stored. 40 | ``` 41 | python file_proof.py update [filename] 42 | ``` 43 | -o option is also available. 44 | * Verify a file 45 | ``` 46 | python file_proof.py vefify [filename] 47 | ``` 48 | Of course, the file must be in the bbc_core for this to succeed. 49 | * Send/receive a file 50 | You need two terminals. 51 | ``` 52 | python file_proof.py wait 53 | ``` 54 | The above command is for the receiver. 55 | ``` 56 | python file_proof.py send [filename] 57 | ``` 58 | The above command is for the sender. The sender will see a prompt for the user name for the receiver. (Note that it is not user_id!) 59 | You can send/receive the file by following the interactive messages. 60 | After the file transfer, the receiver can get/verify the file by "get" and "verify" commands above. 61 | 62 | ## JSON file for utility 63 | Basically, BBc-1 treats only 256-bit value (SHA-256 digest value) as an ID. It is not intuitive for application user/developer in some cases. So, bbc_app.py provides utilities for mapping betwen SHA-256 values and human-readable strings in a JSON file. You can see .bbc_id_mappings in the directory where file_proof.py is executed. 64 | 65 | # Basic flow of file_proof.py 66 | A process in file_proof.py includes two parts, preparation (the former half of the process) and individual mode operation (the latter half of it). 67 | 68 | ## Preparation 69 | argument_parser() parses parameters to choose the operation mode. 70 | sys_check() mainly read a key pair, which is saved in .private_key and .public_kdy in the current directory. 71 | setup_bbc_client() calls method in bbc_app.py and connects/registers to bbc_core. In registering to bbc_core, domain_id, user_id, network module and so on are configured. 72 | get_id_from_mappings() and store_id_mappings() reads/stores the JSON file that has the information of the mappings among a transaction_id, an asset_id and a file name. Basically, BBc-1 treats only 256-bit value (SHA-256 digest value) as an ID. It is not intuitive for application user/developer in some cases. So, bbc_app.py provides utilities for mapping between SHA-256 values and human-readable strings in a JSON file. You can see .bbc_id_mappings in the directory where file_proof.py is executed. 73 | 74 | 75 | ## Operation modes 76 | ### common thing 77 | In each mode, queue system is utilized for message receiving from bbc_core. You can find several lines of ```response_data = bbc_app_client.callback.synchronize()```. 78 | 79 | ### store mode 80 | store_file() and store_proc() work in this mode. store_proc() creates a transaction using bbclib.make_transaction_for_base_asset() and add the signature of yourself. Then, the transaction is inserted into the bbc_core by bbc_app_client.insert_transaction() method. 81 | 82 | ### update mode 83 | store_file() and store_proc() also work in this mode. At the beginning of store_proc(), it searches for the existing transaction by using asset_id obtained from .bbc_id_mappings JSON file. Different from the store mode, the transaction involves a BBcReference object for the previous transaction (maybe the first registration of the file or the last update of it). The rest of the process is the same as store mode. 84 | 85 | ### get mode 86 | get_file() works in this mode. By the file name, the corresponding asset_id (included in the last transaction regarding the file) obtained from .bbc_id_mappings JSON file. The transaction and the asset file are retrieved from the bbc_core by using bbc_app_client.search_asset(). The transaction in the returned result must be deserialized into a BBcTransaction object by using bbclib.recover_transaction_object_from_rawdata(). The returned result also includes the file itself. 87 | 88 | ### verify mode 89 | verify_file() works in this mode. Similar to get mode, the file and the transaction are obtained using bbc_app_client.search_asset(). In the BBcEvent object of the returned transaction, BBcAsset includes the file digest value of the asset file, By calculating SHA-256 of the returned asset file, the integrity can be confirmed by comparing the file digest in the BBcAsset and the calculation resullt. 90 | 91 | ### send mode 92 | enter_file_send_mode() works in this mode. The method includes 4 major steps as follows: preparation, creating a transaction, inserting the transaction into bbc_core and sending a message to the file receiver about completing the transfer process. 93 | 94 | ### receive mode 95 | enter_file_wait_mode() works in this mode. The method includes 4 major steps as follows: preparation, waiting for a transaction in the sign request from the file sender, signing the transaction and returning it, and then, waiting for the complete message. 96 | 97 | -------------------------------------------------------------------------------- /examples/starter/README.md: -------------------------------------------------------------------------------- 1 | Starter example 2 | ==== 3 | 4 | This directory includes an simple example of BBc-1 application. The goal of this example is to show how BBc-1 Transaction is created/treated in an application. The scripts in this directory are helper tools to build up an envilonment of BBc-1 system (configure and run bbc\_core) and to create an user and to run client app. 5 | 6 | # How to use 7 | 8 | ### Step 1. Install modules (Run just once) 9 | 10 | ```bash 11 | bash ./starter.sh install 12 | ``` 13 | 14 | Note that python3 virtualenv is required to build the environment. 15 | 16 | 17 | ### Step 2. Setup initial configuration of bbc_core.py (Run just once) 18 | 19 | ```bash 20 | bash ./starter.sh setup 21 | ``` 22 | 23 | 24 | ### Step 3. Run bbc_core in background 25 | 26 | If you have not run bbc_core.py, run it as follows: 27 | 28 | ```bash 29 | bash ./starter.sh core 30 | ``` 31 | 32 | 33 | ### Step 4. Create a user 34 | 35 | ```bash 36 | bash ./starter.sh create *username* 37 | ``` 38 | 39 | You can specify *username* as you like. Then, you will find the directory whose name is the specified user name. 40 | 41 | ### Step 5. Generate and register a transaction 42 | 43 | Suppose that you created UserA in the previous step. 44 | 45 | Enter directory "UserA" and run the script as follows: 46 | 47 | ```bash 48 | cd UserA 49 | bash ./run_script.sh register 50 | ``` 51 | 52 | You can run the above script multiple times, then multiple transactions are registered. 53 | The script invokes register_a_transaction.py, which finds the latest transaction of the user (the user of the asset in the transaction equals to the user_id described in ID_FILE.) The new transaction has BBcPointer pointing to the latest transaction_id. 54 | 55 | ### Step 6. Show the user's transactions 56 | 57 | Enter directory "UserA" and run the script as follows: 58 | ```bash 59 | cd UserA 60 | bash ./run_script.sh show_all 61 | ``` 62 | 63 | You will see the summary information of the registered transactions of the user. 64 | 65 | ### Step 7. Dump a transaction 66 | 67 | You can print the content of a transaction by specifying a transaction_id. 68 | 69 | ```bash 70 | cd UserA 71 | bash ./run_script.sh print *transaction_id* 72 | ``` 73 | \*transaction_id\* is in a hex format like "cb2e83022c32a25a565b90de89735b7e14c02ec6b3ce8ecc7ffb36254a2bcd96". 74 | 75 | 76 | # Other options 77 | 78 | ### Kill bbc_core.py process 79 | 80 | ```bash 81 | bash ./starter.sh kill 82 | ``` 83 | 84 | 85 | ### Clean up all data 86 | 87 | ```bash 88 | bash ./starter.sh clean 89 | ``` 90 | 91 | You have to setup bbc_core configuration again. (see step.2) 92 | 93 | ### Remove a user 94 | 95 | ```bash 96 | bash ./starter.sh remove *username* 97 | ``` 98 | 99 | The directory of the specified username will be removed. 100 | -------------------------------------------------------------------------------- /examples/starter/requirements.txt: -------------------------------------------------------------------------------- 1 | asn1crypto==0.24.0 2 | bson==0.5.8 3 | certifi==2019.3.9 4 | cffi==1.12.2 5 | chardet==3.0.4 6 | Click==7.0 7 | cryptography==2.6.1 8 | Flask==1.0.1 9 | gevent==1.4.0 10 | greenlet==0.4.15 11 | idna==2.8 12 | itsdangerous==1.1.0 13 | Jinja2==2.10.1 14 | MarkupSafe==1.1.1 15 | msgpack==0.6.1 16 | msgpack-python==0.5.6 17 | mysql-connector-python==8.0.15 18 | protobuf==3.7.1 19 | py==1.8.0 20 | pycparser==2.19 21 | pyOpenSSL==19.0.0 22 | pytest==3.1.3 23 | python-dateutil==2.8.0 24 | requests==2.21.0 25 | six==1.12.0 26 | urllib3==1.24.2 27 | Werkzeug==0.15.2 28 | -------------------------------------------------------------------------------- /examples/starter/scripts/create_userid_keypair.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2018 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import os 23 | import sys 24 | import argparse 25 | 26 | from bbc1.core import bbclib 27 | 28 | 29 | PRIVATE_KEY = ".private_key" 30 | PUBLIC_KEY = ".public_key" 31 | 32 | 33 | def create_keypair(): 34 | keypair = bbclib.KeyPair() 35 | keypair.generate() 36 | with open(PRIVATE_KEY, "wb") as fout: 37 | fout.write(keypair.private_key) 38 | with open(PUBLIC_KEY, "wb") as fout: 39 | fout.write(keypair.public_key) 40 | print("created private_key and public_key : %s, %s" % (PRIVATE_KEY, PUBLIC_KEY)) 41 | 42 | 43 | def argument_parser(): 44 | argparser = argparse.ArgumentParser(description='Generate an user_id') 45 | argparser.add_argument('-u', '--username', action='store', help='username') 46 | return argparser.parse_args() 47 | 48 | 49 | if __name__ == '__main__': 50 | if os.path.exists(PRIVATE_KEY): 51 | print("Private key file already exists.") 52 | sys.exit(1) 53 | parsed_args = argument_parser() 54 | if parsed_args.username is None: 55 | print("Usage: $0 -u username") 56 | sys.exit(1) 57 | create_keypair() 58 | user_id = bbclib.get_new_id(parsed_args.username, include_timestamp=False) 59 | with open("ID_FILE", "w") as f: 60 | f.write('{\n "name": "%s",\n "id": "%s"\n}\n' % (parsed_args.username, user_id.hex())) 61 | -------------------------------------------------------------------------------- /examples/starter/scripts/print_transaction.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2018 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | import binascii 24 | import msgpack 25 | import os 26 | import json 27 | import sys 28 | import pprint 29 | 30 | from bbc1.core import bbc_app 31 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT 32 | from bbc1.core import bbclib 33 | from bbc1.core.message_key_types import KeyType 34 | from bbc1.core.bbc_error import * 35 | 36 | asset_group_id = bbclib.get_new_id("test_asset_group", include_timestamp=False) 37 | 38 | 39 | def setup_bbc_client(domain_id, user_id): 40 | bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, multiq=False, loglevel="all") 41 | bbc_app_client.set_user_id(user_id) 42 | bbc_app_client.set_domain_id(domain_id) 43 | bbc_app_client.set_callback(bbc_app.Callback()) 44 | ret = bbc_app_client.register_to_core() 45 | assert ret 46 | return bbc_app_client 47 | 48 | 49 | def search_transaction(domain_id, txid): 50 | """ 51 | Search transaction with the given transaction_id 52 | :param domain_id: 53 | :param txid: 54 | :return: 55 | """ 56 | bbc_app_client = setup_bbc_client(domain_id, user_id) 57 | bbc_app_client.search_transaction(transaction_id=txid) 58 | response_data = bbc_app_client.callback.synchronize() 59 | if response_data[KeyType.status] < ESUCCESS: 60 | print("ERROR: ", response_data[KeyType.reason].decode()) 61 | return None 62 | 63 | obj, fmt_type = bbclib.deserialize(response_data[KeyType.transaction_data]) 64 | return obj 65 | 66 | 67 | def argument_parser(): 68 | argparser = argparse.ArgumentParser(description='Generate a transaction and register it to bbc_core') 69 | argparser.add_argument('-i', '--id_file', action='store', default="ID_FILE", help='file including user_id of the user') 70 | argparser.add_argument('-t', '--transaction_id', action='store', help='transaction_id to search') 71 | return argparser.parse_args() 72 | 73 | 74 | if __name__ == '__main__': 75 | parsed_args = argument_parser() 76 | if not os.path.exists(parsed_args.id_file): 77 | print("No id_file") 78 | sys.exit(1) 79 | 80 | # read domain_id config in the upper directory (filename is DOMAIN_ID) 81 | with open("../DOMAIN_ID", "r") as f: 82 | domain_id_str = f.readline() 83 | domain_id = binascii.a2b_hex(domain_id_str.rstrip()) 84 | 85 | # set user_id from the user information file (JSON formatted) 86 | with open(parsed_args.id_file, "r") as f: 87 | user_info = json.load(f) 88 | user_id = binascii.a2b_hex(user_info["id"]) 89 | 90 | # main part (search transaction) 91 | txid_to_search = binascii.a2b_hex(parsed_args.transaction_id) 92 | txobj = search_transaction(domain_id, txid_to_search) 93 | print(txobj) 94 | 95 | # show asset body 96 | asset_body = txobj.relations[0].asset.asset_body 97 | body_data = msgpack.loads(asset_body) 98 | print("# The content of the asset body") 99 | pprint.pprint(body_data) 100 | -------------------------------------------------------------------------------- /examples/starter/scripts/run_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! -f ../venv/bin/activate ]]; then 4 | echo 'Run "starter.sh install" to prepare the environment' 5 | exit 1 6 | fi 7 | 8 | if [ $# -ne 1 -a $# -ne 2 ]; then 9 | echo "Usage: $0 [register|show_all|print]" 10 | exit 1 11 | fi 12 | 13 | . ../venv/bin/activate 14 | 15 | 16 | case $1 in 17 | register) 18 | python register_a_transaction.py -i ID_FILE 19 | ;; 20 | 21 | show_all) 22 | python show_transactions.py -i ID_FILE 23 | ;; 24 | 25 | print) 26 | python print_transaction.py -i ID_FILE -t $2 27 | ;; 28 | 29 | *) 30 | echo "Usage: $0 [register|show_all|print]" 31 | exit 1 32 | esac 33 | -------------------------------------------------------------------------------- /examples/starter/scripts/show_transactions.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2018 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | import binascii 24 | import os 25 | import json 26 | import sys 27 | 28 | from bbc1.core import bbc_app 29 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT 30 | from bbc1.core import bbclib 31 | from bbc1.core.message_key_types import KeyType 32 | from bbc1.core.bbc_error import * 33 | 34 | 35 | asset_group_id = bbclib.get_new_id("test_asset_group", include_timestamp=False) 36 | 37 | 38 | def setup_bbc_client(domain_id, user_id): 39 | bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, multiq=False, loglevel="all") 40 | bbc_app_client.set_user_id(user_id) 41 | bbc_app_client.set_domain_id(domain_id) 42 | bbc_app_client.set_callback(bbc_app.Callback()) 43 | ret = bbc_app_client.register_to_core() 44 | assert ret 45 | return bbc_app_client 46 | 47 | 48 | def search_all_transactions_of_user(domain_id, user_id): 49 | """ 50 | Search all transactions with the specified user's asset and return the list of the transactions 51 | :param domain_id: 52 | :param user_id: 53 | :return: 54 | """ 55 | bbc_app_client = setup_bbc_client(domain_id, user_id) 56 | bbc_app_client.search_transaction_with_condition(asset_group_id=asset_group_id, user_id=user_id, direction=0, count=30) # direction=0 means that the result is sorted in descending order in terms of timestamp (direction=1 means ascending) 57 | response_data = bbc_app_client.callback.synchronize() 58 | if response_data[KeyType.status] < ESUCCESS: 59 | print("ERROR: ", response_data[KeyType.reason].decode()) 60 | return None 61 | 62 | txlist = list() 63 | for txdat in response_data[KeyType.transactions]: 64 | obj, fmt_type = bbclib.deserialize(txdat) 65 | txlist.append(obj) 66 | 67 | return txlist 68 | 69 | 70 | def argument_parser(): 71 | argparser = argparse.ArgumentParser(description='Generate a transaction and register it to bbc_core') 72 | argparser.add_argument('-i', '--id_file', action='store', default="ID_FILE", help='file including user_id of the user') 73 | return argparser.parse_args() 74 | 75 | 76 | if __name__ == '__main__': 77 | parsed_args = argument_parser() 78 | if not os.path.exists(parsed_args.id_file): 79 | print("No id_file") 80 | sys.exit(1) 81 | 82 | # read domain_id config in the upper directory (filename is DOMAIN_ID) 83 | with open("../DOMAIN_ID", "r") as f: 84 | domain_id_str = f.readline() 85 | domain_id = binascii.a2b_hex(domain_id_str.rstrip()) 86 | 87 | # set user_id from the user information file (JSON formatted) 88 | with open(parsed_args.id_file, "r") as f: 89 | user_info = json.load(f) 90 | user_id = binascii.a2b_hex(user_info["id"]) 91 | 92 | # main part (search transactions) 93 | txobj_list = search_all_transactions_of_user(domain_id, user_id) 94 | 95 | print("# Summary") 96 | print("-- user_id = %s" % user_id.hex()) 97 | if txobj_list is None: 98 | print("-- the number of transactions of the user: 0") 99 | else: 100 | print("-- the number of transactions of the user: %d" % len(txobj_list)) 101 | print("-- the list of transaction_id") 102 | for txobj in txobj_list: 103 | print(" * transaction_id: %s (timestamp=%d)" % (txobj.transaction_id.hex(), txobj.timestamp)) 104 | -------------------------------------------------------------------------------- /examples/starter/starter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | COMMAND=$1 5 | ARG=$2 6 | 7 | 8 | case ${COMMAND} in 9 | install) 10 | echo "# Prepare a python3 virtual environment and install modules" 11 | python3 -mvenv venv 12 | . venv/bin/activate 13 | pip install -r requirements.txt 14 | pip --no-cache-dir install bbc1 15 | ;; 16 | 17 | clean) 18 | echo "# Clean up the BBc-1 working directory" 19 | rm -rf ./.bbc1 20 | rm -f DOMAIN_ID 21 | ;; 22 | 23 | setup) 24 | echo "# Setup a domain" 25 | . venv/bin/activate 26 | bbc_core.py -w .bbc1 --no_nodekey -d > /dev/null 2>&1 27 | sleep 1 28 | DOMAIN_ID=`id_create.py -s test_domain_seed` 29 | echo " -- setup domain_id=${DOMAIN_ID}" 30 | echo "${DOMAIN_ID}" > DOMAIN_ID 31 | bbc_domain_update.py -a -d ${DOMAIN_ID} 32 | bbc_core.py -k 33 | ;; 34 | 35 | core) 36 | echo "# Start bbc_core in background" 37 | . venv/bin/activate 38 | bbc_core.py -w .bbc1 --no_nodekey -d > /dev/null 2>&1 39 | ;; 40 | 41 | create) 42 | if [[ ${ARG} == "" ]]; then 43 | echo "Usage: $0 create [username]" 44 | exit 45 | fi 46 | . venv/bin/activate 47 | echo "# Create a user: ${ARG}" 48 | mkdir ${ARG} 49 | [[ $? -gt 0 ]] && exit 50 | cp scripts/* ${ARG}/ 51 | cd ${ARG} 52 | echo " -- create key pair for user: ${ARG}" 53 | python create_userid_keypair.py -u ${ARG} 54 | ;; 55 | 56 | remove) 57 | if [[ ${ARG} == "" ]]; then 58 | echo "Usage: $0 remove [username]" 59 | exit 60 | fi 61 | echo "# Remove user: ${ARG}" 62 | if [[ -f ${ARG}/ID_FILE ]]; then 63 | rm -rf ${ARG} 64 | echo " -- Removed!" 65 | fi 66 | ;; 67 | 68 | run) 69 | cd ${ARG} 70 | bash run_script.sh register 71 | ;; 72 | 73 | show) 74 | cd ${ARG} 75 | bash run_script.sh show_all 76 | ;; 77 | 78 | kill) 79 | echo "# Kill bbc_core" 80 | . venv/bin/activate 81 | bbc_core.py -k 82 | ;; 83 | 84 | *) 85 | echo "Usage: $0 [install|clean|setup|core|create|remove|run|show|kill]" 86 | ;; 87 | esac 88 | -------------------------------------------------------------------------------- /prepare-apidoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . venv/bin/activate 4 | 5 | pip install -r requirements.txt 6 | pip install sphinx sphinx_rtd_theme 7 | 8 | sphinx-apidoc -F -e -o docs/api/ bbc1 9 | cd docs/api 10 | 11 | rm -f bbc1.core.libbbcsig.test_ecdsa.rst 12 | 13 | make html 14 | -------------------------------------------------------------------------------- /prepare.py: -------------------------------------------------------------------------------- 1 | import os, shutil, site 2 | 3 | sitedir = None 4 | if hasattr(site, 'getsitepackages'): 5 | # normal execution 6 | sitepackages = site.getsitepackages() 7 | sitedir = sitepackages[0] 8 | else: 9 | # workaround for virtualenv 10 | from distutils.sysconfig import get_python_lib 11 | sitepackages = [get_python_lib()] 12 | sitedir = sitepackages[0] 13 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | attrs==21.2.0 2 | bson==0.5.10 3 | certifi==2020.12.5 4 | cffi==1.14.5 5 | chardet==4.0.0 6 | click==7.1.2 7 | cryptography==3.4.7 8 | Flask==1.1.2 9 | gevent==21.1.2 10 | greenlet==1.1.0 11 | idna==2.10 12 | iniconfig==1.1.1 13 | itsdangerous==1.1.0 14 | Jinja2==2.11.3 15 | MarkupSafe==1.1.1 16 | msgpack-python==0.5.6 17 | mysql-connector-python==8.0.24 18 | packaging==20.9 19 | pluggy==0.13.1 20 | protobuf==3.16.0 21 | py==1.10.0 22 | py-bbclib==1.6.1 23 | pycparser==2.20 24 | pyOpenSSL==20.0.1 25 | pyparsing==2.4.7 26 | pytest==6.2.4 27 | python-dateutil==2.8.1 28 | requests==2.25.1 29 | six==1.16.0 30 | toml==0.10.2 31 | urllib3==1.26.4 32 | Werkzeug==1.0.1 33 | zope.event==4.5.0 34 | zope.interface==5.4.0 35 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | import os 4 | from os import path 5 | from setuptools import setup 6 | from setuptools.command.install import install 7 | 8 | VERSION = "1.5.1" 9 | 10 | here = path.abspath(path.dirname(__file__)) 11 | 12 | with open('README.rst') as f: 13 | readme = f.read() 14 | 15 | 16 | class MyInstall(install): 17 | def run(self): 18 | try: 19 | subprocess.call(['python', 'prepare.py'], cwd=here) 20 | except Exception as e: 21 | print(e) 22 | print("Error compiling openssl.") 23 | exit(1) 24 | else: 25 | install.run(self) 26 | 27 | 28 | class VerifyVersionCommand(install): 29 | """Custom command to verify that the git tag matches our version""" 30 | description = 'verify that the git tag matches our version' 31 | 32 | def run(self): 33 | tag = os.getenv('CIRCLE_TAG') 34 | 35 | if tag != "v%s" % VERSION: 36 | info = "Git tag: {0} does not match the version of this app: {1}".format( 37 | tag, "v%s" % VERSION 38 | ) 39 | sys.exit(info) 40 | 41 | 42 | bbc1_requires = [ 43 | 'pyOpenSSL>=16.2.0', 44 | 'jinja2>=2.8.1', 45 | 'requests>=2.12.4', 46 | 'gevent>=1.2.1', 47 | 'cryptography>=2.1.4', 48 | 'pytest>=5.3.0', 49 | 'msgpack-python>=0.4.8', 50 | 'mysql-connector-python>=8.0.5', 51 | 'py-bbclib>=1.6', 52 | 'greenlet', 53 | 'bson', 54 | 'Flask>=0.10.1,<=1.0.1' 55 | ] 56 | 57 | bbc1_packages = ['bbc1', 'bbc1.core'] 58 | 59 | bbc1_commands = [ 60 | 'bbc1/core/bbc_core.py', 61 | 'utils/bbc_domain_config.py', 62 | 'utils/bbc_domain_update.py', 63 | 'utils/bbc_info.py', 64 | 'utils/bbc_ping.py', 65 | 'utils/domain_key_setup.py', 66 | 'utils/id_create.py', 67 | 'utils/db_migration_tool.py', 68 | 'examples/file_proof/file_proof.py'] 69 | 70 | bbc1_classifiers = [ 71 | 'Development Status :: 4 - Beta', 72 | 'Programming Language :: Python :: 3.5', 73 | 'Programming Language :: Python :: 3.6', 74 | 'Programming Language :: Python :: 3.7', 75 | 'Topic :: Software Development'] 76 | 77 | setup( 78 | name='bbc1', 79 | version=VERSION, 80 | description='A core system of Beyond Blockchain One', 81 | long_description_content_type='text/markdown', 82 | long_description=readme, 83 | url='https://github.com/beyond-blockchain/bbc1', 84 | author='beyond-blockchain.org', 85 | author_email='bbc1-dev@beyond-blockchain.org', 86 | license='Apache License 2.0', 87 | classifiers=bbc1_classifiers, 88 | cmdclass={'install': MyInstall, 'verify': VerifyVersionCommand}, 89 | packages=bbc1_packages, 90 | scripts=bbc1_commands, 91 | install_requires=bbc1_requires, 92 | zip_safe=False) 93 | 94 | -------------------------------------------------------------------------------- /tests/compat/testutils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import binascii 3 | import os 4 | import shutil 5 | import threading 6 | import time 7 | import copy 8 | 9 | import sys 10 | sys.path.extend(["../"]) 11 | from bbc1.core.compat import bbclib, bbc_app 12 | from bbc1.core.message_key_types import KeyType 13 | from bbc1.core import bbc_core 14 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT, DEFAULT_P2P_PORT 15 | 16 | cores = None 17 | clients = None 18 | stats = None 19 | common_domain_id = None 20 | loglv = 'debug' 21 | config_file = None 22 | 23 | 24 | def prepare(core_num=1, client_num=1, conf_file=None, loglevel='debug'): 25 | global cores, clients, stats, config_file, loglv 26 | cores = [None for i in range(core_num)] 27 | stats = [None for i in range(core_num)] 28 | clients = [dict() for i in range(client_num)] 29 | loglv = loglevel 30 | config_file = conf_file 31 | 32 | 33 | def get_core_client(): 34 | return cores, clients 35 | 36 | 37 | def start_core_thread(index, core_port_increment=0, p2p_port_increment=0, 38 | use_nodekey=True, use_domain0=False, remove_dir=True): 39 | core_port = DEFAULT_CORE_PORT + core_port_increment 40 | p2p_port = DEFAULT_P2P_PORT + p2p_port_increment 41 | th = threading.Thread(target=start_core, args=(index, core_port, p2p_port, use_nodekey, use_domain0, remove_dir,)) 42 | th.setDaemon(True) 43 | th.start() 44 | time.sleep(0.1) 45 | 46 | 47 | def start_core(index, core_port, p2p_port, use_nodekey=True, use_domain0=False, remove_dir=True): 48 | print("** [%d] start: port=%i" % (index, core_port)) 49 | working_dir = ".bbc1-%i/" % core_port 50 | if remove_dir and os.path.exists(working_dir): 51 | shutil.rmtree(working_dir) 52 | os.makedirs(working_dir) 53 | if config_file is not None: 54 | shutil.copyfile(config_file, os.path.join(working_dir, "config.json")) 55 | cores[index] = bbc_core.BBcCoreService(p2p_port=p2p_port, core_port=core_port, 56 | workingdir=working_dir, 57 | use_nodekey=use_nodekey, 58 | use_domain0=use_domain0, 59 | server_start=False, 60 | loglevel=loglv) 61 | cores[index]._start_server(port=core_port) 62 | 63 | 64 | def domain_setup_utility(core_port_increment, dom_id): 65 | cl = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT + core_port_increment, multiq=False) 66 | working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment) 67 | if os.path.exists(os.path.join(working_dir, "node_key.pem")): 68 | cl.set_node_key(os.path.join(working_dir, "node_key.pem")) 69 | cl.domain_setup(dom_id) 70 | global common_domain_id 71 | common_domain_id = dom_id 72 | wait_check_result_msg_type(cl.callback, bbclib.MsgType.RESPONSE_SETUP_DOMAIN) 73 | cl.unregister_from_core() 74 | 75 | 76 | def make_client(index, core_port_increment, callback=None, connect_to_core=True, domain_id=None): 77 | keypair = bbclib.KeyPair() 78 | keypair.generate() 79 | clients[index]['user_id'] = bbclib.get_new_id("user_%i" % index) 80 | clients[index]['keypair'] = keypair 81 | clients[index]['app'] = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT + core_port_increment, 82 | multiq=False, loglevel=loglv) 83 | if connect_to_core: 84 | if domain_id is None: 85 | global common_domain_id 86 | domain_id = common_domain_id 87 | clients[index]['app'].set_user_id(clients[index]['user_id']) 88 | clients[index]['app'].set_domain_id(domain_id) 89 | if callback is not None: 90 | clients[index]['app'].set_callback(callback) 91 | working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment) 92 | if os.path.exists(os.path.join(working_dir, "node_key.pem")): 93 | clients[index]['app'].set_node_key(os.path.join(working_dir, "node_key.pem")) 94 | time.sleep(1) 95 | print("[%i] user_id = %s" % (index, binascii.b2a_hex(clients[index]['user_id']))) 96 | 97 | 98 | def get_random_data(length=16): 99 | import random 100 | source_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 101 | return "".join([random.choice(source_str) for x in range(length)]) 102 | 103 | 104 | def wait_check_result_msg_type(callback, msg_type): 105 | dat = callback.synchronize() 106 | if dat[KeyType.command] != msg_type: 107 | print("XXXXXX not expected result: %d <=> %d(received)" % (msg_type, dat[KeyType.command])) 108 | return dat 109 | 110 | 111 | def get_stats(i): 112 | global stats 113 | stats[i] = copy.deepcopy(cores[i].stats.get_stats()) 114 | 115 | 116 | def get_stat_diffs(i): 117 | stats_diff = copy.deepcopy(cores[i].stats.get_stats()) 118 | for key in stats_diff.keys(): 119 | for key2 in stats_diff[key].keys(): 120 | if key in stats[i]: 121 | stats_diff[key][key2] -= stats[i][key].get(key2, 0) 122 | get_stats(i) 123 | return stats_diff 124 | -------------------------------------------------------------------------------- /tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | addopts = --capture=no 3 | markers = 4 | register: exec register 5 | unregister: exec unregister 6 | -------------------------------------------------------------------------------- /tests/sample_config.json: -------------------------------------------------------------------------------- 1 | {"workingdir": ".bbc1", "client": {"port": 9000}, "network": {"p2p_port": 6641, "max_connections": 100}, "domain_auth_key": {"use": false, "directory": ".bbc1", "obsolete_timeout": 300}, "domains": {"0000000000000000000000000000000000000000000000000000000000000000": {"module": "p2p_domain0", "static_nodes": {}, "use_ledger_subsystem": false, "ledger_subsystem": {"max_transactions": 4096, "max_seconds": 3600, "subsystem": "ethereum"}}}, "ethereum": {"chain_id": 15, "port": 30303, "log": "geth.log", "account": "", "passphrase": "", "contract": "BBcAnchor", "contract_address": ""}} -------------------------------------------------------------------------------- /tests/test_bbc_app_domain_setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import json 5 | import time 6 | 7 | import sys 8 | sys.path.extend(["../"]) 9 | from bbc1.core import bbclib 10 | from testutils import prepare, get_core_client, start_core_thread, make_client, domain_setup_utility 11 | 12 | LOGLEVEL = 'debug' 13 | LOGLEVEL = 'info' 14 | 15 | 16 | core_num = 1 17 | client_num = 1 18 | cores = None 19 | clients = None 20 | domain_id = bbclib.get_new_id("testdomain") 21 | 22 | 23 | class TestBBcAppClient(object): 24 | 25 | def test_00_setup(self): 26 | print("\n-----", sys._getframe().f_code.co_name, "-----") 27 | 28 | prepare(core_num=core_num, client_num=client_num) 29 | for i in range(core_num): 30 | start_core_thread(index=i) 31 | make_client(index=i, core_port_increment=0) 32 | time.sleep(1) 33 | 34 | global cores, clients 35 | cores, clients = get_core_client() 36 | 37 | def test_01_create_domain_with_custom_config(self): 38 | print("\n-----", sys._getframe().f_code.co_name, "-----") 39 | conf = { 40 | 'workingdir': ".bbc1-9000", 41 | 'client': { 42 | 'port': 9000, 43 | 'use_node_key': True, 44 | }, 45 | 'network': { 46 | 'p2p_port': 6641, 47 | 'max_connections': 10000, 48 | }, 49 | 'domain_key': { 50 | 'use': False, 51 | 'directory': ".bbc1-9000" + "/domain_keys", 52 | 'obsolete_timeout': 30000, 53 | }, 54 | } 55 | jsonconf = json.dumps(conf) 56 | clients[0]['app'].domain_setup(domain_id, config=jsonconf) 57 | dat = clients[0]['app'].callback.synchronize() 58 | print(dat) 59 | 60 | def test_02_get_config(self): 61 | print("\n-----", sys._getframe().f_code.co_name, "-----") 62 | clients[0]['app'].register_to_core() 63 | 64 | clients[0]['app'].get_bbc_config() 65 | dat = clients[0]['app'].callback.synchronize() 66 | print(dat) 67 | 68 | 69 | if __name__ == '__main__': 70 | pytest.main() 71 | 72 | -------------------------------------------------------------------------------- /tests/test_bbc_app_encryption.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import binascii 5 | import time 6 | 7 | import sys 8 | sys.path.extend(["../"]) 9 | from bbc1.core import bbclib 10 | from bbc1.core import message_key_types, bbc_app 11 | from bbc1.core.message_key_types import KeyType 12 | from bbc1.core.bbc_error import * 13 | from testutils import prepare, get_core_client, start_core_thread, make_client, domain_setup_utility, wait_check_result_msg_type 14 | 15 | LOGLEVEL = 'debug' 16 | LOGLEVEL = 'info' 17 | 18 | core_num = 1 19 | client_num = 1 20 | cores = None 21 | clients = None 22 | domain_id = bbclib.get_new_id("testdomain") 23 | asset_group_id = bbclib.get_new_id("asset_group_1") 24 | transactions = [None for i in range(client_num)] 25 | 26 | msg_processor = [None for i in range(client_num)] 27 | 28 | 29 | class MessageProcessor(bbc_app.Callback): 30 | def __init__(self, index=0): 31 | super(MessageProcessor, self).__init__(self) 32 | self.idx = index 33 | 34 | def proc_resp_search_asset(self, dat): 35 | if KeyType.transaction_data in dat: 36 | self.logger.info("OK: Asset [%s] is found." % binascii.b2a_hex(dat[KeyType.asset_id])) 37 | tx_obj, fmt_type = bbclib.deserialize(dat[KeyType.transaction_data]) 38 | for evt in tx_obj.events: 39 | if evt.asset.asset_body_size > 0: 40 | self.logger.info(" [%s] asset_body --> %s" % (binascii.b2a_hex(evt.asset.asset_id[:4]), 41 | evt.asset.asset_body)) 42 | else: 43 | self.logger.info("NG.....") 44 | self.queue.put(dat) 45 | 46 | 47 | class TestBBcAppClient(object): 48 | 49 | def test_00_setup(self): 50 | print("\n-----", sys._getframe().f_code.co_name, "-----") 51 | 52 | global msg_processor 53 | prepare(core_num=core_num, client_num=client_num, loglevel=LOGLEVEL) 54 | for i in range(core_num): 55 | start_core_thread(index=i) 56 | domain_setup_utility(i, domain_id) # system administrator 57 | msg_processor[i] = MessageProcessor(index=i) 58 | make_client(index=i, core_port_increment=0, callback=msg_processor[i]) 59 | time.sleep(1) 60 | 61 | global cores, clients 62 | cores, clients = get_core_client() 63 | for i in range(client_num): 64 | msg_processor[i].set_client(clients[i]['app']) 65 | 66 | def test_01_key_exchange(self): 67 | print("\n-----", sys._getframe().f_code.co_name, "-----") 68 | for i in range(client_num): 69 | clients[i]['app'].exchange_key() 70 | dat = msg_processor[0].synchronize() 71 | assert dat 72 | assert len(message_key_types.encryptors) == client_num * 2 73 | 74 | def test_02_register(self): 75 | print("\n-----", sys._getframe().f_code.co_name, "-----") 76 | for i in range(client_num): 77 | ret = clients[i]['app'].register_to_core() 78 | assert ret 79 | 80 | ret = clients[0]['app'].get_domain_neighborlist(domain_id=domain_id) 81 | assert ret 82 | dat = msg_processor[0].synchronize() 83 | print("nodeinfo=",dat) 84 | 85 | def test_02_make_transaction(self): 86 | print("\n-----", sys._getframe().f_code.co_name, "-----") 87 | user = clients[0]['user_id'] 88 | global transactions 89 | transactions[0] = bbclib.make_transaction(event_num=2, witness=True) 90 | transactions[0].events[0].add(reference_index=0, mandatory_approver=user) 91 | bbclib.add_event_asset(transactions[0], event_idx=0, asset_group_id=asset_group_id, 92 | user_id=user, asset_body=b'123456') 93 | bbclib.add_event_asset(transactions[0], event_idx=1, asset_group_id=asset_group_id, 94 | user_id=user, asset_body=b'abcdefg') 95 | 96 | transactions[0].witness.add_witness(user) 97 | 98 | def test_03_insert(self): 99 | print("\n-----", sys._getframe().f_code.co_name, "-----") 100 | sig = transactions[0].sign(keypair=clients[0]['keypair']) 101 | assert sig is not None 102 | if sig is None: 103 | print(bbclib.error_text) 104 | import os 105 | os._exit(1) 106 | transactions[0].witness.add_signature(user_id=clients[0]['user_id'], signature=sig) 107 | print(transactions[0]) 108 | transactions[0].digest() 109 | print("register transaction=", binascii.b2a_hex(transactions[0].transaction_id)) 110 | clients[0]['app'].insert_transaction(transactions[0]) 111 | dat = wait_check_result_msg_type(msg_processor[0], bbclib.MsgType.RESPONSE_INSERT) 112 | assert dat[KeyType.status] == ESUCCESS 113 | 114 | def test_07_search_asset0(self): 115 | print("\n-----", sys._getframe().f_code.co_name, "-----") 116 | asid = transactions[0].events[0].asset.asset_id 117 | print(" search for asset:%s"%binascii.b2a_hex(asid)) 118 | clients[0]['app'].search_transaction_with_condition(asset_group_id=asset_group_id, asset_id=asid) 119 | dat = wait_check_result_msg_type(msg_processor[0], bbclib.MsgType.RESPONSE_SEARCH_WITH_CONDITIONS) 120 | assert dat[KeyType.status] == ESUCCESS 121 | print(dat) 122 | assert KeyType.transactions in dat 123 | 124 | @pytest.mark.unregister 125 | def test_99_unregister(self): 126 | print("\n-----", sys._getframe().f_code.co_name, "-----") 127 | for i in range(client_num): 128 | clients[i]['app'].unregister_from_core() 129 | time.sleep(1) 130 | assert len(message_key_types.encryptors) == 0 131 | 132 | 133 | if __name__ == '__main__': 134 | pytest.main() 135 | 136 | -------------------------------------------------------------------------------- /tests/test_bbc_app_multi_core_anycast.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import binascii 5 | import time 6 | 7 | import os 8 | import sys 9 | sys.path.extend(["../"]) 10 | from bbc1.core import bbclib 11 | from bbc1.core.message_key_types import KeyType 12 | from bbc1.core import bbc_app 13 | from testutils import prepare, get_core_client, start_core_thread, make_client, domain_setup_utility 14 | 15 | 16 | LOGLEVEL = 'debug' 17 | #LOGLEVEL = 'info' 18 | 19 | 20 | core_num = 5 21 | client_num = 5 22 | cores = None 23 | clients = None 24 | domain_id = bbclib.get_new_id("testdomain") 25 | 26 | anycast_id = bbclib.get_new_id() 27 | 28 | msg_processor = [None for i in range(client_num)] 29 | 30 | 31 | class MessageProcessor(bbc_app.Callback): 32 | def __init__(self, index=0): 33 | super(MessageProcessor, self).__init__(self) 34 | self.idx = index 35 | 36 | def proc_user_message(self, dat): 37 | print("User[%d] receives message:%s" % (self.idx, dat[KeyType.message])) 38 | 39 | 40 | class TestBBcAppClient(object): 41 | 42 | def test_00_setup(self): 43 | print("\n-----", sys._getframe().f_code.co_name, "-----") 44 | print("domain_id =", binascii.b2a_hex(domain_id)) 45 | 46 | keypair = bbclib.KeyPair() 47 | keypair.generate() 48 | keyname = domain_id.hex() + ".pem" 49 | try: 50 | os.mkdir(".bbc1") 51 | except: 52 | pass 53 | with open(os.path.join(".bbc1", keyname), "wb") as f: 54 | f.write(keypair.get_private_key_in_pem()) 55 | 56 | global msg_processor 57 | prepare(core_num=core_num, client_num=client_num, loglevel=LOGLEVEL) 58 | for i in range(core_num): 59 | start_core_thread(index=i, core_port_increment=i, p2p_port_increment=i) 60 | time.sleep(0.1) 61 | domain_setup_utility(i, domain_id) # system administrator 62 | time.sleep(1) 63 | for i in range(client_num): 64 | msg_processor[i] = MessageProcessor(index=i) 65 | make_client(index=i, core_port_increment=i, callback=msg_processor[i]) 66 | time.sleep(1) 67 | 68 | global cores, clients 69 | cores, clients = get_core_client() 70 | 71 | def test_10_register(self): 72 | print("\n-----", sys._getframe().f_code.co_name, "-----") 73 | for cl in clients: 74 | ret = cl['app'].register_to_core() 75 | assert ret 76 | time.sleep(1) 77 | 78 | def test_11_setup_network(self): 79 | print("\n-----", sys._getframe().f_code.co_name, "-----") 80 | ret = clients[0]['app'].get_domain_neighborlist(domain_id=domain_id) 81 | assert ret 82 | dat = msg_processor[0].synchronize() 83 | print("[0] nodeinfo=",dat[0]) 84 | node_id, ipv4, ipv6, port, domain0 = dat[0] 85 | 86 | for i in range(1, client_num): 87 | ret = clients[i]['app'].set_domain_static_node(domain_id, node_id, ipv4, ipv6, port) 88 | assert ret 89 | ret = msg_processor[i].synchronize() 90 | print("[%d] set_domain_static_node result is %s" %(i, ret)) 91 | time.sleep(5) 92 | 93 | for i in range(client_num): 94 | clients[i]['app'].get_domain_neighborlist(domain_id=domain_id) 95 | dat = msg_processor[i].synchronize() 96 | assert len(dat) == core_num 97 | 98 | def test_12_register(self): 99 | print("\n-----", sys._getframe().f_code.co_name, "-----") 100 | for cl in clients: 101 | cl['user_id'] = anycast_id 102 | cl['app'].set_user_id(anycast_id) 103 | ret = cl['app'].register_to_core(on_multiple_nodes=True) 104 | assert ret 105 | time.sleep(1) 106 | 107 | def test_30_messaging(self): 108 | print("\n-----", sys._getframe().f_code.co_name, "-----") 109 | for k in range(5): 110 | for i in range(client_num): 111 | msg = "message %d" % i 112 | clients[i]['app'].send_message(msg, anycast_id, is_anycast=True) 113 | print("--- wait 3 seconds ---") 114 | time.sleep(3) 115 | 116 | 117 | if __name__ == '__main__': 118 | pytest.main() 119 | -------------------------------------------------------------------------------- /tests/test_bbc_config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import binascii 5 | import sys 6 | sys.path.extend(["../"]) 7 | from bbc1.core import bbclib 8 | from bbc1.core.bbc_config import BBcConfig 9 | 10 | 11 | config = None 12 | 13 | 14 | class TestBBcConfig(object): 15 | 16 | def test_00_load(self): 17 | print("-----", sys._getframe().f_code.co_name, "-----") 18 | global config 19 | config = BBcConfig() 20 | print(config.get_config()) 21 | assert config is not None 22 | 23 | def test_01_update(self): 24 | print("-----", sys._getframe().f_code.co_name, "-----") 25 | conf = config.get_config() 26 | conf['network']['ipv4'] = False 27 | with open(".bbc1/config.json", "r") as f: 28 | print(f.read()) 29 | config.update_config() 30 | with open(".bbc1/config.json", "r") as f: 31 | print(f.read()) 32 | 33 | def test_02_add_node(self): 34 | print("-----", sys._getframe().f_code.co_name, "-----") 35 | domain_id = binascii.a2b_hex("0000000000000000000000000000000000000000000000000000000000000000") 36 | dconf = config.get_domain_config(domain_id) 37 | assert dconf is not None 38 | 39 | node_id_str = bbclib.convert_id_to_string(bbclib.get_new_id("testnode1")) 40 | dconf['static_nodes'][node_id_str] = [1, 2, 3] 41 | config.update_config() 42 | with open(".bbc1/config.json", "r") as f: 43 | print(f.read()) 44 | 45 | -------------------------------------------------------------------------------- /tests/test_bbc_network.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import shutil 5 | import queue 6 | import time 7 | 8 | import os 9 | import sys 10 | sys.path.extend(["../"]) 11 | 12 | from bbc1.core import bbclib 13 | from bbc1.core import bbc_network, bbc_config, query_management, bbc_stats 14 | from bbc1.core.topology_manager import TopologyManagerBase 15 | 16 | LOGLEVEL = 'debug' 17 | LOGLEVEL = 'info' 18 | 19 | ticker = query_management.get_ticker() 20 | core_nodes = 10 21 | networkings = [None for i in range(core_nodes)] 22 | nodes = [None for i in range(core_nodes)] 23 | 24 | domain_id = bbclib.get_new_id("test_domain") 25 | asset_group_id = bbclib.get_new_id("asset_group_1") 26 | users = [bbclib.get_new_id("test_user_%i" % i) for i in range(core_nodes)] 27 | 28 | result_queue = queue.Queue() 29 | 30 | sample_resource_id = bbclib.get_new_id("sample_resource_id") 31 | 32 | 33 | def get_random_data(length=16): 34 | import random 35 | source_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 36 | return "".join([random.choice(source_str) for x in range(length)]) 37 | 38 | 39 | class DummyCore: 40 | class UserMessageRouting: 41 | def add_domain(self, domain_id): 42 | pass 43 | 44 | def remove_domain(self, domain_id): 45 | pass 46 | 47 | def __init__(self): 48 | self.user_message_routing = DummyCore.UserMessageRouting() 49 | self.stats = bbc_stats.BBcStats() 50 | 51 | 52 | class TestBBcNetwork(object): 53 | 54 | def test_01_start(self): 55 | print("\n-----", sys._getframe().f_code.co_name, "-----") 56 | 57 | TopologyManagerBase.NEIGHBOR_LIST_REFRESH_INTERVAL = 15 58 | dummycore = DummyCore() 59 | global networkings, nodes, conf 60 | for i, nw in enumerate(networkings): 61 | if os.path.exists(".bbc1-%d"%i): 62 | shutil.rmtree(".bbc1-%d"%i) 63 | config = bbc_config.BBcConfig(directory=".bbc1-%d"%i) 64 | networkings[i] = bbc_network.BBcNetwork(core=dummycore, config=config, p2p_port=6641+i, loglevel=LOGLEVEL) 65 | networkings[i].create_domain(domain_id=domain_id) 66 | nodes[i] = networkings[i].domains[domain_id]['neighbor'].my_node_id 67 | assert nodes[i] is not None 68 | assert networkings[i].ip_address != '' 69 | print("IPv4: %s, IPv6 %s, port: %d" % (networkings[i].ip_address, networkings[i].ip6_address, 70 | networkings[i].port)) 71 | 72 | def test_02_set_initial_peer(self): 73 | print("\n-----", sys._getframe().f_code.co_name, "-----") 74 | for i in range(core_nodes-5): 75 | networkings[i].add_neighbor(domain_id=domain_id, node_id=nodes[0], 76 | ipv4=networkings[0].ip_address, port=networkings[0].port) 77 | print(networkings[i].domains[domain_id]['neighbor'].show_list()) 78 | 79 | def test_03_wait_and_show(self): 80 | print("\n-----", sys._getframe().f_code.co_name, "-----") 81 | print("-- wait 4 seconds --") 82 | time.sleep(4) 83 | for i in range(core_nodes): 84 | print(networkings[i].domains[domain_id]['neighbor'].show_list()) 85 | 86 | def test_04_send_ping(self): 87 | print("\n-----", sys._getframe().f_code.co_name, "-----") 88 | ipv4 = networkings[0].ip_address 89 | ipv6 = networkings[0].ip6_address 90 | port = networkings[0].port 91 | for i in range(5, core_nodes): 92 | networkings[i].send_domain_ping(domain_id=domain_id, ipv4=ipv4, ipv6=ipv6, port=port, is_static=True) 93 | print("-- wait 5 seconds --") 94 | time.sleep(5) 95 | 96 | def test_05_wait_and_show(self): 97 | print("\n-----", sys._getframe().f_code.co_name, "-----") 98 | for i in range(core_nodes): 99 | print(networkings[i].domains[domain_id]['neighbor'].show_list()) 100 | assert len(list(networkings[i].domains[domain_id]['neighbor'].nodeinfo_list.keys())) == core_nodes - 1 101 | 102 | def test_06_leave_domain(self): 103 | print("\n-----", sys._getframe().f_code.co_name, "-----") 104 | networkings[core_nodes-1].remove_domain(domain_id) 105 | print("-- wait 5 seconds --") 106 | time.sleep(5) 107 | 108 | def test_07_wait_and_show(self): 109 | print("\n-----", sys._getframe().f_code.co_name, "-----") 110 | for i in range(core_nodes-1): 111 | print(networkings[i].domains[domain_id]['neighbor'].show_list()) 112 | assert len(list(networkings[i].domains[domain_id]['neighbor'].nodeinfo_list.keys())) == core_nodes - 2 113 | 114 | def test_08_long_wait_for_refresh(self): 115 | print("\n-----", sys._getframe().f_code.co_name, "-----") 116 | print("-- wait 20 seconds in total --") 117 | for i in range(4): 118 | time.sleep(5) 119 | print("* elapsed:", (i+1)*5) 120 | 121 | def test_09_save_list(self): 122 | print("\n-----", sys._getframe().f_code.co_name, "-----") 123 | networkings[0].save_all_static_node_list() 124 | with open(".bbc1-%d/config.json" % 0, "r") as f: 125 | dat = f.read() 126 | print(dat) 127 | 128 | 129 | if __name__ == '__main__': 130 | pytest.main() 131 | -------------------------------------------------------------------------------- /tests/test_bbc_network_encryption.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import shutil 5 | import queue 6 | import time 7 | 8 | import os 9 | import sys 10 | sys.path.extend(["../"]) 11 | 12 | from bbc1.core import bbclib 13 | from bbc1.core import bbc_network, bbc_config, query_management, bbc_stats, message_key_types 14 | from bbc1.core import key_exchange_manager 15 | from bbc1.core.topology_manager import TopologyManagerBase 16 | 17 | LOGLEVEL = 'debug' 18 | LOGLEVEL = 'info' 19 | 20 | ticker = query_management.get_ticker() 21 | core_nodes = 2 22 | networkings = [None for i in range(core_nodes)] 23 | nodes = [None for i in range(core_nodes)] 24 | 25 | domain_id = bbclib.get_new_id("test_domain") 26 | asset_group_id = bbclib.get_new_id("asset_group_1") 27 | users = [bbclib.get_new_id("test_user_%i" % i) for i in range(core_nodes)] 28 | key_names = [None for i in range(core_nodes)] 29 | result_queue = queue.Queue() 30 | 31 | sample_resource_id = bbclib.get_new_id("sample_resource_id") 32 | 33 | 34 | def get_random_data(length=16): 35 | import random 36 | source_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 37 | return "".join([random.choice(source_str) for x in range(length)]) 38 | 39 | 40 | def sleep_tick(wait_for): 41 | end_time = time.time() + wait_for 42 | while time.time() < end_time: 43 | print("(%d) .. waiting" % int(time.time())) 44 | time.sleep(1) 45 | 46 | 47 | class DummyCore: 48 | class UserMessageRouting: 49 | def add_domain(self, domain_id): 50 | pass 51 | 52 | def remove_domain(self, domain_id): 53 | pass 54 | 55 | def __init__(self): 56 | self.user_message_routing = DummyCore.UserMessageRouting() 57 | self.stats = bbc_stats.BBcStats() 58 | 59 | 60 | class TestBBcNetwork(object): 61 | 62 | def test_01_start(self): 63 | print("\n-----", sys._getframe().f_code.co_name, "-----") 64 | key_exchange_manager.KeyExchangeManager.KEY_EXCHANGE_INVOKE_MAX_BACKOFF = 1 65 | key_exchange_manager.KeyExchangeManager.KEY_EXCHANGE_RETRY_INTERVAL = 3 66 | key_exchange_manager.KeyExchangeManager.KEY_REFRESH_INTERVAL = 15 67 | key_exchange_manager.KeyExchangeManager.KEY_OBSOLETE_TIMER = 4 68 | TopologyManagerBase.NEIGHBOR_LIST_REFRESH_INTERVAL = 15 69 | dummycore = DummyCore() 70 | global networkings, nodes, conf 71 | for i, nw in enumerate(networkings): 72 | if os.path.exists(".bbc1-%d"%i): 73 | shutil.rmtree(".bbc1-%d"%i) 74 | config = bbc_config.BBcConfig(directory=".bbc1-%d"%i) 75 | networkings[i] = bbc_network.BBcNetwork(core=dummycore, config=config, p2p_port=6641+i, loglevel=LOGLEVEL) 76 | networkings[i].create_domain(domain_id=domain_id) 77 | nodes[i] = networkings[i].domains[domain_id]['neighbor'].my_node_id 78 | assert nodes[i] is not None 79 | assert networkings[i].ip_address != '' 80 | print("IPv4: %s, IPv6 %s, port: %d" % (networkings[i].ip_address, networkings[i].ip6_address, 81 | networkings[i].port)) 82 | 83 | def test_02_set_initial_peer(self): 84 | print("\n-----", sys._getframe().f_code.co_name, "-----") 85 | for i in range(1, core_nodes): 86 | networkings[i].add_neighbor(domain_id=domain_id, node_id=nodes[0], 87 | ipv4=networkings[0].ip_address, port=networkings[0].port) 88 | print(networkings[i].domains[domain_id]['neighbor'].show_list()) 89 | 90 | def test_03_wait_and_show(self): 91 | print("\n-----", sys._getframe().f_code.co_name, "-----") 92 | print("-- wait 2 seconds --") 93 | global key_names 94 | sleep_tick(2) 95 | for i in range(core_nodes): 96 | #print(networkings[i].domains[domain_id]['neighbor'].show_list()) 97 | for nd in networkings[i].domains[domain_id]['neighbor'].nodeinfo_list.values(): 98 | assert nd.key_manager.state == key_exchange_manager.KeyExchangeManager.STATE_ESTABLISHED 99 | assert nd.key_manager.key_name in message_key_types.encryptors 100 | key_names[i] = nd.key_manager.key_name 101 | 102 | for i in range(core_nodes): 103 | print("keynames[%d]=%s" % (i, key_names[i].hex()[:10])) 104 | for k in message_key_types.encryptors.keys(): 105 | print("key_name=%s" % k.hex()[:10]) 106 | 107 | def test_04_wait(self): 108 | print("\n-----", sys._getframe().f_code.co_name, "-----") 109 | print("-- wait 10 seconds (should be established) --") 110 | sleep_tick(10) 111 | for i in range(core_nodes): 112 | for nd in networkings[i].domains[domain_id]['neighbor'].nodeinfo_list.values(): 113 | assert nd.key_manager.state == key_exchange_manager.KeyExchangeManager.STATE_ESTABLISHED 114 | assert nd.key_manager.key_name in message_key_types.encryptors 115 | assert key_names[i] in message_key_types.encryptors 116 | for k in message_key_types.encryptors.keys(): 117 | print("key_name=%s" % k.hex()[:10]) 118 | 119 | def test_05_wait_refresh(self): 120 | print("\n-----", sys._getframe().f_code.co_name, "-----") 121 | print("-- wait 15 seconds (will occur refresh and re-established) --") 122 | sleep_tick(15) 123 | for k in message_key_types.encryptors.keys(): 124 | print("key_name=%s" % k.hex()[:10]) 125 | for i in range(core_nodes): 126 | for nd in networkings[i].domains[domain_id]['neighbor'].nodeinfo_list.values(): 127 | assert nd.key_manager.state == key_exchange_manager.KeyExchangeManager.STATE_ESTABLISHED 128 | assert nd.key_manager.key_name in message_key_types.encryptors 129 | assert key_names[i] not in message_key_types.encryptors 130 | assert len(message_key_types.encryptors) == 2 131 | 132 | 133 | if __name__ == '__main__': 134 | pytest.main() 135 | -------------------------------------------------------------------------------- /tests/test_bbc_ping.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import binascii 5 | import time 6 | import pprint 7 | 8 | import sys 9 | sys.path.extend(["../", "../utils"]) 10 | from bbc1.core import bbclib 11 | from bbc1.core import bbc_app 12 | from testutils import prepare, get_core_client, start_core_thread, make_client, domain_setup_utility 13 | 14 | 15 | LOGLEVEL = 'debug' 16 | #LOGLEVEL = 'info' 17 | 18 | localhost = "127.0.0.1" 19 | #localhost = "::1" 20 | 21 | core_num = 10 22 | client_num = 10 23 | cores = None 24 | clients = None 25 | domain_id = bbclib.get_new_id("testdomain") 26 | asset_group_id = bbclib.get_new_id("asset_group_1") 27 | transactions = [None for i in range(client_num)] 28 | cross_ref_list = [] 29 | 30 | msg_processor = [None for i in range(client_num)] 31 | 32 | 33 | class MessageProcessor(bbc_app.Callback): 34 | def __init__(self, index=0): 35 | super(MessageProcessor, self).__init__(self) 36 | self.idx = index 37 | 38 | 39 | class TestBBcPing(object): 40 | 41 | def test_00_setup(self): 42 | print("\n-----", sys._getframe().f_code.co_name, "-----") 43 | print("domain_id =", binascii.b2a_hex(domain_id)) 44 | 45 | global msg_processor 46 | prepare(core_num=core_num, client_num=client_num, loglevel=LOGLEVEL) 47 | for i in range(core_num): 48 | start_core_thread(index=i, core_port_increment=i, p2p_port_increment=i) 49 | time.sleep(1) 50 | for i in range(client_num): 51 | msg_processor[i] = MessageProcessor(index=i) 52 | domain_setup_utility(i, domain_id) # system administrator 53 | make_client(index=i, core_port_increment=i, callback=msg_processor[i]) 54 | time.sleep(1) 55 | 56 | global cores, clients 57 | cores, clients = get_core_client() 58 | 59 | def test_10_register(self): 60 | print("\n-----", sys._getframe().f_code.co_name, "-----") 61 | for cl in clients: 62 | ret = cl['app'].register_to_core() 63 | assert ret 64 | time.sleep(1) 65 | 66 | def test_11_setup_network(self): 67 | print("\n-----", sys._getframe().f_code.co_name, "-----") 68 | ret = clients[0]['app'].get_domain_neighborlist(domain_id=domain_id) 69 | assert ret 70 | dat = msg_processor[0].synchronize() 71 | print("[0] nodeinfo=",dat[0]) 72 | node_id, ipv4, ipv6, port, domain0 = dat[0] 73 | 74 | for i in range(1, client_num): 75 | ret = clients[i]['app'].set_domain_static_node(domain_id, node_id, ipv4, ipv6, port) 76 | assert ret 77 | ret = msg_processor[i].synchronize() 78 | print("[%d] set_domain_static_node result is %s" %(i, ret)) 79 | 80 | def test_12_wait_and_show_result(self): 81 | print("\n-----", sys._getframe().f_code.co_name, "-----") 82 | print("*** wait 5 sec, checking neighbor_list in the core ***") 83 | time.sleep(5) 84 | for i in range(client_num): 85 | clients[i]['app'].get_domain_neighborlist(domain_id=domain_id) 86 | dat = msg_processor[i].synchronize() 87 | assert len(dat) == core_num 88 | print("-------------") 89 | pprint.pprint(dat) 90 | 91 | def test_99_quit(self): 92 | print("\n-----", sys._getframe().f_code.co_name, "-----") 93 | for core in cores: 94 | core.networking.save_all_static_node_list() 95 | ret = core.config.update_config() 96 | assert ret 97 | 98 | 99 | if __name__ == '__main__': 100 | pytest.main() 101 | -------------------------------------------------------------------------------- /tests/test_bbc_stats.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | import pprint 4 | 5 | import sys 6 | sys.path.extend(["../"]) 7 | from bbc1.core import bbc_stats 8 | 9 | bbcstats = bbc_stats.BBcStats() 10 | 11 | 12 | class TestBBcStats(object): 13 | 14 | def test_0_get(self): 15 | print("-----", sys._getframe().f_code.co_name, "-----") 16 | result = bbcstats.get_stats() 17 | pprint.pprint(result) 18 | 19 | def test_1_add_item(self): 20 | print("-----", sys._getframe().f_code.co_name, "-----") 21 | bbcstats.update_stats("cat1", "item1", 10) 22 | bbcstats.update_stats("cat2", "itemA", 20) 23 | bbcstats.update_stats("cat1", "item2", 30) 24 | 25 | def test_2_increment(self): 26 | print("-----", sys._getframe().f_code.co_name, "-----") 27 | bbcstats.update_stats_increment("cat1", "item2", 5) 28 | 29 | def test_3_get(self): 30 | print("-----", sys._getframe().f_code.co_name, "-----") 31 | result = bbcstats.get_stats() 32 | pprint.pprint(result) 33 | 34 | def test_4_remove_item(self): 35 | print("-----", sys._getframe().f_code.co_name, "-----") 36 | bbcstats.remove_stat_item("cat1", "item2") 37 | result = bbcstats.get_stats() 38 | pprint.pprint(result) 39 | 40 | def test_5_remove_category(self): 41 | print("-----", sys._getframe().f_code.co_name, "-----") 42 | bbcstats.remove_stat_category("cat2") 43 | result = bbcstats.get_stats() 44 | pprint.pprint(result) 45 | 46 | def test_6_clear(self): 47 | print("-----", sys._getframe().f_code.co_name, "-----") 48 | bbcstats.clear_stats() 49 | result = bbcstats.get_stats() 50 | pprint.pprint(result) 51 | 52 | 53 | if __name__ == '__main__': 54 | pytest.main() 55 | -------------------------------------------------------------------------------- /tests/test_key_exchange_manager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import time 5 | import queue 6 | 7 | import sys 8 | sys.path.extend(["../"]) 9 | from bbc1.core import query_management, message_key_types 10 | from bbc1.core import key_exchange_manager 11 | from bbc1.core import bbclib 12 | 13 | ticker = query_management.get_ticker() 14 | msg_queue = queue.Queue() 15 | 16 | node_num = 4 17 | domain_id = bbclib.get_new_id("test_domain") 18 | node_ids = [None for i in range(node_num)] 19 | key_managers = [None for i in range(node_num)] 20 | 21 | 22 | class DummyNetwork: 23 | def send_key_exchange_message(self, domain_id, node_id, command, pubkey, nonce, random_val, key_name): 24 | print("send KEY_EXCHANGE message") 25 | msg_queue.put([domain_id, node_id, pubkey, nonce, random_val, key_name]) 26 | return True 27 | 28 | 29 | class TestKeyExchangeManager(object): 30 | 31 | def test_01_setup(self): 32 | print("\n-----", sys._getframe().f_code.co_name, "-----") 33 | key_exchange_manager.KeyExchangeManager.KEY_EXCHANGE_INVOKE_MAX_BACKOFF = 1 34 | key_exchange_manager.KeyExchangeManager.KEY_EXCHANGE_RETRY_INTERVAL = 2 35 | key_exchange_manager.KeyExchangeManager.KEY_REFRESH_INTERVAL = 20 36 | global key_managers, node_ids 37 | for i in range(2): 38 | node_ids[i] = bbclib.get_new_id("node%d"%i) 39 | key_managers[0] = key_exchange_manager.KeyExchangeManager(DummyNetwork(), domain_id, node_ids[1]) 40 | key_managers[1] = key_exchange_manager.KeyExchangeManager(DummyNetwork(), domain_id, node_ids[0]) 41 | 42 | def test_02_invoke_key_exchange(self): 43 | print("\n-----", sys._getframe().f_code.co_name, "-----") 44 | print("# Node0 invokes key exchange") 45 | key_managers[0].set_invoke_timer(1) 46 | 47 | def test_03_receive_request(self): 48 | print("\n-----", sys._getframe().f_code.co_name, "-----") 49 | print("# Node1------") 50 | msg = msg_queue.get() 51 | assert key_managers[0].state == key_exchange_manager.KeyExchangeManager.STATE_REQUESTING 52 | key_managers[1].receive_exchange_request(msg[2], msg[3], msg[4], msg[5]) 53 | assert key_managers[1].state == key_exchange_manager.KeyExchangeManager.STATE_CONFIRMING 54 | print("# Node1 sends response") 55 | 56 | def test_04_receive_response(self): 57 | print("\n-----", sys._getframe().f_code.co_name, "-----") 58 | print("# Node0------") 59 | msg = msg_queue.get() 60 | key_managers[0].receive_exchange_response(msg[2], msg[3], msg[5]) 61 | assert key_managers[0].state == key_exchange_manager.KeyExchangeManager.STATE_ESTABLISHED 62 | print("# Node0 sends confirmation") 63 | 64 | def test_05_confirm(self): 65 | print("\n-----", sys._getframe().f_code.co_name, "-----") 66 | print("# Node1------") 67 | print("# Node1 receives confirmation") 68 | msg = msg_queue.get() 69 | key_managers[1].receive_confirmation() 70 | assert key_managers[1].state == key_exchange_manager.KeyExchangeManager.STATE_ESTABLISHED 71 | 72 | time.sleep(1) 73 | assert key_managers[0].key_name in message_key_types.encryptors 74 | assert key_managers[1].key_name in message_key_types.encryptors 75 | 76 | 77 | if __name__ == '__main__': 78 | pytest.main() 79 | 80 | -------------------------------------------------------------------------------- /tests/test_message_key_types.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.extend(["../"]) 3 | 4 | 5 | #import unittest 6 | import bbc1.core.message_key_types as message_key_types 7 | import bbc1.core.bbc_error as bbc_error 8 | 9 | from bbc1.core.bbclib import MsgType 10 | # dummy start. 11 | #class MsgType: 12 | # MESSAGE = 34 13 | # dummy end. 14 | 15 | 16 | def _bytes_to_str(bytes_str): 17 | """ 18 | """ 19 | return bytes_str.decode('utf-8') 20 | 21 | 22 | def test_to_4byte(): 23 | """ 24 | """ 25 | val = message_key_types.to_4byte(7) 26 | assert (val == b'\x00\x00\x00\x07') 27 | 28 | val = message_key_types.to_4byte(1, 0x20) 29 | assert (val == b'\x00\x00\x00\x21') 30 | 31 | val = message_key_types.to_4byte(8, 0x30) 32 | assert (val == b'\x00\x00\x00\x38') 33 | 34 | val = message_key_types.to_4byte(2, 0x70) 35 | assert (val == b'\x00\x00\x00\x72') 36 | 37 | 38 | def test_make_message(): 39 | """ 40 | """ 41 | data = { } 42 | message = message_key_types.make_message(message_key_types.PayloadType.Type_msgpack, data, 0) 43 | # print(message) 44 | assert (message == b'\x00\x02\x00\x00\x00\x00\x00\x01\x80') 45 | assert (message[:message_key_types.Message.HEADER_LEN] == b'\x00\x02\x00\x00\x00\x00\x00\x01') 46 | 47 | 48 | def test_make_message2(): 49 | """ 50 | """ 51 | data = { 52 | message_key_types.KeyType.command: MsgType.MESSAGE, 53 | message_key_types.KeyType.asset_group_id: "asset_group_id_001", 54 | message_key_types.KeyType.source_user_id: "source_user_id_12345", 55 | message_key_types.KeyType.query_id: "query_id_67890", 56 | message_key_types.KeyType.status: bbc_error.ESUCCESS, 57 | } 58 | message = message_key_types.make_message(message_key_types.PayloadType.Type_msgpack, data, 0) 59 | # print(message) 60 | assert (message[:message_key_types.Message.HEADER_LEN] == b'\x00\x02\x00\x00\x00\x00\x00S') 61 | 62 | msg_obj = message_key_types.Message() 63 | msg_obj.recv(bytes(message)) 64 | parsed_data = msg_obj.parse() 65 | assert (msg_obj.payload_type == message_key_types.PayloadType.Type_msgpack) 66 | assert (msg_obj.format_version == 0) 67 | assert (msg_obj.msg_len == 83) # 'S' == 83 68 | print(parsed_data) 69 | assert (parsed_data[message_key_types.KeyType.command] == MsgType.MESSAGE) 70 | assert (_bytes_to_str(parsed_data[message_key_types.KeyType.asset_group_id]) == "asset_group_id_001") 71 | assert (_bytes_to_str(parsed_data[message_key_types.KeyType.source_user_id]) == "source_user_id_12345") 72 | assert (_bytes_to_str(parsed_data[message_key_types.KeyType.query_id]) == "query_id_67890") 73 | assert (parsed_data[message_key_types.KeyType.status] == bbc_error.ESUCCESS) 74 | 75 | -------------------------------------------------------------------------------- /tests/test_msg_serializer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import sys 5 | sys.path.extend(["../"]) 6 | import pprint 7 | 8 | #import unittest 9 | from bbc1.core import bbclib 10 | from bbc1.core import message_key_types 11 | from bbc1.core.message_key_types import KeyType 12 | 13 | msg_data = None 14 | 15 | 16 | class TestMsgSerializer(object): 17 | 18 | def test_01_serialize(self): 19 | print("\n-----", sys._getframe().f_code.co_name, "-----") 20 | msg = { 21 | KeyType.source_node_id: bbclib.get_new_id("aaa"), 22 | KeyType.destination_node_id: bbclib.get_new_id("bbb"), 23 | KeyType.status: True, 24 | KeyType.random: int(8000).to_bytes(4, "little") 25 | } 26 | pprint.pprint(msg) 27 | global msg_data 28 | msg_data = message_key_types.make_TLV_formatted_message(msg) 29 | 30 | def test_02_deserialize(self): 31 | print("\n-----", sys._getframe().f_code.co_name, "-----") 32 | msg = message_key_types.make_dictionary_from_TLV_format(msg_data) 33 | pprint.pprint(msg) 34 | 35 | 36 | if __name__ == '__main__': 37 | pytest.main() 38 | -------------------------------------------------------------------------------- /tests/test_pending_request.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import time 5 | import queue 6 | 7 | import sys 8 | sys.path.extend(["../"]) 9 | from bbc1.core import query_management 10 | 11 | 12 | ticker = None 13 | result_queue = queue.Queue() 14 | 15 | 16 | def callback_normal(entry): 17 | print("-----", sys._getframe().f_code.co_name, "-----") 18 | print("--> %s" % entry.data) 19 | result_queue.put(1) 20 | 21 | 22 | def callback_error(entry): 23 | print("-----", sys._getframe().f_code.co_name, "-----") 24 | print("==> %s" % entry.data) 25 | result_queue.put(0) 26 | 27 | 28 | def callback_expire(entry): 29 | print("-----", sys._getframe().f_code.co_name, "-----") 30 | print("==> %s" % entry.data) 31 | result_queue.put(-1) 32 | 33 | 34 | def wait_results(count): 35 | total = 0 36 | for i in range(count): 37 | total += result_queue.get() 38 | return total 39 | 40 | 41 | class TestPendingRequest(object): 42 | 43 | def test_01_setup(self): 44 | print("\n-----", sys._getframe().f_code.co_name, "-----") 45 | global ticker 46 | ticker = query_management.get_ticker() 47 | 48 | def test_02_normal_callback(self): 49 | print("\n-----", sys._getframe().f_code.co_name, "-----") 50 | entry = query_management.QueryEntry(expire_after=2, callback_expire=callback_expire, 51 | callback=callback_normal, callback_error=callback_error, 52 | data=[2, 2, 2]) 53 | entry.update(fire_after=1.5) 54 | time.sleep(1) 55 | entry.callback() # entry is deactivated in the callback 56 | total = wait_results(1) 57 | assert total == 1 58 | 59 | def test_02_deactivate(self): 60 | print("\n-----", sys._getframe().f_code.co_name, "-----") 61 | entry = query_management.QueryEntry(expire_after=3, callback_expire=callback_expire, 62 | callback=callback_normal, callback_error=callback_error, 63 | interval=2, 64 | data=[2.5, 2.5, 2.5], 65 | retry_count=1) 66 | print("**sleep 2.5 sec") 67 | time.sleep(2.5) 68 | entry.deactivate() 69 | 70 | def test_03_callback_expire(self): 71 | print("\n-----", sys._getframe().f_code.co_name, "-----") 72 | entry = query_management.QueryEntry(expire_after=5, callback_expire=callback_expire, data=[4, 4, 4]) 73 | total = wait_results(1) 74 | assert total == -1 75 | 76 | def test_04_expire_callback_reschedule(self): 77 | print("\n-----", sys._getframe().f_code.co_name, "-----") 78 | entry = query_management.QueryEntry(expire_after=2, callback_expire=callback_expire, 79 | callback=callback_normal, callback_error=callback_error, 80 | data=[3, 3, 3]) 81 | entry.update(expire_after=1.5) 82 | time.sleep(1.6) 83 | entry.deactivate() 84 | total = wait_results(1) 85 | assert total == -1 86 | 87 | def test_05_multiple_entries_normal(self): 88 | print("\n-----", sys._getframe().f_code.co_name, "-----") 89 | query_entries = [] 90 | for i in range(10): 91 | entry = query_management.QueryEntry(expire_after=4, callback_expire=callback_expire, 92 | callback=callback_normal, callback_error=callback_error, 93 | data=[i, 0, 5]) 94 | entry.update(fire_after=2) 95 | query_entries.append(entry.nonce) 96 | 97 | time.sleep(1) 98 | for i in range(10): 99 | entry = ticker.get_entry(query_entries[i]) 100 | entry.callback() 101 | ticker.del_entry(query_entries[i]) 102 | total = wait_results(10) 103 | assert total == 10 104 | 105 | def test_06_multiple_entries_normal_error_expire(self): 106 | print("\n-----", sys._getframe().f_code.co_name, "-----") 107 | query_entries = [] 108 | for i in range(10): 109 | entry = query_management.QueryEntry(expire_after=5, callback_expire=callback_expire, 110 | callback=callback_normal, callback_error=callback_error, 111 | data=[i, 0, 6]) 112 | entry.update(2) 113 | query_entries.append(entry.nonce) 114 | time.sleep(1) 115 | 116 | # -- normal 117 | for i in range(10): 118 | entry = ticker.get_entry(query_entries[i]) 119 | entry.callback() 120 | total = wait_results(10) 121 | assert total == 10 122 | 123 | # -- error 124 | for i in range(10): 125 | entry = ticker.get_entry(query_entries[i]) 126 | entry.update(1) 127 | total = wait_results(10) 128 | assert total == 0 129 | 130 | # -- finally 131 | time.sleep(5) 132 | total = wait_results(10) 133 | assert total == -10 134 | 135 | def test_99_show_scheduler(self): 136 | print("\n-----", sys._getframe().f_code.co_name, "-----") 137 | time.sleep(2) 138 | print(ticker.schedule) 139 | print(ticker.queries) 140 | 141 | 142 | if __name__ == '__main__': 143 | pytest.main() 144 | 145 | -------------------------------------------------------------------------------- /tests/testutils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import binascii 3 | import os 4 | import shutil 5 | import threading 6 | import time 7 | import copy 8 | 9 | import sys 10 | sys.path.extend(["../"]) 11 | from bbc1.core import bbclib, bbc_app 12 | from bbc1.core.message_key_types import KeyType 13 | from bbc1.core import bbc_core 14 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT, DEFAULT_P2P_PORT 15 | 16 | cores = None 17 | clients = None 18 | stats = None 19 | common_domain_id = None 20 | loglv = 'debug' 21 | config_file = None 22 | 23 | 24 | def prepare(core_num=1, client_num=1, conf_file=None, loglevel='debug'): 25 | global cores, clients, stats, config_file, loglv 26 | cores = [None for i in range(core_num)] 27 | stats = [None for i in range(core_num)] 28 | clients = [dict() for i in range(client_num)] 29 | loglv = loglevel 30 | config_file = conf_file 31 | 32 | 33 | def get_core_client(): 34 | return cores, clients 35 | 36 | 37 | def start_core_thread(index, core_port_increment=0, p2p_port_increment=0, 38 | use_nodekey=True, use_domain0=False, remove_dir=True): 39 | core_port = DEFAULT_CORE_PORT + core_port_increment 40 | p2p_port = DEFAULT_P2P_PORT + p2p_port_increment 41 | th = threading.Thread(target=start_core, args=(index, core_port, p2p_port, use_nodekey, use_domain0, remove_dir,)) 42 | th.setDaemon(True) 43 | th.start() 44 | time.sleep(0.1) 45 | 46 | 47 | def start_core(index, core_port, p2p_port, use_nodekey=True, use_domain0=False, remove_dir=True): 48 | print("** [%d] start: port=%i" % (index, core_port)) 49 | working_dir = ".bbc1-%i/" % core_port 50 | if remove_dir and os.path.exists(working_dir): 51 | shutil.rmtree(working_dir) 52 | os.makedirs(working_dir) 53 | if config_file is not None: 54 | shutil.copyfile(config_file, os.path.join(working_dir, "config.json")) 55 | cores[index] = bbc_core.BBcCoreService(p2p_port=p2p_port, core_port=core_port, 56 | workingdir=working_dir, 57 | use_nodekey=use_nodekey, 58 | use_domain0=use_domain0, 59 | server_start=False, 60 | loglevel=loglv) 61 | cores[index]._start_server(port=core_port) 62 | 63 | 64 | def domain_setup_utility(core_port_increment, dom_id): 65 | cl = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT + core_port_increment, multiq=False) 66 | working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment) 67 | if os.path.exists(os.path.join(working_dir, "node_key.pem")): 68 | cl.set_node_key(os.path.join(working_dir, "node_key.pem")) 69 | cl.domain_setup(dom_id) 70 | global common_domain_id 71 | common_domain_id = dom_id 72 | wait_check_result_msg_type(cl.callback, bbclib.MsgType.RESPONSE_SETUP_DOMAIN) 73 | cl.unregister_from_core() 74 | 75 | 76 | def make_client(index, core_port_increment, callback=None, connect_to_core=True, domain_id=None): 77 | keypair = bbclib.KeyPair() 78 | keypair.generate() 79 | clients[index]['user_id'] = bbclib.get_new_id("user_%i" % index) 80 | clients[index]['keypair'] = keypair 81 | clients[index]['app'] = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT + core_port_increment, 82 | multiq=False, loglevel=loglv) 83 | if connect_to_core: 84 | if domain_id is None: 85 | global common_domain_id 86 | domain_id = common_domain_id 87 | clients[index]['app'].set_user_id(clients[index]['user_id']) 88 | clients[index]['app'].set_domain_id(domain_id) 89 | if callback is not None: 90 | clients[index]['app'].set_callback(callback) 91 | working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment) 92 | if os.path.exists(os.path.join(working_dir, "node_key.pem")): 93 | clients[index]['app'].set_node_key(os.path.join(working_dir, "node_key.pem")) 94 | time.sleep(1) 95 | print("[%i] user_id = %s" % (index, binascii.b2a_hex(clients[index]['user_id']))) 96 | 97 | 98 | def get_random_data(length=16): 99 | import random 100 | source_str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 101 | return "".join([random.choice(source_str) for x in range(length)]) 102 | 103 | 104 | def wait_check_result_msg_type(callback, msg_type): 105 | dat = callback.synchronize() 106 | if dat[KeyType.command] != msg_type: 107 | print("XXXXXX not expected result: %d <=> %d(received)" % (msg_type, dat[KeyType.command])) 108 | return dat 109 | 110 | 111 | def get_stats(i): 112 | global stats 113 | stats[i] = copy.deepcopy(cores[i].stats.get_stats()) 114 | 115 | 116 | def get_stat_diffs(i): 117 | stats_diff = copy.deepcopy(cores[i].stats.get_stats()) 118 | for key in stats_diff.keys(): 119 | for key2 in stats_diff[key].keys(): 120 | if key in stats[i]: 121 | stats_diff[key][key2] -= stats[i][key].get(key2, 0) 122 | get_stats(i) 123 | return stats_diff 124 | -------------------------------------------------------------------------------- /utils/bbc_domain_update.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2017 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | import os 24 | import sys 25 | sys.path.append("../") 26 | 27 | from bbc1.core import bbc_app 28 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT 29 | from bbc1.core import bbclib 30 | from bbc1.core.message_key_types import KeyType 31 | 32 | 33 | def wait_check_result_msg_type(callback, msg_type): 34 | dat = callback.synchronize() 35 | if dat[KeyType.command] != msg_type: 36 | sys.stderr.write("XXXXXX not expected result: %d <=> %d(received)\n" % (msg_type, dat[KeyType.command])) 37 | return dat 38 | 39 | 40 | def argument_parser(): 41 | argparser = argparse.ArgumentParser(description='Online domain setting update tool') 42 | argparser.add_argument('-4', '--ip4address', action='store', default="127.0.0.1", help='bbc_core address (IPv4)') 43 | argparser.add_argument('-6', '--ip6address', action='store', help='bbc_core address (IPv6)') 44 | argparser.add_argument('-p', '--port', action='store', default=DEFAULT_CORE_PORT, help='port number of bbc_core') 45 | argparser.add_argument('-d', '--domain_id', action='store', default=None, help='domain_id to setup') 46 | argparser.add_argument('-a', '--add_domain', action='store_true', help='add a new domain') 47 | argparser.add_argument('-r', '--remove_domain', action='store_true', help='remove a domain') 48 | argparser.add_argument('-k', '--node_key', action='store', default=None, help='path to node key pem file') 49 | return argparser.parse_args() 50 | 51 | 52 | if __name__ == '__main__': 53 | port = None 54 | parsed_args = argument_parser() 55 | if parsed_args.domain_id is None: 56 | print("### -d option is mandatory!") 57 | sys.exit(1) 58 | 59 | if parsed_args.ip4address: 60 | addr = parsed_args.ip4address 61 | if parsed_args.ip6address: 62 | addr = parsed_args.ip6address 63 | port = parsed_args.port 64 | bbcclient = bbc_app.BBcAppClient(host=addr, port=port, multiq=False, loglevel="all") 65 | 66 | if parsed_args.node_key and os.path.exists(parsed_args.node_key): 67 | bbcclient.set_node_key(parsed_args.node_key) 68 | 69 | domain_id = bbclib.convert_idstring_to_bytes(parsed_args.domain_id) 70 | 71 | if parsed_args.add_domain: 72 | bbcclient.domain_setup(domain_id) 73 | dat = wait_check_result_msg_type(bbcclient.callback, bbclib.MsgType.RESPONSE_SETUP_DOMAIN) 74 | if KeyType.reason in dat: 75 | print("Result:", dat[KeyType.reason]) 76 | else: 77 | print("Result: success") 78 | elif parsed_args.remove_domain: 79 | bbcclient.domain_close(domain_id) 80 | dat = wait_check_result_msg_type(bbcclient.callback, bbclib.MsgType.RESPONSE_CLOSE_DOMAIN) 81 | if KeyType.reason in dat: 82 | print("Result:", dat[KeyType.reason]) 83 | else: 84 | print("Result: success") 85 | sys.exit(0) 86 | -------------------------------------------------------------------------------- /utils/bbc_info.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2017 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | 23 | import argparse 24 | import binascii 25 | import json 26 | import pprint 27 | 28 | import os 29 | import sys 30 | sys.path.append("../") 31 | 32 | from bbc1.core import bbc_app 33 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT 34 | from bbc1.core import bbclib 35 | from bbc1.core.message_key_types import KeyType 36 | 37 | 38 | def wait_check_result_msg_type(callback, msg_type): 39 | dat = callback.synchronize() 40 | if dat[KeyType.command] != msg_type: 41 | sys.stderr.write("XXXXXX not expected result: %d <=> %d(received)\n" % (msg_type, dat[KeyType.command])) 42 | return dat 43 | 44 | 45 | def get_neighborlist(client): 46 | client.get_domain_list() 47 | domainlist = client.callback.synchronize() 48 | for domain_id in domainlist: 49 | client.get_domain_neighborlist(domain_id=domain_id) 50 | dat = bbcclient.callback.synchronize() 51 | print("====== neighbor list of domain:%s =====" % binascii.b2a_hex(domain_id).decode()) 52 | print(" node_id(4byte), ipv4, ipv6, port, is_domain0") 53 | for k in range(len(dat)): 54 | node_id, ipv4, ipv6, port, domain0 = dat[k] 55 | if k == 0: 56 | print("*myself* %s, %s, %s, %d, %s" % (binascii.b2a_hex(node_id[:4]), ipv4, ipv6, port, domain0)) 57 | else: 58 | print(" %s, %s, %s, %d, %s" % (binascii.b2a_hex(node_id[:4]), ipv4, ipv6, port, domain0)) 59 | 60 | 61 | def argument_parser(): 62 | argparser = argparse.ArgumentParser(description='Configure bbc_core using json conf file.') 63 | argparser.add_argument('-4', '--ip4address', action='store', default="127.0.0.1", help='bbc_core address (IPv4)') 64 | argparser.add_argument('-6', '--ip6address', action='store', help='bbc_core address (IPv6)') 65 | argparser.add_argument('-p', '--port', action='store', default=DEFAULT_CORE_PORT, help='port number of bbc_core') 66 | argparser.add_argument('-d', '--domain_id', action='store', default=None, help='domain_id HEX string') 67 | argparser.add_argument('-l', '--neighborlist', action='store_true', default=False, 68 | help='Get neighbor_list in bbc_core') 69 | argparser.add_argument('-u', '--userlist', action='store_true', default=False, help='Get user_ist in bbc_core') 70 | argparser.add_argument('-n', '--my_node_id', action='store_true', default=False, help='Get my node_id') 71 | argparser.add_argument('--stat', action='store_true', default=False, help='Get statistics of the bbc_core') 72 | argparser.add_argument('--getconfig', action='store_true', default=False, help='Get config from bbc_core') 73 | argparser.add_argument('-k', '--node_key', action='store', default=".bbc1/node_key.pem", 74 | help="path to node key pem file") 75 | return argparser.parse_args() 76 | 77 | 78 | if __name__ == '__main__': 79 | parsed_args = argument_parser() 80 | addr = None 81 | port = None 82 | 83 | if parsed_args.ip4address: 84 | addr = parsed_args.ip4address 85 | if parsed_args.ip6address: 86 | addr = parsed_args.ip6address 87 | port = parsed_args.port 88 | 89 | bbcclient = bbc_app.BBcAppClient(host=addr, port=port, multiq=False, loglevel="all") 90 | if os.path.exists(parsed_args.node_key): 91 | bbcclient.set_node_key(parsed_args.node_key) 92 | 93 | if parsed_args.getconfig: 94 | bbcclient.get_bbc_config() 95 | dat = wait_check_result_msg_type(bbcclient.callback, bbclib.MsgType.RESPONSE_GET_CONFIG) 96 | print("------ config.json ------") 97 | conf = json.loads(dat[KeyType.bbc_configuration].decode()) 98 | pprint.pprint(conf, width=80) 99 | sys.exit(0) 100 | 101 | if parsed_args.stat or (not parsed_args.my_node_id and not parsed_args.userlist and not parsed_args.neighborlist): 102 | bbcclient.get_stats() 103 | dat = wait_check_result_msg_type(bbcclient.callback, bbclib.MsgType.RESPONSE_GET_STATS) 104 | print("------ statistics ------") 105 | pprint.pprint(dat[KeyType.stats], width=80) 106 | sys.exit(0) 107 | 108 | if parsed_args.domain_id is None: 109 | sys.stderr.write("-d option (domain_id) is mandatory\n") 110 | sys.exit(1) 111 | domain_id = bbclib.convert_idstring_to_bytes(parsed_args.domain_id) 112 | bbcclient.set_domain_id(domain_id) 113 | 114 | if parsed_args.my_node_id: 115 | bbcclient.get_node_id() 116 | node_id = bbcclient.callback.synchronize() 117 | print("Node_id is %s" % node_id.hex()) 118 | elif parsed_args.userlist: 119 | bbcclient.get_user_list() 120 | user_list = bbcclient.callback.synchronize() 121 | print("------- user_list -------") 122 | for uid in user_list: 123 | print("User_id: ", uid.hex()) 124 | elif parsed_args.neighborlist: 125 | get_neighborlist(bbcclient) 126 | 127 | sys.exit(0) 128 | -------------------------------------------------------------------------------- /utils/bbc_ping.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2017 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | import time 24 | import binascii 25 | import sys 26 | import os 27 | import ipaddress 28 | sys.path.append("../") 29 | 30 | from bbc1.core import bbc_app 31 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT, DEFAULT_P2P_PORT 32 | from bbc1.core import bbclib 33 | from bbc1.core.message_key_types import KeyType 34 | from bbc1.core.bbc_error import * 35 | 36 | 37 | def argument_parser(): 38 | argparser = argparse.ArgumentParser(description='Send domain ping to crate domain and configure static ' 39 | 'neighbor nodes.') 40 | argparser.add_argument('-4', '--ip4address', action='store', help='bbc_core address (IPv4) to connect') 41 | argparser.add_argument('-6', '--ip6address', action='store', help='bbc_core address (IPv6) to connect') 42 | argparser.add_argument('-p', '--port', action='store', default=DEFAULT_CORE_PORT, help='port number of bbc_core') 43 | argparser.add_argument('-k', '--node_key', action='store', default=".bbc1/node_key.pem", 44 | help="path to node key pem file") 45 | argparser.add_argument('domain_id', action='store', nargs='?', default=None, help='Hex string of the domain_id') 46 | argparser.add_argument('dst_address', action='store', nargs='?', 47 | help='destination IPv4/v6 address of the neighbor node') 48 | argparser.add_argument('dst_port', action='store', nargs='?', default=DEFAULT_P2P_PORT+1, 49 | help='destination port number of the neighbor node') 50 | return argparser.parse_args() 51 | 52 | 53 | def send_domain_ping(client, dom_id, adr, pt): 54 | dst_ip, dst_port = ipaddress.ip_address(adr), int(pt) 55 | ip4 = None 56 | ip6 = None 57 | if isinstance(dst_ip, ipaddress.IPv4Address): 58 | ip4 = str(dst_ip) 59 | else: 60 | ip6 = str(dst_ip) 61 | print("Request domain_ping to %s, %s, %d" % (ip4, ip6, dst_port)) 62 | client.send_domain_ping(dom_id, ip4, ip6, dst_port) 63 | 64 | 65 | if __name__ == '__main__': 66 | parsed_args = argument_parser() 67 | addr = "127.0.0.1" 68 | if parsed_args.ip4address: 69 | addr = parsed_args.ip4address 70 | if parsed_args.ip6address: 71 | addr = parsed_args.ip6address 72 | port = parsed_args.port 73 | 74 | bbcclient = bbc_app.BBcAppClient(host=addr, port=port, multiq=False, loglevel="all") 75 | if os.path.exists(parsed_args.node_key): 76 | bbcclient.set_node_key(parsed_args.node_key) 77 | 78 | domain_id = bbclib.convert_idstring_to_bytes(parsed_args.domain_id) 79 | query_id = bbcclient.domain_setup(domain_id) 80 | dat = bbcclient.callback.synchronize() 81 | assert dat[KeyType.status] == ESUCCESS 82 | 83 | send_domain_ping(bbcclient, domain_id, parsed_args.dst_address, parsed_args.dst_port) 84 | 85 | print("*** wait 5 sec, checking neighbor list in the core ***") 86 | time.sleep(5) 87 | query_id = bbcclient.get_domain_neighborlist(domain_id=domain_id) 88 | dat = bbcclient.callback.synchronize() 89 | print("====== neighbor list =====") 90 | for k in range(len(dat)): 91 | node_id, ipv4, ipv6, port, domain0 = dat[k] 92 | if k == 0: 93 | print("*my_self* %s, %s, %s, %d, domain0:%s" % (binascii.b2a_hex(node_id[:4]), ipv4, ipv6, port, domain0)) 94 | else: 95 | print(" %s, %s, %s, %d, domain0:%s" % (binascii.b2a_hex(node_id[:4]), ipv4, ipv6, port, domain0)) 96 | sys.exit(0) 97 | -------------------------------------------------------------------------------- /utils/db_migration_tool.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2018 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | from gevent import monkey 24 | monkey.patch_all() 25 | import os 26 | 27 | import sys 28 | sys.path.extend(["../../bbc1"]) 29 | from bbc1.core import bbc_config, data_handler, bbc_stats, logger 30 | 31 | 32 | def parser(): 33 | argparser = argparse.ArgumentParser(description='Database migration tool') 34 | argparser.add_argument('-c', '--config', type=str, default=None, help='config file name') 35 | argparser.add_argument('-w', '--workingdir', type=str, default=bbc_config.DEFAULT_WORKING_DIR, help='working directory', required=False) 36 | args = argparser.parse_args() 37 | return args 38 | 39 | 40 | class NewDataHandler(data_handler.DataHandler): 41 | def __init__(self, domain_id_str=None, config=None, workingdir=None): 42 | self.logger = logger.get_logger("dummy") 43 | self.config = config 44 | self.working_dir = workingdir 45 | self.storage_root = os.path.join(self.working_dir, domain_id_str) 46 | if not os.path.exists(self.storage_root): 47 | os.makedirs(self.storage_root, exist_ok=True) 48 | self.stats = bbc_stats.BBcStats() # dummy 49 | self.upgraded_from = data_handler.DB_VERSION 50 | self.db_adaptors = list() 51 | self.dbs = list() 52 | self._db_setup() 53 | 54 | 55 | class MigrationTool: 56 | """Migration tool for """ 57 | def __init__(self, workingdir=".bbc1", configfile=None): 58 | self.config = bbc_config.BBcConfig(workingdir, configfile, None).get_config() 59 | self.handlers = dict() 60 | for domain_id_str, conf in self.config['domains'].items(): 61 | if 'db' not in conf: 62 | continue 63 | dh = NewDataHandler(domain_id_str=domain_id_str, config=conf, workingdir=workingdir) 64 | self.handlers[domain_id_str] = dh 65 | 66 | def upgrade(self): 67 | for domain_id_str, dh in self.handlers.items(): 68 | print("*** Try to upgrade DB of domain_id = %s" % domain_id_str) 69 | for count in range(len(dh.db_adaptors)): 70 | print(" -- Upgrade from %s to %s" % (dh.upgraded_from, data_handler.DB_VERSION)) 71 | print(" -- DB num:", count) 72 | ret = dh.exec_sql(db_num=count, sql="SELECT COUNT(*) FROM asset_info_table WHERE timestamp is NULL;") 73 | print(" Total target records:", ret[0][0]) 74 | rows = dh.exec_sql(db_num=count, sql="SELECT * FROM asset_info_table WHERE timestamp is NULL;") 75 | total = 0 76 | for row in rows: 77 | if row[5] is not None: # skip if timestamp has been already set 78 | continue 79 | txid = row[1] 80 | txrow = dh.search_transaction(transaction_id=txid, db_num=count) 81 | if txrow[0] is None: 82 | continue 83 | txobj = txrow[0][txid] 84 | dh.exec_sql(db_num=count, 85 | sql="UPDATE asset_info_table SET timestamp = %s WHERE transaction_id = %s" % 86 | (dh.db_adaptors[count].placeholder, dh.db_adaptors[count].placeholder), 87 | args=[txobj.timestamp, txid], commit=True) 88 | total += 1 89 | if total % 100 == 0: 90 | print(" updated: %d records" % total) 91 | print(" [complete] updated: %d records" % total) 92 | 93 | 94 | if __name__ == '__main__': 95 | argresult = parser() 96 | mt = MigrationTool( 97 | workingdir=argresult.workingdir, 98 | configfile=argresult.config, 99 | ) 100 | mt.upgrade() 101 | -------------------------------------------------------------------------------- /utils/domain_key_setup.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2017 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | 24 | import os 25 | import sys 26 | sys.path.append("../") 27 | 28 | from bbc1.core import bbc_app 29 | from bbc1.core.bbc_config import DEFAULT_CORE_PORT 30 | from bbc1.core import bbclib 31 | from bbc1.core.message_key_types import KeyType 32 | 33 | 34 | def wait_check_result_msg_type(callback, msg_type): 35 | dat = callback.synchronize() 36 | if dat[KeyType.command] != msg_type: 37 | sys.stderr.write("XXXXXX not expected result: %d <=> %d(received)\n" % (msg_type, dat[KeyType.command])) 38 | return dat 39 | 40 | 41 | def argument_parser(): 42 | argparser = argparse.ArgumentParser(description='Domain_key manager') 43 | argparser.add_argument('-4', '--ip4address', action='store', default="127.0.0.1", help='bbc_core address (IPv4)') 44 | argparser.add_argument('-6', '--ip6address', action='store', help='bbc_core address (IPv6)') 45 | argparser.add_argument('-p', '--port', action='store', default=DEFAULT_CORE_PORT, help='port number of bbc_core') 46 | argparser.add_argument('-k', '--node_key', action='store', default=".bbc1/node_key.pem", 47 | help="path to node key pem file") 48 | argparser.add_argument('-dir', '--directory', action='store', default=".bbc-domainkeys", 49 | help='Directory for domain_keys') 50 | argparser.add_argument('-d', '--domain_id', action='store', default=None, help='Domain_id', required=True) 51 | argparser.add_argument('-g', '--generate', action='store_true', default=False, help='Generate a domain_key') 52 | argparser.add_argument('-n', '--notify', action='store_true', default=False, help='Notify update of domain_key') 53 | return argparser.parse_args() 54 | 55 | 56 | if __name__ == '__main__': 57 | parsed_args = argument_parser() 58 | addr = None 59 | port = None 60 | 61 | if parsed_args.domain_id is None: 62 | sys.stderr.write("# -d option (domain_id) is mandatory\n") 63 | sys.exit(1) 64 | 65 | if parsed_args.generate: 66 | try: 67 | os.makedirs(parsed_args.directory, exist_ok=True) 68 | except: 69 | sys.stderr.write("# Fail to mkdir for domain_keys") 70 | sys.exit(1) 71 | keyname = os.path.join(parsed_args.directory, parsed_args.domain_id + ".pem") 72 | keypair = bbclib.KeyPair() 73 | keypair.generate() 74 | with open(keyname, "wb") as fout: 75 | fout.write(keypair.get_private_key_in_pem()) 76 | sys.exit(0) 77 | 78 | if not parsed_args.notify: 79 | sys.stderr.write("# Either -g or -n is required\n") 80 | sys.exit(1) 81 | 82 | if parsed_args.ip4address: 83 | addr = parsed_args.ip4address 84 | if parsed_args.ip6address: 85 | addr = parsed_args.ip6address 86 | port = parsed_args.port 87 | 88 | bbcclient = bbc_app.BBcAppClient(host=addr, port=port, multiq=False, loglevel="all") 89 | if os.path.exists(parsed_args.node_key): 90 | bbcclient.set_node_key(parsed_args.node_key) 91 | bbcclient.notify_domain_key_update() 92 | sys.exit(0) 93 | -------------------------------------------------------------------------------- /utils/id_create.py: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | """:" . 3 | 4 | exec python "$0" "$@" 5 | """ 6 | # -*- coding: utf-8 -*- 7 | """ 8 | Copyright (c) 2017 beyond-blockchain.org. 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | import argparse 23 | import sys 24 | sys.path.append("../") 25 | 26 | from bbc1.core import bbclib 27 | 28 | 29 | def argument_parser(): 30 | argparser = argparse.ArgumentParser(description='Calculate ID HEX string from name') 31 | argparser.add_argument('-s', '--string', action='store', help='Seed strings for calculating SHA256') 32 | argparser.add_argument('-t', '--timebaseid', action='store_true', default=False, help='Concatenate timestamp with seed strings') 33 | argparser.add_argument('-r', '--random', action='store_true', help='Seed strings for calculating SHA256') 34 | return argparser.parse_args() 35 | 36 | 37 | if __name__ == '__main__': 38 | parsed_args = argument_parser() 39 | 40 | if parsed_args.string: 41 | value = bbclib.get_new_id(parsed_args.string, include_timestamp=parsed_args.timebaseid) 42 | print(bbclib.convert_id_to_string(value)) 43 | sys.exit(0) 44 | 45 | if parsed_args.random: 46 | value = bbclib.get_random_id() 47 | print(bbclib.convert_id_to_string(value)) 48 | sys.exit(0) 49 | 50 | sys.stderr.write("# Either -s or -r is required\n") 51 | sys.exit(1) 52 | --------------------------------------------------------------------------------