├── .bazelignore ├── .bazelrc ├── .clang-format ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── BUILD ├── CMakeLists.txt ├── CODEOWNERS ├── CONTRIBUTING.md ├── Dockerfile ├── Doxyfile ├── LICENSE ├── README.md ├── SECURITY.md ├── WORKSPACE ├── cclient ├── BUILD ├── CMakeLists.txt ├── README.md ├── api │ ├── BUILD │ ├── core │ │ ├── add_neighbors.c │ │ ├── add_neighbors.h │ │ ├── attach_to_tangle.c │ │ ├── attach_to_tangle.h │ │ ├── broadcast_transactions.c │ │ ├── broadcast_transactions.h │ │ ├── check_consistency.c │ │ ├── check_consistency.h │ │ ├── core_api.h │ │ ├── core_init.c │ │ ├── core_init.h │ │ ├── doxy.txt │ │ ├── find_transactions.c │ │ ├── find_transactions.h │ │ ├── get_balances.c │ │ ├── get_balances.h │ │ ├── get_inclusion_states.c │ │ ├── get_inclusion_states.h │ │ ├── get_neighbors.c │ │ ├── get_neighbors.h │ │ ├── get_node_api_conf.c │ │ ├── get_node_api_conf.h │ │ ├── get_node_info.c │ │ ├── get_node_info.h │ │ ├── get_tips.c │ │ ├── get_tips.h │ │ ├── get_transactions_to_approve.c │ │ ├── get_transactions_to_approve.h │ │ ├── get_trytes.c │ │ ├── get_trytes.h │ │ ├── logger.c │ │ ├── logger.h │ │ ├── remove_neighbors.c │ │ ├── remove_neighbors.h │ │ ├── store_transactions.c │ │ ├── store_transactions.h │ │ ├── were_addresses_spent_from.c │ │ └── were_addresses_spent_from.h │ ├── examples │ │ ├── BUILD │ │ ├── cclient_examples.c │ │ ├── cclient_examples.h │ │ ├── example_attach_to_tangle.c │ │ ├── example_broadcast_bundle.c │ │ ├── example_broadcast_transactions.c │ │ ├── example_check_consistency.c │ │ ├── example_find_transaction_objects.c │ │ ├── example_find_transactions.c │ │ ├── example_get_account_data.c │ │ ├── example_get_balance.c │ │ ├── example_get_bundle.c │ │ ├── example_get_inclusion_states.c │ │ ├── example_get_inputs.c │ │ ├── example_get_latest_inclusion.c │ │ ├── example_get_new_address.c │ │ ├── example_get_tips.c │ │ ├── example_get_transactions_to_approve.c │ │ ├── example_get_trytes.c │ │ ├── example_get_unspent_address.c │ │ ├── example_is_promotable.c │ │ ├── example_node_api_conf.c │ │ ├── example_node_info.c │ │ ├── example_prepare_transfer.c │ │ ├── example_promote_transacion.c │ │ ├── example_replay_bundle.c │ │ ├── example_send_balance.c │ │ ├── example_send_data.c │ │ ├── example_send_trytes.c │ │ ├── example_store_transactions.c │ │ ├── example_traverse_bundle.c │ │ └── example_were_addresses_spent_from.c │ ├── extended │ │ ├── broadcast_bundle.c │ │ ├── broadcast_bundle.h │ │ ├── doxy.txt │ │ ├── extended_api.h │ │ ├── extended_init.c │ │ ├── extended_init.h │ │ ├── find_transaction_objects.c │ │ ├── find_transaction_objects.h │ │ ├── get_account_data.c │ │ ├── get_account_data.h │ │ ├── get_bundle.c │ │ ├── get_bundle.h │ │ ├── get_inputs.c │ │ ├── get_inputs.h │ │ ├── get_latest_inclusion.c │ │ ├── get_latest_inclusion.h │ │ ├── get_new_address.c │ │ ├── get_new_address.h │ │ ├── get_transaction_objects.c │ │ ├── get_transaction_objects.h │ │ ├── is_promotable.c │ │ ├── is_promotable.h │ │ ├── logger.c │ │ ├── logger.h │ │ ├── prepare_transfers.c │ │ ├── prepare_transfers.h │ │ ├── promote_transaction.c │ │ ├── promote_transaction.h │ │ ├── replay_bundle.c │ │ ├── replay_bundle.h │ │ ├── send_transfer.c │ │ ├── send_transfer.h │ │ ├── send_trytes.c │ │ ├── send_trytes.h │ │ ├── store_and_broadcast.c │ │ ├── store_and_broadcast.h │ │ ├── traverse_bundle.c │ │ └── traverse_bundle.h │ └── tests │ │ ├── BUILD │ │ ├── cclient_service_init.c │ │ ├── cclient_test_defs.h │ │ ├── test_add_neighbors.c │ │ ├── test_attach_to_tangle.c │ │ ├── test_broadcast_transactions.c │ │ ├── test_check_consistency.c │ │ ├── test_find_transactions.c │ │ ├── test_get_balances.c │ │ ├── test_get_inclusion_states.c │ │ ├── test_get_neighbors.c │ │ ├── test_get_node_api_conf.c │ │ ├── test_get_node_info.c │ │ ├── test_get_tips.c │ │ ├── test_get_transactions_to_approve.c │ │ ├── test_get_trytes.c │ │ ├── test_remove_neighbors.c │ │ ├── test_store_transactions.c │ │ └── test_were_addresses_spent_from.c ├── doxy.txt ├── http │ ├── BUILD │ ├── doxy.txt │ ├── http.c │ ├── http.h │ ├── socket.c │ ├── socket.h │ └── tests │ │ ├── BUILD │ │ └── test_http.c ├── request │ ├── BUILD │ ├── add_neighbors.c │ ├── add_neighbors.h │ ├── attach_to_tangle.c │ ├── attach_to_tangle.h │ ├── broadcast_transactions.c │ ├── broadcast_transactions.h │ ├── check_consistency.c │ ├── check_consistency.h │ ├── doxy.txt │ ├── find_transactions.c │ ├── find_transactions.h │ ├── get_balances.c │ ├── get_balances.h │ ├── get_inclusion_states.c │ ├── get_inclusion_states.h │ ├── get_transactions_to_approve.c │ ├── get_transactions_to_approve.h │ ├── get_trytes.c │ ├── get_trytes.h │ ├── remove_neighbors.c │ ├── remove_neighbors.h │ ├── requests.h │ ├── store_transactions.c │ ├── store_transactions.h │ ├── were_addresses_spent_from.c │ └── were_addresses_spent_from.h ├── response │ ├── BUILD │ ├── add_neighbors.c │ ├── add_neighbors.h │ ├── attach_to_tangle.c │ ├── attach_to_tangle.h │ ├── check_consistency.c │ ├── check_consistency.h │ ├── doxy.txt │ ├── error.c │ ├── error.h │ ├── find_transactions.c │ ├── find_transactions.h │ ├── get_balances.c │ ├── get_balances.h │ ├── get_inclusion_states.c │ ├── get_inclusion_states.h │ ├── get_missing_transactions.c │ ├── get_missing_transactions.h │ ├── get_neighbors.c │ ├── get_neighbors.h │ ├── get_node_api_conf.h │ ├── get_node_info.c │ ├── get_node_info.h │ ├── get_tips.c │ ├── get_tips.h │ ├── get_transactions_to_approve.c │ ├── get_transactions_to_approve.h │ ├── get_trytes.c │ ├── get_trytes.h │ ├── remove_neighbors.c │ ├── remove_neighbors.h │ ├── responses.h │ ├── were_addresses_spent_from.c │ └── were_addresses_spent_from.h ├── serialization │ ├── BUILD │ ├── doxy.txt │ ├── json │ │ ├── add_neighbors.c │ │ ├── add_neighbors.h │ │ ├── attach_to_tangle.c │ │ ├── attach_to_tangle.h │ │ ├── broadcast_transactions.c │ │ ├── broadcast_transactions.h │ │ ├── check_consistency.c │ │ ├── check_consistency.h │ │ ├── doxy.txt │ │ ├── error.c │ │ ├── error.h │ │ ├── find_transactions.c │ │ ├── find_transactions.h │ │ ├── get_balances.c │ │ ├── get_balances.h │ │ ├── get_inclusion_states.c │ │ ├── get_inclusion_states.h │ │ ├── get_missing_transactions.c │ │ ├── get_missing_transactions.h │ │ ├── get_neighbors.c │ │ ├── get_neighbors.h │ │ ├── get_node_api_conf.c │ │ ├── get_node_api_conf.h │ │ ├── get_node_info.c │ │ ├── get_node_info.h │ │ ├── get_tips.c │ │ ├── get_tips.h │ │ ├── get_transactions_to_approve.c │ │ ├── get_transactions_to_approve.h │ │ ├── get_trytes.c │ │ ├── get_trytes.h │ │ ├── helpers.c │ │ ├── helpers.h │ │ ├── json_serializer.c │ │ ├── json_serializer.h │ │ ├── logger.c │ │ ├── logger.h │ │ ├── remove_neighbors.c │ │ ├── remove_neighbors.h │ │ ├── store_transactions.c │ │ ├── store_transactions.h │ │ ├── tests │ │ │ ├── BUILD │ │ │ ├── add_neighbors.c │ │ │ ├── attach_to_tangle.c │ │ │ ├── broadcast_transactions.c │ │ │ ├── check_consistency.c │ │ │ ├── error.c │ │ │ ├── find_transactions.c │ │ │ ├── get_balances.c │ │ │ ├── get_inclusion_states.c │ │ │ ├── get_missing_transactions.c │ │ │ ├── get_neighbors.c │ │ │ ├── get_node_api_conf.c │ │ │ ├── get_node_info.c │ │ │ ├── get_tips.c │ │ │ ├── get_transactions_to_approve.c │ │ │ ├── get_trytes.c │ │ │ ├── remove_neighbors.c │ │ │ ├── shared.h │ │ │ ├── store_transactions.c │ │ │ └── were_addresses_spent_from.c │ │ ├── were_addresses_spent_from.c │ │ └── were_addresses_spent_from.h │ └── serializer.h ├── service.c └── service.h ├── ciri ├── BUILD ├── README.md ├── api │ ├── BUILD │ ├── api.c │ ├── api.h │ ├── conf.c │ ├── conf.h │ ├── doxy.txt │ ├── feature.c │ ├── feature.h │ ├── http │ │ ├── BUILD │ │ ├── http.c │ │ └── http.h │ └── tests │ │ ├── BUILD │ │ ├── defs.h │ │ ├── test_add_neighbors.c │ │ ├── test_attach_to_tangle.c │ │ ├── test_broadcast_transactions.c │ │ ├── test_check_consistency.c │ │ ├── test_find_transactions.c │ │ ├── test_get_missing_transactions.c │ │ ├── test_get_neighbors.c │ │ ├── test_get_node_info.c │ │ ├── test_get_tips.c │ │ ├── test_get_transactions_to_approve.c │ │ ├── test_get_trytes.c │ │ ├── test_remove_neighbors.c │ │ ├── test_store_transactions.c │ │ └── test_were_addresses_spent_from.c ├── conf.bzl ├── conf.c ├── conf.example.yml ├── conf.h ├── consensus │ ├── BUILD │ ├── bundle_validator │ │ ├── BUILD │ │ ├── bundle_validator.c │ │ ├── bundle_validator.h │ │ └── tests │ │ │ ├── BUILD │ │ │ └── bundle_validator.c │ ├── conf.bzl │ ├── conf.c │ ├── conf.h │ ├── consensus.c │ ├── consensus.h │ ├── doxy.txt │ ├── ledger_validator │ │ ├── BUILD │ │ ├── ledger_validator.c │ │ ├── ledger_validator.h │ │ └── tests │ │ │ ├── BUILD │ │ │ ├── snapshot.txt │ │ │ └── test_ledger_validator.c │ ├── milestone │ │ ├── BUILD │ │ ├── milestone_service.c │ │ ├── milestone_service.h │ │ ├── milestone_tracker.c │ │ ├── milestone_tracker.h │ │ └── tests │ │ │ ├── BUILD │ │ │ └── test_milestone_tracker.c │ ├── model.h │ ├── snapshot │ │ ├── BUILD │ │ ├── local_snapshots │ │ │ ├── BUILD │ │ │ ├── conf.c │ │ │ ├── conf.h │ │ │ ├── local_snapshots_manager.c │ │ │ ├── local_snapshots_manager.h │ │ │ ├── pruning_service.c │ │ │ └── pruning_service.h │ │ ├── snapshot.c │ │ ├── snapshot.h │ │ ├── snapshot_metadata.c │ │ ├── snapshot_metadata.h │ │ ├── snapshots_provider.c │ │ ├── snapshots_provider.h │ │ ├── snapshots_service.c │ │ ├── snapshots_service.h │ │ ├── state_delta.c │ │ ├── state_delta.h │ │ └── tests │ │ │ ├── BUILD │ │ │ ├── snapshot.txt │ │ │ ├── snapshot_badly_formatted.txt │ │ │ ├── snapshot_conf.json │ │ │ ├── snapshot_inconsistent.txt │ │ │ ├── snapshot_invalid_supply.txt │ │ │ ├── test_snapshot.c │ │ │ ├── test_snapshot_metadata.c │ │ │ └── test_state_delta.c │ ├── spent_addresses │ │ ├── BUILD │ │ ├── spent_addresses_provider.c │ │ ├── spent_addresses_provider.h │ │ ├── spent_addresses_service.c │ │ ├── spent_addresses_service.h │ │ └── tests │ │ │ ├── BUILD │ │ │ ├── spent_addresses_test.txt │ │ │ ├── test_spent_addresses_provider.c │ │ │ └── test_spent_addresses_service.c │ ├── tangle │ │ ├── BUILD │ │ ├── tangle.c │ │ ├── tangle.h │ │ ├── tests │ │ │ ├── BUILD │ │ │ └── test_tangle.c │ │ ├── traversal.c │ │ └── traversal.h │ ├── test_utils │ │ ├── BUILD │ │ ├── bundle.c │ │ ├── bundle.h │ │ ├── spent_addresses.c │ │ ├── spent_addresses.h │ │ ├── tangle.c │ │ └── tangle.h │ ├── tip_selection │ │ ├── BUILD │ │ ├── cw_rating_calculator │ │ │ ├── BUILD │ │ │ ├── cw_rating_calculator.c │ │ │ ├── cw_rating_calculator.h │ │ │ ├── cw_rating_dfs_impl.c │ │ │ └── cw_rating_dfs_impl.h │ │ ├── entry_point_selector │ │ │ ├── BUILD │ │ │ ├── entry_point_selector.c │ │ │ ├── entry_point_selector.h │ │ │ └── tests │ │ │ │ ├── BUILD │ │ │ │ └── test_entry_point_selector.c │ │ ├── exit_probability_randomizer │ │ │ ├── BUILD │ │ │ ├── exit_prob_map.c │ │ │ ├── exit_prob_map.h │ │ │ ├── exit_probability_randomizer.c │ │ │ ├── exit_probability_randomizer.h │ │ │ ├── global_calcs.c │ │ │ ├── global_calcs.h │ │ │ ├── tests │ │ │ │ ├── BUILD │ │ │ │ ├── snapshot.txt │ │ │ │ └── test_exit_probability_randomizer.c │ │ │ ├── walker.c │ │ │ └── walker.h │ │ ├── exit_probability_validator │ │ │ ├── BUILD │ │ │ ├── exit_probability_validator.c │ │ │ ├── exit_probability_validator.h │ │ │ └── tests │ │ │ │ ├── BUILD │ │ │ │ ├── exit_probability_validator.c │ │ │ │ └── snapshot.txt │ │ ├── tip_selector.c │ │ └── tip_selector.h │ ├── transaction_solidifier │ │ ├── BUILD │ │ ├── transaction_solidifier.c │ │ └── transaction_solidifier.h │ └── transaction_validator │ │ ├── BUILD │ │ ├── tests │ │ ├── BUILD │ │ └── test_transaction_validator.c │ │ ├── transaction_validator.c │ │ └── transaction_validator.h ├── core.c ├── core.h ├── db │ └── .gitkeep ├── doxy.txt ├── main.c ├── node │ ├── BUILD │ ├── conf.bzl │ ├── conf.c │ ├── conf.h │ ├── doxy.txt │ ├── network │ │ ├── BUILD │ │ ├── endpoint.c │ │ ├── endpoint.h │ │ ├── neighbor.c │ │ ├── neighbor.h │ │ ├── network.h │ │ ├── router.c │ │ ├── router.h │ │ ├── uri.c │ │ └── uri.h │ ├── node.c │ ├── node.h │ ├── pipeline │ │ ├── BUILD │ │ ├── broadcaster.c │ │ ├── broadcaster.h │ │ ├── hasher.c │ │ ├── hasher.h │ │ ├── processor.c │ │ ├── processor.h │ │ ├── responder.c │ │ ├── responder.h │ │ ├── tips_requester.c │ │ ├── tips_requester.h │ │ ├── transaction_requester.c │ │ ├── transaction_requester.h │ │ ├── validator.c │ │ └── validator.h │ ├── protocol │ │ ├── BUILD │ │ ├── gossip.c │ │ ├── gossip.h │ │ ├── handshake.c │ │ ├── handshake.h │ │ ├── header.h │ │ ├── protocol.h │ │ ├── transaction_request.c │ │ └── transaction_request.h │ ├── recent_seen_bytes_cache.c │ ├── recent_seen_bytes_cache.h │ ├── tests │ │ ├── BUILD │ │ ├── test_recent_seen_bytes_cache.c │ │ └── test_tips_cache.c │ ├── tips_cache.c │ └── tips_cache.h ├── storage │ ├── BUILD │ ├── connection.h │ ├── defs.h │ ├── pack.c │ ├── pack.h │ ├── sql │ │ ├── BUILD │ │ ├── mariadb │ │ │ ├── BUILD │ │ │ ├── connection.c │ │ │ ├── connection.h │ │ │ ├── setup.sql │ │ │ ├── spent-addresses-schema.sql │ │ │ ├── storage.c │ │ │ ├── tangle-schema.sql │ │ │ ├── test_utils.c │ │ │ ├── wrappers.c │ │ │ └── wrappers.h │ │ ├── sqlite3 │ │ │ ├── BUILD │ │ │ ├── connection.c │ │ │ ├── connection.h │ │ │ ├── spent-addresses-schema.sql │ │ │ ├── storage.c │ │ │ ├── tangle-schema.sql │ │ │ ├── test_utils.c │ │ │ ├── wrappers.c │ │ │ └── wrappers.h │ │ ├── statements.c │ │ └── statements.h │ ├── storage.h │ ├── test_utils.h │ └── tests │ │ ├── BUILD │ │ ├── defs.h │ │ └── test_storage.c ├── usage.c ├── usage.h └── utils │ ├── BUILD │ ├── files.c │ ├── files.h │ ├── signed_files.c │ ├── signed_files.h │ └── tests │ ├── BUILD │ ├── fake.sig │ └── test_signed_files.c ├── cmake ├── cjson.cmake ├── embear_logger.cmake ├── gen_hash_container.sh ├── http_parser.cmake ├── keccak.cmake ├── mbedtls.cmake ├── rpi_toolchain.cmake ├── unity.cmake └── uthash.cmake ├── common ├── BUILD ├── crypto │ ├── BUILD │ ├── curl-p │ │ ├── BUILD │ │ ├── README.md │ │ ├── const.c │ │ ├── const.h │ │ ├── curl_p.c │ │ ├── digest.c │ │ ├── digest.h │ │ ├── doxy.txt │ │ ├── hamming.c │ │ ├── hamming.h │ │ ├── hashcash.c │ │ ├── hashcash.h │ │ ├── indices.h │ │ ├── pearl_diver.c │ │ ├── pearl_diver.h │ │ ├── ptrit.c │ │ ├── ptrit.h │ │ ├── search.h │ │ ├── tests │ │ │ ├── BUILD │ │ │ ├── test_cpu_hamming.c │ │ │ ├── test_cpu_hashcash.c │ │ │ ├── test_curlp.c │ │ │ ├── test_curlp_ptrit.c │ │ │ └── test_curlp_ptrit.h │ │ └── trit.h │ ├── doxy.txt │ ├── ftroika │ │ ├── BUILD │ │ ├── README.md │ │ ├── doxy.txt │ │ ├── ftroika.c │ │ ├── ftroika.h │ │ ├── general.h │ │ ├── round_constants.h │ │ ├── sbox_lookup.h │ │ ├── t27.h │ │ └── tests │ │ │ ├── BUILD │ │ │ └── test_ftroika.c │ ├── iss │ │ ├── BUILD │ │ ├── doxy.txt │ │ ├── normalize.c │ │ ├── normalize.h │ │ ├── v1 │ │ │ ├── BUILD │ │ │ ├── iss.c │ │ │ ├── iss.c.inc │ │ │ ├── iss.h │ │ │ ├── iss.h.inc │ │ │ ├── iss_curl.c │ │ │ ├── iss_curl.h │ │ │ ├── iss_kerl.c │ │ │ ├── iss_kerl.h │ │ │ └── tests │ │ │ │ ├── BUILD │ │ │ │ ├── test_iss.c │ │ │ │ ├── test_iss_curl.c │ │ │ │ └── test_iss_kerl.c │ │ └── v2 │ │ │ ├── BUILD │ │ │ ├── iss.c.inc │ │ │ ├── iss.h.inc │ │ │ ├── iss_curl.c │ │ │ ├── iss_curl.h │ │ │ ├── iss_kerl.c │ │ │ ├── iss_kerl.h │ │ │ └── tests │ │ │ ├── BUILD │ │ │ └── test_iss_curl.c │ ├── kerl │ │ ├── BUILD │ │ ├── bigint.c │ │ ├── bigint.h │ │ ├── converter.c │ │ ├── converter.h │ │ ├── doxy.txt │ │ ├── hash.c │ │ ├── hash.h │ │ ├── kerl.c │ │ ├── kerl.h │ │ └── tests │ │ │ ├── BUILD │ │ │ ├── test_converter.c │ │ │ └── test_kerl.c │ ├── sponge │ │ ├── BUILD │ │ ├── doxy.txt │ │ ├── sponge.c │ │ ├── sponge.h │ │ └── tests │ │ │ ├── BUILD │ │ │ └── test_sponge.c │ └── troika │ │ ├── BUILD │ │ ├── README.md │ │ ├── doxy.txt │ │ ├── troika.c │ │ └── troika.h ├── defs.h ├── doxy.txt ├── error_strings.h ├── errors.c ├── errors.h ├── helpers │ ├── BUILD │ ├── checksum.c │ ├── checksum.h │ ├── digest.c │ ├── digest.h │ ├── doxy.txt │ ├── pow.c │ ├── pow.h │ ├── sign.c │ ├── sign.h │ └── tests │ │ ├── BUILD │ │ ├── test_checksum.c │ │ ├── test_digest.c │ │ ├── test_pow.c │ │ └── test_sign.c ├── model │ ├── BUILD │ ├── bundle.c │ ├── bundle.h │ ├── doxy.txt │ ├── inputs.h │ ├── milestone.h │ ├── tests │ │ ├── BUILD │ │ ├── defs.h │ │ ├── test_bundle.c │ │ ├── test_inputs.c │ │ ├── test_transaction.c │ │ ├── test_transfer.c │ │ └── test_tryte_transaction.cc │ ├── transaction.c │ ├── transaction.h │ ├── transfer.c │ ├── transfer.h │ ├── tryte_transaction.cc │ └── tryte_transaction.h ├── stdint.h └── trinary │ ├── BUILD │ ├── add.c │ ├── add.h │ ├── bytes.h │ ├── doxy.txt │ ├── flex_trit.c │ ├── flex_trit.h │ ├── ptrit.c │ ├── ptrit.h │ ├── ptrit_incr.c │ ├── ptrit_incr.h │ ├── tests │ ├── BUILD │ ├── test_add.c │ ├── test_flex_trit.c │ ├── test_ptrits.c │ ├── test_trit_byte.c │ ├── test_trit_long.c │ ├── test_trit_ptrit.c │ ├── test_trit_tryte.c │ ├── test_tryte_ascii.c │ └── test_tryte_long.c │ ├── trit_byte.c │ ├── trit_byte.h │ ├── trit_long.c │ ├── trit_long.h │ ├── trit_ptrit.h │ ├── trit_tryte.c │ ├── trit_tryte.h │ ├── trits.h │ ├── tryte.h │ ├── tryte_ascii.c │ ├── tryte_ascii.h │ ├── tryte_long.c │ └── tryte_long.h ├── cppclient ├── BUILD ├── api.h ├── api_json.cc ├── api_json.h ├── beast.cc ├── beast.h ├── messages.h └── tests │ ├── api_json.cc │ └── beast.cc ├── docs ├── README.md ├── doxygen │ ├── IOTA_Logo_black.png │ ├── footer.html │ ├── header.html │ ├── layout.xml │ └── stylesheet.css ├── labels.json └── pull_request_template.md ├── mam ├── BUILD ├── README.md ├── api │ ├── BUILD │ ├── api.c │ ├── api.h │ └── tests │ │ ├── BUILD │ │ └── test_api.c ├── defs.h ├── doxy.txt ├── examples │ ├── BUILD │ ├── README.md │ ├── common.c │ ├── common.h │ ├── ntru-key-exchange.c │ ├── recv.c │ ├── send-common.c │ ├── send-common.h │ ├── send-header.c │ ├── send-msg.c │ └── send-packet.c ├── mam │ ├── BUILD │ ├── channel.c │ ├── channel.h │ ├── endpoint.c │ ├── endpoint.h │ ├── message.c │ ├── message.h │ └── tests │ │ ├── BUILD │ │ ├── test_channel.c │ │ ├── test_channel_utils.c │ │ ├── test_channel_utils.h │ │ ├── test_endpoint.c │ │ └── test_message.c ├── mss │ ├── BUILD │ ├── mss.h │ ├── mss_classic.c │ ├── mss_classic.h │ ├── mss_common.c │ ├── mss_common.h │ ├── mss_traversal.c │ ├── mss_traversal.h │ └── tests │ │ ├── BUILD │ │ └── test_mss.c ├── ntru │ ├── BUILD │ ├── ntru.c │ ├── ntru.h │ ├── ntru_types.h │ ├── poly.c │ ├── poly.h │ ├── poly_param.h │ └── tests │ │ ├── BUILD │ │ ├── test_ntru.c │ │ └── test_poly.c ├── pb3 │ ├── BUILD │ ├── pb3.c │ ├── pb3.h │ └── tests │ │ ├── BUILD │ │ └── test_pb3.c ├── prng │ ├── BUILD │ ├── prng.c │ ├── prng.h │ └── tests │ │ ├── BUILD │ │ └── test_prng.c ├── prototype │ ├── BUILD │ ├── mam.c │ ├── mam.h │ ├── mask.c │ ├── mask.h │ └── tests │ │ ├── BUILD │ │ ├── test_mam.c │ │ └── test_mask.c ├── psk │ ├── BUILD │ ├── psk.c │ ├── psk.h │ └── tests │ │ ├── BUILD │ │ └── test_psk.c ├── rep.pdf ├── spec.pdf ├── sponge │ ├── BUILD │ ├── sponge.c │ ├── sponge.h │ ├── spongos.c │ ├── spongos.h │ ├── spongos_types.c │ ├── spongos_types.h │ └── tests │ │ ├── BUILD │ │ ├── test_sponge.c │ │ └── test_spongos.c ├── trits │ ├── BUILD │ ├── buffers.c │ ├── buffers.h │ ├── tests │ │ ├── BUILD │ │ └── test_trits.c │ ├── trits.c │ └── trits.h ├── troika │ ├── BUILD │ ├── tests │ │ ├── BUILD │ │ └── test_troika.c │ ├── troika.c │ └── troika.h └── wots │ ├── BUILD │ ├── tests │ ├── BUILD │ └── test_wots.c │ ├── wots.c │ └── wots.h ├── mobile ├── android │ ├── AndroidManifest.xml │ ├── BUILD │ ├── Interface.cpp │ ├── Interface.h │ ├── demo │ │ ├── App.java │ │ └── DummyActivity.java │ ├── java │ │ └── Interface.java │ └── jni.h └── ios │ ├── BUILD │ ├── Demo │ ├── Demo.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── EntangledDemo.xcscheme │ ├── Demo │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Constants.h │ │ ├── Constants.m │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ ├── DemoTests │ │ ├── DemoTests.m │ │ ├── Info.plist │ │ ├── TestConstants.h │ │ └── TestConstants.m │ └── Frameworks │ │ └── .gitkeep │ ├── Interface.h │ ├── Interface.mm │ └── README.md ├── tanglescope ├── BUILD ├── README.md ├── blowballcollector.cpp ├── blowballcollector.hpp ├── broadcastrecievecollecter.cpp ├── broadcastrecievecollecter.hpp ├── collector │ ├── BUILD │ ├── collector.cpp │ └── collector.hpp ├── common │ ├── BUILD │ ├── iri.cpp │ ├── iri.hpp │ ├── tangledb.cpp │ ├── tangledb.hpp │ ├── tests │ │ └── iri.cpp │ ├── txauxiliary.cpp │ ├── txauxiliary.hpp │ ├── zmqdbloader.cpp │ ├── zmqdbloader.hpp │ ├── zmqpub.cpp │ └── zmqpub.hpp ├── confirmationratecollector.cpp ├── confirmationratecollector.hpp ├── doxy.txt ├── echocollector.cpp ├── echocollector.hpp ├── prometheus_collector │ ├── BUILD │ ├── prometheus_collector.cpp │ └── prometheus_collector.hpp ├── runner │ ├── BUILD │ ├── configuration.yaml │ ├── runner.cpp │ └── tests │ │ └── tanglescope.cpp ├── statscollector │ ├── BUILD │ ├── analyzer.cpp │ ├── analyzer.hpp │ ├── stats │ │ ├── frame.cpp │ │ ├── frame.hpp │ │ ├── noop.hpp │ │ └── stats.hpp │ ├── statscollector.cpp │ ├── statscollector.hpp │ └── tests │ │ └── test_analyzer.cpp ├── tanglewidthcollector.cpp ├── tanglewidthcollector.hpp ├── tipselectioncollector.cpp └── tipselectioncollector.hpp ├── tools ├── BUILD ├── bazel.rc ├── buildifier ├── ci_buildifier_check ├── ci_format_check ├── ci_test_setup ├── cppcheck │ └── googletest.cfg ├── cpplint ├── cpplint.py ├── formatter ├── hooks │ ├── autohook.sh │ ├── pre-commit │ │ ├── 01-buildifier-check │ │ ├── 02-cpplint │ │ └── 03-format-check │ └── scripts │ │ ├── buildifier_check │ │ ├── cpplint │ │ └── format_check ├── remote.rc ├── snapshot.bzl └── toolchains.rc └── utils ├── BUILD ├── bundle_miner.c ├── bundle_miner.h ├── char_buffer.c ├── char_buffer.h ├── containers ├── BUILD ├── bitset.c ├── bitset.h ├── hash │ ├── BUILD │ ├── hash_array.c │ ├── hash_array.h │ ├── hash_container_generator.bzl │ ├── hash_map.c.tpl │ ├── hash_map.h.tpl │ ├── hash_map_generator.bzl │ ├── hash_queue.c.tpl │ ├── hash_queue.h.tpl │ ├── hash_set.c.tpl │ ├── hash_set.h.tpl │ ├── hash_stack.c.tpl │ ├── hash_stack.h.tpl │ └── tests │ │ ├── BUILD │ │ ├── defs.h │ │ ├── test_hash_array.c │ │ ├── test_hash_map.c │ │ ├── test_hash_queue.c │ │ └── test_hash_stack.c ├── map.c.tpl ├── map.h.tpl ├── map_generator.bzl ├── person_example.h ├── set.c.tpl ├── set.h.tpl ├── tests │ ├── BUILD │ ├── test_map.c │ └── test_set.c └── typed_container_generator.bzl ├── doxy.txt ├── export.h ├── forced_inline.h ├── handles ├── BUILD ├── cond.h ├── lock.h ├── rand.h ├── rw_lock.h ├── signal.h └── thread.h ├── hash_indexed_map.c ├── hash_indexed_map.h ├── logger_helper.c ├── logger_helper.h ├── macros.h ├── memset_safe.c ├── memset_safe.h ├── merkle.c ├── merkle.h ├── system.c ├── system.h ├── tests ├── BUILD ├── test_bundle_miner.c └── test_merkle.c ├── time.c ├── time.h └── windows.h /.bazelignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/.bazelignore -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | import %workspace%/tools/bazel.rc 2 | import %workspace%/tools/remote.rc 3 | import %workspace%/tools/toolchains.rc 4 | try-import %workspace%/user.bazelrc 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/.gitmodules -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/BUILD -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @tsvisabo @thibault-martinez @oopsmonk 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:17.10 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | #install prerequisits 6 | RUN apt-get update && \ 7 | apt-get -y install sudo 8 | 9 | RUN sudo apt update && sudo apt -y install ocl-icd-opencl-dev 10 | 11 | RUN sudo apt -y install opencl-headers && sudo apt-get -y install libssl-dev 12 | -------------------------------------------------------------------------------- /cclient/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "service", 3 | srcs = [ 4 | "service.c", 5 | ], 6 | hdrs = ["service.h"], 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "//cclient/request:requests", 10 | "//cclient/response:responses", 11 | "//cclient/serialization:serializer_json", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /cclient/api/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "api_core", 3 | srcs = glob([ 4 | "core/*.c", 5 | "core/*.h", 6 | ]), 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//cclient:service", 10 | "//cclient/http", 11 | "//common/helpers", 12 | "//common/model:bundle", 13 | "//utils:logger_helper", 14 | ], 15 | ) 16 | 17 | cc_library( 18 | name = "api_extended", 19 | srcs = glob([ 20 | "extended/*.c", 21 | "extended/*.h", 22 | ]), 23 | visibility = ["//visibility:private"], 24 | deps = [ 25 | ":api_core", 26 | "//common/model:inputs", 27 | "//common/model:transfer", 28 | "//utils:time", 29 | ], 30 | ) 31 | 32 | cc_library( 33 | name = "api", 34 | hdrs = glob([ 35 | "core/core_api.h", 36 | "extended/extended_api.h", 37 | ]), 38 | visibility = ["//visibility:public"], 39 | deps = [ 40 | ":api_extended", 41 | ], 42 | ) 43 | 44 | cc_binary( 45 | name = "libcclient.so", 46 | linkshared = True, 47 | visibility = ["//visibility:public"], 48 | deps = [":api"], 49 | ) 50 | -------------------------------------------------------------------------------- /cclient/api/core/core_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef CCLIENT_API_CORE_API_H 9 | #define CCLIENT_API_CORE_API_H 10 | 11 | #include "cclient/api/core/add_neighbors.h" 12 | #include "cclient/api/core/attach_to_tangle.h" 13 | #include "cclient/api/core/broadcast_transactions.h" 14 | #include "cclient/api/core/check_consistency.h" 15 | #include "cclient/api/core/core_init.h" 16 | #include "cclient/api/core/find_transactions.h" 17 | #include "cclient/api/core/get_balances.h" 18 | #include "cclient/api/core/get_inclusion_states.h" 19 | #include "cclient/api/core/get_neighbors.h" 20 | #include "cclient/api/core/get_node_api_conf.h" 21 | #include "cclient/api/core/get_node_info.h" 22 | #include "cclient/api/core/get_tips.h" 23 | #include "cclient/api/core/get_transactions_to_approve.h" 24 | #include "cclient/api/core/get_trytes.h" 25 | #include "cclient/api/core/remove_neighbors.h" 26 | #include "cclient/api/core/store_transactions.h" 27 | #include "cclient/api/core/were_addresses_spent_from.h" 28 | 29 | #endif // CCLIENT_API_CORE_API_H 30 | -------------------------------------------------------------------------------- /cclient/api/core/core_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/core/core_init.h" 9 | #include "cclient/api/core/logger.h" 10 | 11 | retcode_t iota_client_core_init(iota_client_service_t* const serv) { 12 | logger_init_client_core(); 13 | return iota_client_service_init(serv); 14 | } 15 | 16 | void iota_client_core_destroy(iota_client_service_t* const serv) { 17 | logger_destroy_client_core(); 18 | iota_client_service_destroy(serv); 19 | } 20 | -------------------------------------------------------------------------------- /cclient/api/core/core_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_CORE_INIT_H 18 | #define CCLIENT_API_CORE_INIT_H 19 | 20 | #include "cclient/http/http.h" 21 | #include "cclient/service.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief This function should be called before using Core APIs. 29 | * 30 | * 31 | * @param[in] serv client service 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_core_init(iota_client_service_t* const serv); 35 | 36 | /** 37 | * @brief This function should be called for cleanup. 38 | * 39 | * @param[in] serv client service 40 | */ 41 | void iota_client_core_destroy(iota_client_service_t* const serv); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // CCLIENT_API_CORE_INIT_H 48 | 49 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/core/get_neighbors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_GET_NEIGHBORS_H 18 | #define CCLIENT_API_GET_NEIGHBORS_H 19 | 20 | #include "cclient/http/http.h" 21 | #include "cclient/response/get_neighbors.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Returns a list of connected neighbors. 29 | * 30 | * @param[in] service client service 31 | * @param[out] res A list of neighbors. 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_get_neighbors(iota_client_service_t const* const service, get_neighbors_res_t* const res); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // CCLIENT_API_GET_NEIGHBORS_H 41 | 42 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/core/get_node_api_conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_GET_NODE_API_CONF_H 18 | #define CCLIENT_API_GET_NODE_API_CONF_H 19 | 20 | #include "cclient/http/http.h" 21 | #include "cclient/response/get_node_api_conf.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Returns configuration of the connected node. 29 | * 30 | * @param[in] service client service 31 | * @param[out] res node configuration 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_get_node_api_conf(iota_client_service_t const* const service, get_node_api_conf_res_t* res); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // CCLIENT_API_GET_NODE_API_CONF_H 41 | 42 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/core/get_node_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_GET_NODE_INFO_H 18 | #define CCLIENT_API_GET_NODE_INFO_H 19 | 20 | #include "cclient/http/http.h" 21 | #include "cclient/response/get_node_info.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Returns information about connected node. 29 | * 30 | * @param[in] service client service 31 | * @param[out] res node information 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_get_node_info(iota_client_service_t const* const service, get_node_info_res_t* res); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // CCLIENT_API_GET_NODE_INFO_H 41 | 42 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/core/get_tips.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_GET_TIPS_H 18 | #define CCLIENT_API_GET_TIPS_H 19 | 20 | #include "cclient/http/http.h" 21 | #include "cclient/response/get_tips.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * @brief Returns a list of tips (transactions not referenced by other transactions). 29 | * 30 | * @param[in] service 31 | * @param[out] res 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_get_tips(iota_client_service_t const* const service, get_tips_res_t* const res); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // CCLIENT_API_GET_TIPS_H 41 | 42 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/core/logger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/core/logger.h" 9 | 10 | #define CCLIENT_CORE_LOGGER_ID "cclient_core" 11 | 12 | logger_id_t client_core_logger_id; 13 | 14 | void logger_init_client_core() { 15 | client_core_logger_id = logger_helper_enable(CCLIENT_CORE_LOGGER_ID, LOGGER_DEBUG, true); 16 | log_info(client_core_logger_id, "[%s:%d] enable logger %s.\n", __func__, __LINE__, CCLIENT_CORE_LOGGER_ID); 17 | } 18 | 19 | void logger_destroy_client_core() { 20 | log_info(client_core_logger_id, "[%s:%d] destroy logger %s.\n", __func__, __LINE__, CCLIENT_CORE_LOGGER_ID); 21 | logger_helper_release(client_core_logger_id); 22 | } 23 | -------------------------------------------------------------------------------- /cclient/api/core/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_core 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_CORE_LOGGER_H 18 | #define CCLIENT_API_CORE_LOGGER_H 19 | 20 | #include "utils/logger_helper.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * @brief logger ID 28 | * 29 | */ 30 | extern logger_id_t client_core_logger_id; 31 | 32 | /** 33 | * @brief init Core API logger 34 | * 35 | */ 36 | void logger_init_client_core(); 37 | 38 | /** 39 | * @brief cleanup Core API logger 40 | * 41 | */ 42 | void logger_destroy_client_core(); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // CCLIENT_API_CORE_LOGGER_H 49 | 50 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/examples/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "cclient_examples", 5 | srcs = glob([ 6 | "*.c", 7 | "*.h", 8 | ]), 9 | deps = [ 10 | "//cclient/api", 11 | "//utils:logger_helper", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /cclient/api/examples/example_get_tips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/examples/cclient_examples.h" 9 | 10 | void example_get_tips(iota_client_service_t *s) { 11 | printf("\n[%s]\n", __FUNCTION__); 12 | get_tips_res_t *tips_res = get_tips_res_new(); 13 | if (tips_res) { 14 | hash243_stack_entry_t *q_iter = NULL; 15 | if (iota_client_get_tips(s, tips_res) == RC_OK) { 16 | CDL_FOREACH(tips_res->hashes, q_iter) { 17 | flex_trit_print(q_iter->hash, NUM_TRITS_HASH); 18 | printf("\n"); 19 | } 20 | printf("Tips: %lu\n", get_tips_res_hash_num(tips_res)); 21 | } 22 | 23 | get_tips_res_free(&tips_res); 24 | } else { 25 | printf("Error OOM\n"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cclient/api/examples/example_is_promotable.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/examples/cclient_examples.h" 9 | 10 | static tryte_t const *const TAIL_HASH = 11 | (tryte_t *)"9GKLL9R9YFXKBQRJNNGFSONCWRVDUJWQFYGWCTAAY9LWZMHEMAWVMIYYYKZXIIOZECKXBRWPEAUEGB999"; 12 | 13 | void example_is_promotable(iota_client_service_t *s) { 14 | printf("\n[%s]\n", __FUNCTION__); 15 | retcode_t ret = RC_ERROR; 16 | flex_trit_t trits_243[FLEX_TRIT_SIZE_243]; 17 | bool is_promotable = false; 18 | 19 | if (flex_trits_from_trytes(trits_243, NUM_TRITS_HASH, TAIL_HASH, NUM_TRYTES_HASH, NUM_TRYTES_HASH) == 0) { 20 | printf("Error: converting flex_trit failed.\n"); 21 | return; 22 | } 23 | 24 | if ((ret = iota_client_is_promotable(s, trits_243, &is_promotable)) == RC_OK) { 25 | printf("promotable: %d \n", is_promotable); 26 | } else { 27 | printf("Error: %s \n", error_2_string(ret)); 28 | } 29 | } -------------------------------------------------------------------------------- /cclient/api/examples/example_node_api_conf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/examples/cclient_examples.h" 9 | 10 | void example_node_api_conf(iota_client_service_t *s) { 11 | printf("\n[%s]\n", __FUNCTION__); 12 | retcode_t ret = RC_ERROR; 13 | get_node_api_conf_res_t node_conf = {}; 14 | 15 | if ((ret = iota_client_get_node_api_conf(s, &node_conf)) == RC_OK) { 16 | printf("maxFindTransactions: %" PRIu32 " \n", node_conf.max_find_transactions); 17 | printf("maxRequestsList: %" PRIu32 " \n", node_conf.max_requests_list); 18 | printf("maxGetTrytes: %" PRIu32 " \n", node_conf.max_get_trytes); 19 | printf("maxBodyLength: %" PRIu32 " \n", node_conf.max_body_length); 20 | printf("milestoneStartIndex: %" PRIu32 " \n", node_conf.milestone_start_index); 21 | printf("testNet: %s\n", node_conf.test_net ? "true" : "false"); 22 | 23 | } else { 24 | printf("Error: %s", error_2_string(ret)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cclient/api/extended/extended_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/extended/extended_init.h" 9 | #include "cclient/api/extended/logger.h" 10 | 11 | void iota_client_extended_init() { logger_init_client_extended(); } 12 | 13 | void iota_client_extended_destroy() { logger_destroy_client_extended(); } 14 | -------------------------------------------------------------------------------- /cclient/api/extended/extended_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_extended 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_EXTENDED_INIT_H 18 | #define CCLIENT_API_EXTENDED_INIT_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * @brief Init client extended APIs 26 | * 27 | */ 28 | void iota_client_extended_init(); 29 | 30 | /** 31 | * @brief Destroy client extended APIs 32 | * 33 | */ 34 | void iota_client_extended_destroy(); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // CCLIENT_API_EXTENDED_INIT_H 41 | 42 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/extended/get_bundle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/extended/get_bundle.h" 9 | #include "cclient/api/extended/logger.h" 10 | #include "cclient/api/extended/traverse_bundle.h" 11 | 12 | retcode_t iota_client_get_bundle(iota_client_service_t const* const serv, flex_trit_t const* const tail_hash, 13 | bundle_transactions_t* const bundle, bundle_status_t* const bundle_status) { 14 | log_debug(client_extended_logger_id, "[%s:%d]\n", __func__, __LINE__); 15 | retcode_t ret_code = iota_client_traverse_bundle(serv, tail_hash, bundle); 16 | if (ret_code == RC_OK) { 17 | bundle_validate(bundle, bundle_status); 18 | } 19 | return ret_code; 20 | } 21 | -------------------------------------------------------------------------------- /cclient/api/extended/get_transaction_objects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_extended 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_GET_TRANSACTION_OBJECTS_H 18 | #define CCLIENT_API_GET_TRANSACTION_OBJECTS_H 19 | 20 | #include "cclient/http/http.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * @brief Fetches the transaction objects, given a list of transaction hashes. 28 | * 29 | * @param[in] serv client service 30 | * @param[in] tx_hashes List of transaction hashes 31 | * @param[out] out_tx_objs List of transaction objects 32 | * @return #retcode_t 33 | */ 34 | retcode_t iota_client_get_transaction_objects(iota_client_service_t const* const serv, 35 | get_trytes_req_t* const tx_hashes, transaction_array_t* out_tx_objs); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif // CCLIENT_API_GET_TRANSACTION_OBJECTS_H 42 | 43 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/extended/logger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/extended/logger.h" 9 | 10 | #define CCLIENT_EXTENDED_LOGGER_ID "cclient_extended" 11 | 12 | logger_id_t client_extended_logger_id; 13 | 14 | void logger_init_client_extended() { 15 | client_extended_logger_id = logger_helper_enable(CCLIENT_EXTENDED_LOGGER_ID, LOGGER_DEBUG, true); 16 | log_info(client_extended_logger_id, "[%s:%d] enable logger %s.\n", __func__, __LINE__, CCLIENT_EXTENDED_LOGGER_ID); 17 | } 18 | 19 | void logger_destroy_client_extended() { 20 | log_info(client_extended_logger_id, "[%s:%d] destroy logger %s.\n", __func__, __LINE__, CCLIENT_EXTENDED_LOGGER_ID); 21 | logger_helper_release(client_extended_logger_id); 22 | } 23 | -------------------------------------------------------------------------------- /cclient/api/extended/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup cclient_extended 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_API_EXTENDED_LOGGER_H 18 | #define CCLIENT_API_EXTENDED_LOGGER_H 19 | 20 | #include "utils/logger_helper.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * @brief Logger ID for extended APIs. 28 | * 29 | */ 30 | extern logger_id_t client_extended_logger_id; 31 | 32 | /** 33 | * @brief Init extended API logger 34 | * 35 | */ 36 | void logger_init_client_extended(); 37 | 38 | /** 39 | * @brief Destroy extended API logger 40 | * 41 | */ 42 | void logger_destroy_client_extended(); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // CCLIENT_API_EXTENDED_LOGGER_H 49 | 50 | /** @} */ -------------------------------------------------------------------------------- /cclient/api/extended/store_and_broadcast.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/extended/store_and_broadcast.h" 9 | #include "cclient/api/extended/logger.h" 10 | 11 | retcode_t iota_client_store_and_broadcast(iota_client_service_t const* const serv, 12 | store_transactions_req_t const* const trytes) { 13 | retcode_t ret_code = RC_ERROR; 14 | ret_code = iota_client_store_transactions(serv, trytes); 15 | if (ret_code == RC_OK) { 16 | ret_code = iota_client_broadcast_transactions(serv, (broadcast_transactions_req_t*)trytes); 17 | if (ret_code) { 18 | log_error(client_extended_logger_id, "sending broadcast transaction failed: %s\n", error_2_string(ret_code)); 19 | } 20 | } else { 21 | log_error(client_extended_logger_id, "sending store transaction failed: %s\n", error_2_string(ret_code)); 22 | } 23 | return ret_code; 24 | } 25 | -------------------------------------------------------------------------------- /cclient/api/tests/test_add_neighbors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/tests/cclient_test_defs.h" 9 | 10 | static iota_client_service_t g_serv; 11 | 12 | static void test_add_neighbors_empty(void) { 13 | add_neighbors_req_t *nb_req = add_neighbors_req_new(); 14 | TEST_ASSERT_NOT_NULL(nb_req); 15 | TEST_ASSERT_NOT_NULL(nb_req->uris); 16 | 17 | add_neighbors_res_t *nb_res = add_neighbors_res_new(); 18 | TEST_ASSERT_NOT_NULL(nb_res); 19 | TEST_ASSERT_EQUAL_INT(0, nb_res->added_neighbors); 20 | 21 | TEST_ASSERT_EQUAL_INT16(RC_NULL_PARAM, iota_client_add_neighbors(&g_serv, nb_req, nb_res)); 22 | 23 | add_neighbors_req_free(&nb_req); 24 | TEST_ASSERT_NULL(nb_req); 25 | add_neighbors_res_free(&nb_res); 26 | TEST_ASSERT_NULL(nb_res); 27 | } 28 | 29 | int main() { 30 | UNITY_BEGIN(); 31 | 32 | cclient_service_setup(&g_serv); 33 | 34 | RUN_TEST(test_add_neighbors_empty); 35 | 36 | cclient_service_cleanup(&g_serv); 37 | return UNITY_END(); 38 | } 39 | -------------------------------------------------------------------------------- /cclient/api/tests/test_broadcast_transactions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/tests/cclient_test_defs.h" 9 | 10 | static iota_client_service_t g_serv; 11 | 12 | static void test_broadcast_transactions_empty(void) { 13 | broadcast_transactions_req_t *bc_tx_req = broadcast_transactions_req_new(); 14 | TEST_ASSERT_NOT_NULL(bc_tx_req); 15 | TEST_ASSERT_NULL(bc_tx_req->trytes); 16 | 17 | TEST_ASSERT_EQUAL_INT16(RC_NULL_PARAM, iota_client_broadcast_transactions(&g_serv, bc_tx_req)); 18 | 19 | broadcast_transactions_req_free(&bc_tx_req); 20 | TEST_ASSERT_NULL(bc_tx_req); 21 | } 22 | 23 | int main() { 24 | UNITY_BEGIN(); 25 | 26 | cclient_service_setup(&g_serv); 27 | 28 | RUN_TEST(test_broadcast_transactions_empty); 29 | 30 | cclient_service_cleanup(&g_serv); 31 | 32 | return UNITY_END(); 33 | } 34 | -------------------------------------------------------------------------------- /cclient/api/tests/test_get_tips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/tests/cclient_test_defs.h" 9 | 10 | static iota_client_service_t g_serv; 11 | 12 | static void test_get_tips(void) { 13 | get_tips_res_t *tips_res = get_tips_res_new(); 14 | TEST_ASSERT_NOT_NULL(tips_res); 15 | TEST_ASSERT_NULL(tips_res->hashes); 16 | 17 | TEST_ASSERT_EQUAL_INT16(RC_OK, iota_client_get_tips(&g_serv, tips_res)); 18 | 19 | TEST_ASSERT_NOT_NULL(tips_res->hashes); 20 | 21 | get_tips_res_free(&tips_res); 22 | TEST_ASSERT_NULL(tips_res); 23 | } 24 | 25 | int main() { 26 | UNITY_BEGIN(); 27 | 28 | cclient_service_setup(&g_serv); 29 | 30 | RUN_TEST(test_get_tips); 31 | 32 | cclient_service_cleanup(&g_serv); 33 | 34 | return UNITY_END(); 35 | } 36 | -------------------------------------------------------------------------------- /cclient/api/tests/test_remove_neighbors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/tests/cclient_test_defs.h" 9 | 10 | static iota_client_service_t g_serv; 11 | 12 | static void test_remove_neighbors_empty(void) { 13 | remove_neighbors_req_t *nb_req = remove_neighbors_req_new(); 14 | TEST_ASSERT_NOT_NULL(nb_req); 15 | TEST_ASSERT_NOT_NULL(nb_req->uris); 16 | 17 | remove_neighbors_res_t *nb_res = remove_neighbors_res_new(); 18 | TEST_ASSERT_NOT_NULL(nb_res); 19 | TEST_ASSERT_EQUAL_INT(0, nb_res->removed_neighbors); 20 | 21 | TEST_ASSERT_EQUAL_INT16(RC_NULL_PARAM, iota_client_remove_neighbors(&g_serv, nb_req, nb_res)); 22 | 23 | remove_neighbors_req_free(&nb_req); 24 | TEST_ASSERT_NULL(nb_req); 25 | remove_neighbors_res_free(&nb_res); 26 | TEST_ASSERT_NULL(nb_res); 27 | } 28 | 29 | int main() { 30 | UNITY_BEGIN(); 31 | 32 | cclient_service_setup(&g_serv); 33 | 34 | RUN_TEST(test_remove_neighbors_empty); 35 | 36 | cclient_service_cleanup(&g_serv); 37 | 38 | return UNITY_END(); 39 | } 40 | -------------------------------------------------------------------------------- /cclient/api/tests/test_store_transactions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/api/tests/cclient_test_defs.h" 9 | 10 | static iota_client_service_t g_serv; 11 | 12 | static void test_store_transactions_empty(void) { 13 | store_transactions_req_t *store_tx_req = store_transactions_req_new(); 14 | TEST_ASSERT_NOT_NULL(store_tx_req); 15 | TEST_ASSERT_NOT_NULL(store_tx_req->trytes); 16 | 17 | TEST_ASSERT_EQUAL_INT16(RC_NULL_PARAM, iota_client_store_transactions(&g_serv, store_tx_req)); 18 | 19 | store_transactions_req_free(&store_tx_req); 20 | TEST_ASSERT_NULL(store_tx_req); 21 | } 22 | 23 | int main() { 24 | UNITY_BEGIN(); 25 | 26 | cclient_service_setup(&g_serv); 27 | 28 | RUN_TEST(test_store_transactions_empty); 29 | 30 | cclient_service_cleanup(&g_serv); 31 | 32 | return UNITY_END(); 33 | } 34 | -------------------------------------------------------------------------------- /cclient/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup cclient CClient 10 | * @brief CClient APIs implementations. 11 | * 12 | * The CClient module contains core and extended APIs in the client library. 13 | */ -------------------------------------------------------------------------------- /cclient/http/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup cclient_http HTTP Client 10 | * @ingroup cclient 11 | * @brief The HTTP/HTTPS Client implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /cclient/http/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_http", 3 | timeout = "short", 4 | srcs = [ 5 | "test_http.c", 6 | ], 7 | flaky = True, 8 | deps = [ 9 | "//cclient/http", 10 | "@cJSON", 11 | "@unity", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /cclient/request/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "requests", 3 | srcs = glob([ 4 | "*.c", 5 | ]), 6 | hdrs = glob([ 7 | "*.h", 8 | ]), 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "//common:errors", 12 | "//common/model:transaction", 13 | "//utils/containers/hash:hash243_queue", 14 | "//utils/containers/hash:hash81_queue", 15 | "//utils/containers/hash:hash_array", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /cclient/request/check_consistency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/check_consistency.h" 11 | 12 | check_consistency_req_t *check_consistency_req_new() { 13 | check_consistency_req_t *req = (check_consistency_req_t *)malloc(sizeof(check_consistency_req_t)); 14 | if (req) { 15 | req->tails = NULL; 16 | } 17 | return req; 18 | } 19 | 20 | void check_consistency_req_free(check_consistency_req_t **req) { 21 | if (!req || !(*req)) { 22 | return; 23 | } 24 | 25 | if ((*req)->tails) { 26 | hash243_queue_free(&(*req)->tails); 27 | } 28 | free(*req); 29 | *req = NULL; 30 | } 31 | -------------------------------------------------------------------------------- /cclient/request/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup request Requests 10 | * @brief The request objects provide read/write methods for the API requests. 11 | * 12 | * Request data structures: 13 | * - #add_neighbors_req_t 14 | * - #attach_to_tangle_req_t 15 | * - #broadcast_transactions_req_t 16 | * - #check_consistency_req_t 17 | * - #find_transactions_req_t 18 | * - #get_balances_req_t 19 | * - #get_inclusion_states_req_t 20 | * - #get_transactions_to_approve_req_t 21 | * - #get_trytes_req_t 22 | * - #remove_neighbors_req_t 23 | * - #store_transactions_req_t 24 | * 25 | */ 26 | -------------------------------------------------------------------------------- /cclient/request/find_transactions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/find_transactions.h" 11 | 12 | find_transactions_req_t* find_transactions_req_new() { 13 | find_transactions_req_t* req = (find_transactions_req_t*)malloc(sizeof(find_transactions_req_t)); 14 | if (req) { 15 | req->bundles = NULL; 16 | req->addresses = NULL; 17 | req->tags = NULL; 18 | req->approvees = NULL; 19 | } 20 | return req; 21 | } 22 | 23 | void find_transactions_req_free(find_transactions_req_t** req) { 24 | if (!req || !(*req)) { 25 | return; 26 | } 27 | 28 | if ((*req)->bundles) { 29 | hash243_queue_free(&(*req)->bundles); 30 | } 31 | if ((*req)->addresses) { 32 | hash243_queue_free(&(*req)->addresses); 33 | } 34 | if ((*req)->tags) { 35 | hash81_queue_free(&(*req)->tags); 36 | } 37 | if ((*req)->approvees) { 38 | hash243_queue_free(&(*req)->approvees); 39 | } 40 | free(*req); 41 | *req = NULL; 42 | } 43 | -------------------------------------------------------------------------------- /cclient/request/get_balances.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/get_balances.h" 11 | 12 | get_balances_req_t* get_balances_req_new() { 13 | get_balances_req_t* req = (get_balances_req_t*)malloc(sizeof(get_balances_req_t)); 14 | if (req) { 15 | req->addresses = NULL; 16 | req->tips = NULL; 17 | req->threshold = 0; 18 | } 19 | return req; 20 | } 21 | 22 | void get_balances_req_free(get_balances_req_t** req) { 23 | if (!req || !(*req)) { 24 | return; 25 | } 26 | 27 | if ((*req)->addresses) { 28 | hash243_queue_free(&(*req)->addresses); 29 | } 30 | if ((*req)->tips) { 31 | hash243_queue_free(&(*req)->tips); 32 | } 33 | 34 | free(*req); 35 | *req = NULL; 36 | } 37 | -------------------------------------------------------------------------------- /cclient/request/get_inclusion_states.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/get_inclusion_states.h" 11 | 12 | get_inclusion_states_req_t* get_inclusion_states_req_new() { 13 | get_inclusion_states_req_t* req = (get_inclusion_states_req_t*)malloc(sizeof(get_inclusion_states_req_t)); 14 | if (req) { 15 | req->transactions = NULL; 16 | req->tips = NULL; 17 | } 18 | return req; 19 | } 20 | 21 | void get_inclusion_states_req_free(get_inclusion_states_req_t** req) { 22 | if (!req || !(*req)) { 23 | return; 24 | } 25 | 26 | if ((*req)->transactions) { 27 | hash243_queue_free(&(*req)->transactions); 28 | } 29 | if ((*req)->tips) { 30 | hash243_queue_free(&(*req)->tips); 31 | } 32 | free(*req); 33 | *req = NULL; 34 | } 35 | -------------------------------------------------------------------------------- /cclient/request/get_trytes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/get_trytes.h" 11 | 12 | get_trytes_req_t* get_trytes_req_new() { 13 | get_trytes_req_t* req = (get_trytes_req_t*)malloc(sizeof(get_trytes_req_t)); 14 | if (req) { 15 | req->hashes = NULL; 16 | } 17 | return req; 18 | } 19 | 20 | void get_trytes_req_free(get_trytes_req_t** const req) { 21 | if (!req || !(*req)) { 22 | return; 23 | } 24 | 25 | if ((*req)->hashes) { 26 | hash243_queue_free(&(*req)->hashes); 27 | } 28 | 29 | free(*req); 30 | *req = NULL; 31 | } 32 | -------------------------------------------------------------------------------- /cclient/request/requests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef CCLIENT_REQUEST_REQUESTS_H 9 | #define CCLIENT_REQUEST_REQUESTS_H 10 | 11 | #include "cclient/request/add_neighbors.h" 12 | #include "cclient/request/attach_to_tangle.h" 13 | #include "cclient/request/broadcast_transactions.h" 14 | #include "cclient/request/check_consistency.h" 15 | #include "cclient/request/find_transactions.h" 16 | #include "cclient/request/get_balances.h" 17 | #include "cclient/request/get_inclusion_states.h" 18 | #include "cclient/request/get_transactions_to_approve.h" 19 | #include "cclient/request/get_trytes.h" 20 | #include "cclient/request/remove_neighbors.h" 21 | #include "cclient/request/store_transactions.h" 22 | #include "cclient/request/were_addresses_spent_from.h" 23 | 24 | #endif // CCLIENT_REQUEST_REQUESTS_H 25 | -------------------------------------------------------------------------------- /cclient/request/were_addresses_spent_from.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/request/were_addresses_spent_from.h" 11 | 12 | were_addresses_spent_from_req_t* were_addresses_spent_from_req_new() { 13 | were_addresses_spent_from_req_t* req = 14 | (were_addresses_spent_from_req_t*)malloc(sizeof(were_addresses_spent_from_req_t)); 15 | if (req) { 16 | req->addresses = NULL; 17 | } 18 | return req; 19 | } 20 | 21 | void were_addresses_spent_from_req_free(were_addresses_spent_from_req_t** const req) { 22 | if (!req || !(*req)) { 23 | return; 24 | } 25 | 26 | if ((*req)->addresses) { 27 | hash243_queue_free(&(*req)->addresses); 28 | } 29 | 30 | free(*req); 31 | *req = NULL; 32 | } 33 | -------------------------------------------------------------------------------- /cclient/response/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "responses", 3 | srcs = glob([ 4 | "*.c", 5 | ]), 6 | hdrs = glob([ 7 | "*.h", 8 | ]), 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "//common:errors", 12 | "//utils:char_buffer", 13 | "//utils/containers/hash:hash243_queue", 14 | "//utils/containers/hash:hash243_stack", 15 | "//utils/containers/hash:hash8019_queue", 16 | "//utils/containers/hash:hash_array", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /cclient/response/add_neighbors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/add_neighbors.h" 11 | 12 | add_neighbors_res_t* add_neighbors_res_new() { 13 | add_neighbors_res_t* res = (add_neighbors_res_t*)malloc(sizeof(add_neighbors_res_t)); 14 | if (res) { 15 | res->added_neighbors = 0; 16 | } 17 | return res; 18 | } 19 | 20 | void add_neighbors_res_free(add_neighbors_res_t** res) { 21 | if (!res || !(*res)) { 22 | return; 23 | } 24 | 25 | free(*res); 26 | *res = NULL; 27 | } 28 | -------------------------------------------------------------------------------- /cclient/response/add_neighbors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup response 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_RESPONSE_ADD_NEIGHBORS_H 18 | #define CCLIENT_RESPONSE_ADD_NEIGHBORS_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * @brief The data structure of add neighbors response 26 | * 27 | */ 28 | typedef struct add_neighbors_res_s { 29 | int added_neighbors; /**< Numbers of neighbors on this connected node*/ 30 | } add_neighbors_res_t; 31 | 32 | /** 33 | * @brief Allocates an add neighbors response object 34 | * 35 | * @return A pointer to the response object. 36 | */ 37 | add_neighbors_res_t* add_neighbors_res_new(); 38 | 39 | /** 40 | * @brief Frees an add neighbors response object 41 | * 42 | * @param[in] res a response object. 43 | */ 44 | void add_neighbors_res_free(add_neighbors_res_t** res); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // CCLIENT_RESPONSE_ADD_NEIGHBORS_H 51 | 52 | /** @} */ -------------------------------------------------------------------------------- /cclient/response/check_consistency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/response/check_consistency.h" 9 | 10 | check_consistency_res_t* check_consistency_res_new() { 11 | check_consistency_res_t* res = (check_consistency_res_t*)malloc(sizeof(check_consistency_res_t)); 12 | 13 | if (res) { 14 | res->info = NULL; 15 | res->state = false; 16 | } 17 | return res; 18 | } 19 | 20 | retcode_t check_consistency_res_info_set(check_consistency_res_t* res, char const* const info) { 21 | if (!res || !info) { 22 | return RC_NULL_PARAM; 23 | } 24 | 25 | if (!res->info) { 26 | res->info = char_buffer_new(); 27 | } 28 | 29 | if (!res->info) { 30 | return RC_OOM; 31 | } 32 | 33 | char_buffer_set(res->info, info); 34 | return RC_OK; 35 | } 36 | 37 | void check_consistency_res_free(check_consistency_res_t** res) { 38 | if (!res || !(*res)) { 39 | return; 40 | } 41 | 42 | if ((*res)->info) { 43 | char_buffer_free((*res)->info); 44 | } 45 | 46 | free(*res); 47 | *res = NULL; 48 | } 49 | -------------------------------------------------------------------------------- /cclient/response/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup response Responses 10 | * @brief The response objects provide read/write methods for the API responses. 11 | * 12 | * Response data structures: 13 | * - #add_neighbors_res_t 14 | * - #attach_to_tangle_res_t 15 | * - #check_consistency_res_t 16 | * - #error_res_t 17 | * - #find_transactions_res_t 18 | * - #get_balances_res_t 19 | * - #get_inclusion_states_res_t 20 | * - #get_missing_transactions_res_t 21 | * - #get_neighbors_res_t 22 | * - #get_node_info_res_t 23 | * - #get_tips_res_t 24 | * - #get_transactions_to_approve_res_t 25 | * - #get_trytes_res_t 26 | * - #remove_neighbors_res_t 27 | * 28 | */ 29 | -------------------------------------------------------------------------------- /cclient/response/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/response/error.h" 9 | 10 | error_res_t* error_res_new(char const* const error) { 11 | error_res_t* res = (error_res_t*)malloc(sizeof(error_res_t)); 12 | 13 | if (res) { 14 | res->error = char_buffer_new(); 15 | if (!res->error) { 16 | free(res); 17 | return NULL; 18 | } 19 | char_buffer_set(res->error, error); 20 | } 21 | 22 | return res; 23 | } 24 | 25 | char* error_res_get_message(error_res_t const* const res) { 26 | if (res == NULL || res->error == NULL) { 27 | return NULL; 28 | } 29 | return res->error->data; 30 | } 31 | 32 | void error_res_free(error_res_t** res) { 33 | if (!res || !(*res)) { 34 | return; 35 | } 36 | 37 | if ((*res)->error) { 38 | char_buffer_free((*res)->error); 39 | } 40 | 41 | free(*res); 42 | *res = NULL; 43 | } 44 | -------------------------------------------------------------------------------- /cclient/response/find_transactions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/find_transactions.h" 11 | 12 | find_transactions_res_t* find_transactions_res_new() { 13 | find_transactions_res_t* res = (find_transactions_res_t*)malloc(sizeof(find_transactions_res_t)); 14 | if (res) { 15 | res->hashes = NULL; 16 | } 17 | return res; 18 | } 19 | 20 | void find_transactions_res_free(find_transactions_res_t** res) { 21 | if (!res || !(*res)) { 22 | return; 23 | } 24 | 25 | if ((*res)->hashes) { 26 | hash243_queue_free(&(*res)->hashes); 27 | } 28 | free(*res); 29 | *res = NULL; 30 | } 31 | -------------------------------------------------------------------------------- /cclient/response/get_missing_transactions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/get_missing_transactions.h" 11 | 12 | get_missing_transactions_res_t* get_missing_transactions_res_new() { 13 | get_missing_transactions_res_t* res = (get_missing_transactions_res_t*)malloc(sizeof(get_missing_transactions_res_t)); 14 | if (res) { 15 | res->hashes = NULL; 16 | } 17 | return res; 18 | } 19 | 20 | size_t get_missing_transactions_res_hash_num(get_missing_transactions_res_t* res) { 21 | if (!res) { 22 | return 0; 23 | } 24 | return hash243_stack_count(res->hashes); 25 | } 26 | 27 | void get_missing_transactions_res_free(get_missing_transactions_res_t** res) { 28 | if (!res || !(*res)) { 29 | return; 30 | } 31 | 32 | if ((*res)->hashes) { 33 | hash243_stack_free(&(*res)->hashes); 34 | } 35 | free(*res); 36 | *res = NULL; 37 | } 38 | -------------------------------------------------------------------------------- /cclient/response/get_tips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/get_tips.h" 11 | 12 | get_tips_res_t* get_tips_res_new() { 13 | get_tips_res_t* res = (get_tips_res_t*)malloc(sizeof(get_tips_res_t)); 14 | if (res) { 15 | res->hashes = NULL; 16 | } 17 | return res; 18 | } 19 | 20 | size_t get_tips_res_hash_num(get_tips_res_t* res) { return hash243_stack_count(res->hashes); } 21 | 22 | void get_tips_res_free(get_tips_res_t** res) { 23 | if (!res || !(*res)) { 24 | return; 25 | } 26 | 27 | if ((*res)->hashes) { 28 | hash243_stack_free(&(*res)->hashes); 29 | } 30 | free(*res); 31 | *res = NULL; 32 | } 33 | -------------------------------------------------------------------------------- /cclient/response/get_transactions_to_approve.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/get_transactions_to_approve.h" 11 | 12 | get_transactions_to_approve_res_t* get_transactions_to_approve_res_new() { 13 | get_transactions_to_approve_res_t* res = 14 | (get_transactions_to_approve_res_t*)malloc(sizeof(get_transactions_to_approve_res_t)); 15 | if (res) { 16 | memset(res->branch, FLEX_TRIT_NULL_VALUE, FLEX_TRIT_SIZE_243); 17 | memset(res->trunk, FLEX_TRIT_NULL_VALUE, FLEX_TRIT_SIZE_243); 18 | } 19 | return res; 20 | } 21 | 22 | void get_transactions_to_approve_res_free(get_transactions_to_approve_res_t** const res) { 23 | if (!res || !(*res)) { 24 | return; 25 | } 26 | 27 | free(*res); 28 | *res = NULL; 29 | } 30 | -------------------------------------------------------------------------------- /cclient/response/get_trytes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/get_trytes.h" 11 | 12 | get_trytes_res_t* get_trytes_res_new() { 13 | get_trytes_res_t* res = (get_trytes_res_t*)malloc(sizeof(get_trytes_res_t)); 14 | if (res) { 15 | res->trytes = NULL; 16 | } 17 | return res; 18 | } 19 | 20 | void get_trytes_res_free(get_trytes_res_t** const res) { 21 | if (!res || !(*res)) { 22 | return; 23 | } 24 | 25 | get_trytes_res_t* tmp = *res; 26 | 27 | if (tmp->trytes) { 28 | hash8019_queue_free(&tmp->trytes); 29 | } 30 | free(tmp); 31 | *res = NULL; 32 | } 33 | -------------------------------------------------------------------------------- /cclient/response/remove_neighbors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "cclient/response/remove_neighbors.h" 11 | 12 | remove_neighbors_res_t* remove_neighbors_res_new() { 13 | remove_neighbors_res_t* res = (remove_neighbors_res_t*)malloc(sizeof(remove_neighbors_res_t)); 14 | if (res) { 15 | res->removed_neighbors = 0; 16 | } 17 | return res; 18 | } 19 | 20 | void remove_neighbors_res_free(remove_neighbors_res_t** res) { 21 | if (!res || !(*res)) { 22 | return; 23 | } 24 | 25 | free(*res); 26 | *res = NULL; 27 | } 28 | -------------------------------------------------------------------------------- /cclient/response/responses.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef CCLIENT_RESPONSE_RESPONSES_H 9 | #define CCLIENT_RESPONSE_RESPONSES_H 10 | 11 | #include "cclient/response/add_neighbors.h" 12 | #include "cclient/response/attach_to_tangle.h" 13 | #include "cclient/response/check_consistency.h" 14 | #include "cclient/response/error.h" 15 | #include "cclient/response/find_transactions.h" 16 | #include "cclient/response/get_balances.h" 17 | #include "cclient/response/get_inclusion_states.h" 18 | #include "cclient/response/get_missing_transactions.h" 19 | #include "cclient/response/get_neighbors.h" 20 | #include "cclient/response/get_node_api_conf.h" 21 | #include "cclient/response/get_node_info.h" 22 | #include "cclient/response/get_tips.h" 23 | #include "cclient/response/get_transactions_to_approve.h" 24 | #include "cclient/response/get_trytes.h" 25 | #include "cclient/response/remove_neighbors.h" 26 | #include "cclient/response/were_addresses_spent_from.h" 27 | 28 | #endif // CCLIENT_RESPONSE_RESPONSES_H 29 | -------------------------------------------------------------------------------- /cclient/serialization/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "serializer_json", 3 | srcs = glob([ 4 | "json/*.c", 5 | ]), 6 | hdrs = glob([ 7 | "json/*.h", 8 | ]), 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | ":serializer", 12 | "//utils:logger_helper", 13 | "//utils/containers/hash:hash243_queue", 14 | "//utils/containers/hash:hash243_stack", 15 | "//utils/containers/hash:hash8019_queue", 16 | "//utils/containers/hash:hash8019_stack", 17 | "//utils/containers/hash:hash81_queue", 18 | "//utils/containers/hash:hash_array", 19 | "@cJSON", 20 | "@com_github_uthash//:uthash", 21 | ], 22 | alwayslink = True, 23 | ) 24 | 25 | cc_library( 26 | name = "serializer", 27 | hdrs = glob([ 28 | "serializer.h", 29 | ]), 30 | visibility = ["//visibility:public"], 31 | deps = [ 32 | "//cclient/request:requests", 33 | "//cclient/response:responses", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /cclient/serialization/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup serialization Serialization 10 | * @brief The serialization implementations. 11 | * 12 | */ -------------------------------------------------------------------------------- /cclient/serialization/json/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup serialization_json JSON serializations 10 | * @ingroup serialization 11 | * @brief The JSON serialization implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /cclient/serialization/json/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | #include "cclient/serialization/json/error.h" 8 | 9 | #include "cclient/serialization/json/helpers.h" 10 | #include "cclient/serialization/json/logger.h" 11 | 12 | retcode_t json_error_serialize_response(error_res_t *const obj, char_buffer_t *out) { 13 | char const *json_text = NULL; 14 | log_debug(json_logger_id, "[%s:%d]\n", __func__, __LINE__); 15 | 16 | cJSON *json_root = cJSON_CreateObject(); 17 | if (json_root == NULL) { 18 | log_critical(json_logger_id, "[%s:%d] %s\n", __func__, __LINE__, STR_CCLIENT_JSON_CREATE); 19 | return RC_CCLIENT_JSON_CREATE; 20 | } 21 | 22 | cJSON_AddStringToObject(json_root, "error", obj->error->data); 23 | 24 | json_text = cJSON_PrintUnformatted(json_root); 25 | if (json_text) { 26 | char_buffer_set(out, json_text); 27 | cJSON_free((void *)json_text); 28 | } 29 | 30 | cJSON_Delete(json_root); 31 | return RC_OK; 32 | } 33 | -------------------------------------------------------------------------------- /cclient/serialization/json/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup serialization_json 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_SERIALIZATION_JSON_ERROR_H 18 | #define CCLIENT_SERIALIZATION_JSON_ERROR_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "common/errors.h" 25 | 26 | #include "cclient/response/error.h" 27 | #include "cclient/serialization/serializer.h" 28 | 29 | /** 30 | * @brief Converts an error response object to a JSON string. 31 | * 32 | * @param[in] obj An error response object. 33 | * @param[out] out A JSON string. 34 | * @return #retcode_t 35 | */ 36 | retcode_t json_error_serialize_response(error_res_t *const obj, char_buffer_t *out); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | 44 | /** @} */ -------------------------------------------------------------------------------- /cclient/serialization/json/json_serializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup serialization_json 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_SERIALIZATION_JSON_SERIALIZER_H 18 | #define CCLIENT_SERIALIZATION_JSON_SERIALIZER_H 19 | 20 | #include 21 | 22 | #include "cclient/serialization/serializer.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * @brief Initializes json serializer function table. 30 | * 31 | * @param serializer 32 | */ 33 | void init_json_serializer(serializer_t* serializer); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // CCLIENT_SERIALIZATION_JSON_SERIALIZER_H 40 | 41 | /** @} */ -------------------------------------------------------------------------------- /cclient/serialization/json/logger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/serialization/json/logger.h" 9 | 10 | #define JSON_LOGGER_ID "json_serializer" 11 | 12 | logger_id_t json_logger_id; 13 | 14 | void logger_init_json_serializer() { 15 | json_logger_id = logger_helper_enable(JSON_LOGGER_ID, LOGGER_DEBUG, true); 16 | log_info(json_logger_id, "[%s:%d] enable logger %s.\n", __func__, __LINE__, JSON_LOGGER_ID); 17 | } 18 | 19 | void logger_destroy_json_serializer() { 20 | log_info(json_logger_id, "[%s:%d] destroy logger %s.\n", __func__, __LINE__, JSON_LOGGER_ID); 21 | logger_helper_release(json_logger_id); 22 | } 23 | -------------------------------------------------------------------------------- /cclient/serialization/json/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @ingroup serialization_json 10 | * 11 | * @{ 12 | * 13 | * @file 14 | * @brief 15 | * 16 | */ 17 | #ifndef CCLIENT_SERIALIZATION_JSON_LOGGER_H 18 | #define CCLIENT_SERIALIZATION_JSON_LOGGER_H 19 | 20 | #include "utils/logger_helper.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | extern logger_id_t json_logger_id; 27 | 28 | /** 29 | * @brief Initializes logger of json serialization 30 | * 31 | */ 32 | void logger_init_json_serializer(); 33 | 34 | /** 35 | * @brief destroys logger of json serialization 36 | * 37 | */ 38 | void logger_destroy_json_serializer(); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif // CCLIENT_SERIALIZATION_JSON_SERIALIZER_H 45 | 46 | /** @} */ -------------------------------------------------------------------------------- /cclient/serialization/json/tests/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/serialization/json/tests/shared.h" 9 | 10 | static void test_response(void) { 11 | serializer_t serializer; 12 | char const* json = "{\"error\":\"" TEST_ERROR "\"}"; 13 | error_res_t* res = error_res_new(TEST_ERROR); 14 | char_buffer_t* serializer_out = char_buffer_new(); 15 | 16 | init_json_serializer(&serializer); 17 | 18 | serializer.vtable.error_serialize_response(res, serializer_out); 19 | TEST_ASSERT_EQUAL_STRING(json, serializer_out->data); 20 | 21 | char_buffer_free(serializer_out); 22 | error_res_free(&res); 23 | } 24 | 25 | int main(void) { 26 | UNITY_BEGIN(); 27 | 28 | RUN_TEST(test_response); 29 | 30 | return UNITY_END(); 31 | } 32 | -------------------------------------------------------------------------------- /cclient/service.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "cclient/service.h" 9 | #include "cclient/serialization/json/json_serializer.h" 10 | #include "cclient/serialization/json/logger.h" 11 | #include "utils/logger_helper.h" 12 | 13 | retcode_t iota_client_service_init(iota_client_service_t* const serv) { 14 | // init serializer 15 | if (serv->serializer_type == SR_JSON) { 16 | logger_init_json_serializer(); 17 | init_json_serializer(&serv->serializer); 18 | } else { 19 | return RC_CCLIENT_UNIMPLEMENTED; 20 | } 21 | return RC_OK; 22 | } 23 | 24 | void iota_client_service_destroy(iota_client_service_t* const serv) { 25 | // clear logger 26 | if (serv->serializer_type == SR_JSON) { 27 | logger_destroy_json_serializer(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ciri/api/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//ciri:conf.bzl", "CIRI_MAINNET_VARIABLES") 4 | load("//ciri:conf.bzl", "CIRI_TESTNET_VARIABLES") 5 | 6 | cc_library( 7 | name = "api", 8 | srcs = ["api.c"], 9 | hdrs = ["api.h"], 10 | defines = select({ 11 | "//ciri:mainnet": CIRI_MAINNET_VARIABLES, 12 | "//ciri:testnet": CIRI_TESTNET_VARIABLES, 13 | "//conditions:default": CIRI_MAINNET_VARIABLES, 14 | }), 15 | deps = [ 16 | ":conf", 17 | ":feature", 18 | "//cclient/request:requests", 19 | "//cclient/response:responses", 20 | "//ciri:core", 21 | "//common:errors", 22 | "//common/helpers:pow", 23 | "//utils:logger_helper", 24 | ], 25 | ) 26 | 27 | cc_library( 28 | name = "conf", 29 | srcs = ["conf.c"], 30 | hdrs = ["conf.h"], 31 | deps = [ 32 | "//ciri/utils:files", 33 | "//common:errors", 34 | ], 35 | ) 36 | 37 | cc_library( 38 | name = "feature", 39 | srcs = ["feature.c"], 40 | hdrs = ["feature.h"], 41 | deps = ["@com_github_uthash//:uthash"], 42 | ) 43 | -------------------------------------------------------------------------------- /ciri/api/conf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "ciri/api/conf.h" 12 | 13 | retcode_t iota_api_conf_init(iota_api_conf_t* const conf) { 14 | if (conf == NULL) { 15 | return RC_NULL_PARAM; 16 | } 17 | 18 | conf->http_port = DEFAULT_API_HTTP_PORT; 19 | conf->max_find_transactions = DEFAULT_MAX_FIND_TRANSACTIONS; 20 | conf->max_get_trytes = DEFAULT_MAX_GET_TRYTES; 21 | memset(conf->remote_limit_api, 0, sizeof(conf->remote_limit_api)); 22 | 23 | return RC_OK; 24 | } 25 | 26 | retcode_t iota_api_conf_destroy(iota_api_conf_t* const conf) { 27 | if (conf == NULL) { 28 | return RC_NULL_PARAM; 29 | } 30 | 31 | for (size_t i = 0; conf->remote_limit_api[i]; i++) { 32 | free(conf->remote_limit_api[i]); 33 | } 34 | 35 | return RC_OK; 36 | } 37 | -------------------------------------------------------------------------------- /ciri/api/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup ciri_api cIRI API 10 | * @brief The IOTA API implementation 11 | */ 12 | -------------------------------------------------------------------------------- /ciri/api/feature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "ciri/api/feature.h" 9 | 10 | char const* const node_features_name[NODE_FEATURES_NUM] = {"snapshotPruning", "dnsRefresher", "testnet", 11 | "zeroMessageQueue", "tipSolidification", "RemotePOW"}; 12 | 13 | void node_features_set(uint8_t const features, UT_array* const feature_array) { 14 | node_feature_t elt = (1u << 0); 15 | 16 | for (int i = 0; i < NODE_FEATURES_NUM; i++) { 17 | if (features & elt) { 18 | utarray_push_back(feature_array, &node_features_name[i]); 19 | } 20 | elt <<= 1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ciri/api/http/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "http", 5 | srcs = ["http.c"], 6 | hdrs = ["http.h"], 7 | deps = [ 8 | "//cclient/request:requests", 9 | "//cclient/response:responses", 10 | "//cclient/serialization:serializer", 11 | "//cclient/serialization:serializer_json", 12 | "//ciri/api", 13 | "//ciri/storage:storage_common", 14 | "//common:errors", 15 | "//utils:logger_helper", 16 | "//utils/handles:thread", 17 | "@cJSON", 18 | "@libmicrohttpd", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /ciri/conf.bzl: -------------------------------------------------------------------------------- 1 | CIRI_VERSION = ["CIRI_VERSION='\"0.1.0-alpha\"'"] 2 | 3 | CIRI_MAINNET_VARIABLES = [ 4 | "TANGLE_DB_PATH='\"ciri/db/tangle-mainnet.db\"'", 5 | "SPENT_ADDRESSES_DB_PATH='\"ciri/db/spent-addresses-mainnet.db\"'", 6 | "CIRI_NAME='\"cIRI-mainnet\"'", 7 | ] + CIRI_VERSION 8 | 9 | CIRI_TESTNET_VARIABLES = [ 10 | "TANGLE_DB_PATH='\"ciri/db/tangle-testnet.db\"'", 11 | "SPENT_ADDRESSES_DB_PATH='\"ciri/db/spent-addresses-testnet.db\"'", 12 | "CIRI_NAME='\"cIRI-testnet\"'", 13 | ] + CIRI_VERSION 14 | -------------------------------------------------------------------------------- /ciri/consensus/bundle_validator/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "bundle_validator", 3 | srcs = glob(["*.c"]), 4 | hdrs = glob(["*.h"]), 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:conf", 8 | "//ciri/consensus/tangle", 9 | "//common/crypto/iss:normalize", 10 | "//common/model:bundle", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /ciri/consensus/bundle_validator/bundle_validator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CONSENSUS_BUNDLE_VALIDATOR_BUNDLE_VALIDATOR_H__ 9 | #define __CONSENSUS_BUNDLE_VALIDATOR_BUNDLE_VALIDATOR_H__ 10 | 11 | #include "ciri/consensus/tangle/tangle.h" 12 | #include "common/errors.h" 13 | #include "common/model/bundle.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | retcode_t iota_consensus_bundle_validator_init(); 20 | retcode_t iota_consensus_bundle_validator_destroy(); 21 | retcode_t iota_consensus_bundle_validator_validate(tangle_t const* const tangle, flex_trit_t const* const tail_hash, 22 | bundle_transactions_t* const bundle, bundle_status_t* const status); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // __CONSENSUS_BUNDLE_VALIDATOR_BUNDLE_VALIDATOR_H__ 29 | -------------------------------------------------------------------------------- /ciri/consensus/bundle_validator/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "bundle_validator", 3 | timeout = "moderate", 4 | srcs = ["bundle_validator.c"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus/bundle_validator", 8 | "//ciri/consensus/test_utils", 9 | "//ciri/storage/tests:defs", 10 | "@unity", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /ciri/consensus/conf.bzl: -------------------------------------------------------------------------------- 1 | CONSENSUS_MAINNET_VARIABLES = [ 2 | "IOTA_MAINNET=1", 3 | "SNAPSHOT_CONF_FILE='\"external/snapshot_conf_mainnet/file/downloaded\"'", 4 | "SNAPSHOT_SIG_FILE='\"external/snapshot_sig_mainnet/file/downloaded\"'", 5 | "SNAPSHOT_FILE='\"external/snapshot_mainnet/file/downloaded\"'", 6 | "COORDINATOR_ADDRESS='\"EQSAUZXULTTYZCLNJNTXQTQHOMOFZERHTCGTXOLTVAHKSA9OGAZDEKECURBRIXIJWNPFCQIOVFVVXJVD9\"'", 7 | "COORDINATOR_DEPTH=23", 8 | "MWM=14", 9 | ] 10 | 11 | CONSENSUS_TESTNET_VARIABLES = [ 12 | "IOTA_TESTNET=1", 13 | "SNAPSHOT_CONF_FILE='\"external/snapshot_conf_testnet/file/downloaded\"'", 14 | "SNAPSHOT_SIG_FILE='\"\"'", 15 | "SNAPSHOT_FILE='\"external/snapshot_testnet/file/downloaded\"'", 16 | "COORDINATOR_ADDRESS='\"EQQFCZBIHRHWPXKMTOLMYUYPCN9XLMJPYZVFJSAY9FQHCCLWTOLLUGKKMXYFDBOOYFBLBI9WUEILGECYM\"'", 17 | "COORDINATOR_DEPTH=22", 18 | "MWM=9", 19 | ] 20 | -------------------------------------------------------------------------------- /ciri/consensus/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup consensus Consensus 10 | * @brief The consensus mechanism implementations. 11 | * 12 | * TODO 13 | */ -------------------------------------------------------------------------------- /ciri/consensus/ledger_validator/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "ledger_validator_shared", 3 | hdrs = ["ledger_validator.h"], 4 | visibility = ["//visibility:public"], 5 | deps = [ 6 | "//ciri/consensus/snapshot", 7 | "//common:errors", 8 | "//utils:hash_maps", 9 | ], 10 | ) 11 | 12 | cc_library( 13 | name = "ledger_validator", 14 | srcs = ["ledger_validator.c"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | ":ledger_validator_shared", 18 | "//ciri/consensus/bundle_validator", 19 | "//ciri/consensus/milestone:milestone_tracker_shared", 20 | "//ciri/consensus/snapshot", 21 | "//ciri/consensus/snapshot:snapshots_provider", 22 | "//ciri/consensus/tangle", 23 | "//ciri/consensus/tangle:traversal", 24 | "//utils:hash_maps", 25 | "//utils/containers/hash:hash243_stack", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /ciri/consensus/ledger_validator/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_ledger_validator", 3 | timeout = "long", 4 | srcs = [ 5 | "test_ledger_validator.c", 6 | ], 7 | data = [ 8 | ":snapshot.txt", 9 | "//ciri/consensus/snapshot/tests:snapshot_test_files", 10 | ], 11 | flaky = True, 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//ciri/consensus/ledger_validator", 15 | "//ciri/consensus/milestone:milestone_service", 16 | "//ciri/consensus/milestone:milestone_tracker", 17 | "//ciri/consensus/snapshot:snapshots_provider", 18 | "//ciri/consensus/snapshot:snapshots_service", 19 | "//ciri/consensus/test_utils", 20 | "//ciri/consensus/transaction_solidifier", 21 | "//ciri/storage", 22 | "//ciri/storage/tests:defs", 23 | "//common/helpers:digest", 24 | "//common/trinary:trit_ptrit", 25 | "//utils/containers/hash:hash_uint64_t_map", 26 | "@unity", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /ciri/consensus/ledger_validator/tests/snapshot.txt: -------------------------------------------------------------------------------- 1 | DVPBUDRCLOWZRTIIMRNCACLGOLOOHDFNRRLPMPCEQDNLTYOLMRFCLQVYDWIYKNITUGCLGMMWNAQIBZTHZ;2779530283277761 2 | -------------------------------------------------------------------------------- /ciri/consensus/milestone/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_milestone_tracker", 3 | timeout = "moderate", 4 | srcs = ["test_milestone_tracker.c"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus/milestone:milestone_tracker", 8 | "//ciri/consensus/snapshot:snapshots_provider", 9 | "//ciri/consensus/test_utils", 10 | "@unity", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /ciri/consensus/model.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CONSENSUS_MODEL_H__ 9 | #define __CONSENSUS_MODEL_H__ 10 | 11 | #include 12 | #include 13 | 14 | #include "common/errors.h" 15 | #include "common/trinary/flex_trit.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef struct tips_pair { 22 | flex_trit_t trunk[FLEX_TRIT_SIZE_243]; 23 | flex_trit_t branch[FLEX_TRIT_SIZE_243]; 24 | } tips_pair_t; 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // __CONSENSUS_MODEL_H__ 31 | -------------------------------------------------------------------------------- /ciri/consensus/snapshot/local_snapshots/conf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "ciri/consensus/snapshot/local_snapshots/conf.h" 11 | #include "utils/logger_helper.h" 12 | 13 | #define LOCAL_SNAPSHOT_TRANSACTIONS_GROWTH_THRESHOLD 1000 14 | #define LOCAL_SNAPSHOT_MIN_DEPTH 100 15 | #define LOCAL_SNAPSHOTS_BASE_DIR "local_snapshot" 16 | 17 | retcode_t iota_consensus_local_snapshots_conf_init(iota_consensus_local_snapshots_conf_t* const conf) { 18 | retcode_t ret = RC_OK; 19 | 20 | if (conf == NULL) { 21 | return RC_NULL_PARAM; 22 | } 23 | 24 | conf->local_snapshots_is_enabled = false; 25 | conf->pruning_is_enabled = false; 26 | conf->transactions_growth_threshold = LOCAL_SNAPSHOT_TRANSACTIONS_GROWTH_THRESHOLD; 27 | strcpy(conf->base_dir, LOCAL_SNAPSHOTS_BASE_DIR); 28 | conf->min_depth = LOCAL_SNAPSHOT_MIN_DEPTH; 29 | 30 | return ret; 31 | } 32 | -------------------------------------------------------------------------------- /ciri/consensus/snapshot/tests/snapshot_badly_formatted.txt: -------------------------------------------------------------------------------- 1 | A99999999999999999999999999999999999999999999999999999999999999999999999999999999:100000 2 | B99999999999999999999999999999999999999999999999999999999999999999999999999999999:100000 3 | -------------------------------------------------------------------------------- /ciri/consensus/snapshot/tests/snapshot_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "coordinator": { 3 | "depth": 20, 4 | "lastMilestone": 774804, 5 | "pubkey": "KPWCHICGJZXKE9GSUDXZYUAPLHAKAHYHDXNPHENTERYMMBQOPSQIDENXKLKCEYCPVTZQLEEJVYJZV9BWU", 6 | "securityLevel": 1, 7 | "signatureType": "CURL_P27" 8 | }, 9 | "signature": { 10 | "depth": 6, 11 | "index": 9, 12 | "pubkey": "TTXJUGKTNPOOEXSTQVVACENJOQUROXYKDRCVK9LHUXILCLABLGJTIPNF9REWHOIMEUKWQLUOKD9CZUYAC" 13 | }, 14 | "timestamp": 1537203600 15 | } 16 | -------------------------------------------------------------------------------- /ciri/consensus/snapshot/tests/snapshot_inconsistent.txt: -------------------------------------------------------------------------------- 1 | A99999999999999999999999999999999999999999999999999999999999999999999999999999999;100000 2 | B99999999999999999999999999999999999999999999999999999999999999999999999999999999;-100000 3 | C99999999999999999999999999999999999999999999999999999999999999999999999999999999;100000 4 | -------------------------------------------------------------------------------- /ciri/consensus/snapshot/tests/snapshot_invalid_supply.txt: -------------------------------------------------------------------------------- 1 | A99999999999999999999999999999999999999999999999999999999999999999999999999999999;100000 2 | B99999999999999999999999999999999999999999999999999999999999999999999999999999999;100000 3 | C99999999999999999999999999999999999999999999999999999999999999999999999999999999;100000 4 | -------------------------------------------------------------------------------- /ciri/consensus/spent_addresses/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "spent_addresses_provider", 3 | srcs = ["spent_addresses_provider.c"], 4 | hdrs = ["spent_addresses_provider.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/storage", 8 | "//common:errors", 9 | "//utils:logger_helper", 10 | ], 11 | ) 12 | 13 | cc_library( 14 | name = "spent_addresses_service", 15 | srcs = ["spent_addresses_service.c"], 16 | hdrs = ["spent_addresses_service.h"], 17 | visibility = ["//visibility:public"], 18 | deps = [ 19 | ":spent_addresses_provider", 20 | "//ciri/consensus:conf", 21 | "//ciri/consensus/bundle_validator", 22 | "//ciri/consensus/tangle", 23 | "//common:errors", 24 | "//utils:logger_helper", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /ciri/consensus/spent_addresses/tests/BUILD: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "spent_addresses_test_file", 3 | srcs = ["spent_addresses_test.txt"], 4 | visibility = ["//visibility:public"], 5 | ) 6 | 7 | cc_test( 8 | name = "test_spent_addresses_provider", 9 | srcs = ["test_spent_addresses_provider.c"], 10 | data = [ 11 | ":spent_addresses_test_file", 12 | ], 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | "//ciri/consensus/spent_addresses:spent_addresses_provider", 16 | "//ciri/consensus/test_utils", 17 | "//ciri/utils:files", 18 | "@unity", 19 | ], 20 | ) 21 | 22 | cc_test( 23 | name = "test_spent_addresses_service", 24 | srcs = ["test_spent_addresses_service.c"], 25 | visibility = ["//visibility:public"], 26 | deps = [ 27 | "//ciri/consensus/spent_addresses:spent_addresses_service", 28 | "//ciri/consensus/test_utils", 29 | "//ciri/utils:files", 30 | "@unity", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /ciri/consensus/spent_addresses/tests/spent_addresses_test.txt: -------------------------------------------------------------------------------- 1 | B99999999999999999999999999999999999999999999999999999999999999999999999999999999 2 | D99999999999999999999999999999999999999999999999999999999999999999999999999999999 3 | F99999999999999999999999999999999999999999999999999999999999999999999999999999999 4 | H99999999999999999999999999999999999999999999999999999999999999999999999999999999 5 | J99999999999999999999999999999999999999999999999999999999999999999999999999999999 6 | L99999999999999999999999999999999999999999999999999999999999999999999999999999999 7 | N99999999999999999999999999999999999999999999999999999999999999999999999999999999 8 | P99999999999999999999999999999999999999999999999999999999999999999999999999999999 9 | R99999999999999999999999999999999999999999999999999999999999999999999999999999999 10 | T99999999999999999999999999999999999999999999999999999999999999999999999999999999 11 | V99999999999999999999999999999999999999999999999999999999999999999999999999999999 12 | X99999999999999999999999999999999999999999999999999999999999999999999999999999999 13 | Z99999999999999999999999999999999999999999999999999999999999999999999999999999999 14 | -------------------------------------------------------------------------------- /ciri/consensus/tangle/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "tangle", 3 | srcs = ["tangle.c"], 4 | hdrs = ["tangle.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus/snapshot:state_delta", 8 | "//ciri/storage", 9 | "//common:errors", 10 | "//common/model:bundle", 11 | "//common/model:transaction", 12 | "//utils:logger_helper", 13 | "//utils/containers/hash:hash243_queue", 14 | "//utils/containers/hash:hash243_set", 15 | "//utils/containers/hash:hash81_queue", 16 | "@com_github_uthash//:uthash", 17 | ], 18 | ) 19 | 20 | cc_library( 21 | name = "traversal", 22 | srcs = ["traversal.c"], 23 | hdrs = ["traversal.h"], 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//ciri/consensus/tangle", 27 | "//ciri/storage:pack", 28 | "//common/model:transaction", 29 | "//utils/containers/hash:hash243_set", 30 | "//utils/containers/hash:hash243_stack", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /ciri/consensus/tangle/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_tangle", 3 | timeout = "moderate", 4 | srcs = ["test_tangle.c"], 5 | deps = [ 6 | "//ciri/consensus/tangle", 7 | "//ciri/consensus/test_utils", 8 | "@unity", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /ciri/consensus/test_utils/spent_addresses.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "ciri/consensus/test_utils/spent_addresses.h" 11 | #include "ciri/storage/test_utils.h" 12 | #include "ciri/utils/files.h" 13 | 14 | retcode_t spent_addresses_setup(spent_addresses_provider_t *const sap, storage_connection_config_t *const config, 15 | char *test_db_path) { 16 | return storage_test_setup(&sap->connection, config, test_db_path, STORAGE_CONNECTION_SPENT_ADDRESSES); 17 | } 18 | 19 | retcode_t spent_addresses_cleanup(spent_addresses_provider_t *const sap, char *test_db_path) { 20 | return storage_test_teardown(&sap->connection, test_db_path, STORAGE_CONNECTION_SPENT_ADDRESSES); 21 | } 22 | -------------------------------------------------------------------------------- /ciri/consensus/test_utils/spent_addresses.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_CONSENSUS_TEST_UTILS_SPENT_ADDRESSES_H__ 9 | #define __CIRI_CONSENSUS_TEST_UTILS_SPENT_ADDRESSES_H__ 10 | 11 | #include "ciri/consensus/spent_addresses/spent_addresses_provider.h" 12 | #include "ciri/storage/connection.h" 13 | #include "common/errors.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | retcode_t spent_addresses_setup(spent_addresses_provider_t *const sap, storage_connection_config_t *const config, 20 | char *test_db_path); 21 | 22 | retcode_t spent_addresses_cleanup(spent_addresses_provider_t *const sap, char *test_db_path); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif //__CIRI_CONSENSUS_TEST_UTILS_SPENT_ADDRESSES_H__ 29 | -------------------------------------------------------------------------------- /ciri/consensus/test_utils/tangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CONSENSUS_TEST_UTILS_TANGLE_H__ 9 | #define __CONSENSUS_TEST_UTILS_TANGLE_H__ 10 | 11 | #include "ciri/consensus/tangle/tangle.h" 12 | #include "ciri/storage/connection.h" 13 | #include "common/errors.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | retcode_t tangle_setup(tangle_t *const tangle, storage_connection_config_t *const config, char *test_db_path); 20 | 21 | retcode_t tangle_cleanup(tangle_t *const tangle, char *test_db_path); 22 | 23 | void transactions_deserialize(tryte_t const *const *const transactions_trytes, iota_transaction_t **txs, 24 | size_t num_transactions, bool compute_hash); 25 | 26 | retcode_t build_tangle(tangle_t *const tangle, iota_transaction_t **txs, size_t num_transactions); 27 | 28 | void transactions_free(iota_transaction_t **txs, size_t num_transactions); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif //__CONSENSUS_TEST_UTILS_TANGLE_H__ 35 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "tip_selector", 3 | srcs = ["tip_selector.c"], 4 | hdrs = ["tip_selector.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:model", 8 | "//ciri/consensus/ledger_validator", 9 | "//ciri/consensus/milestone:milestone_tracker", 10 | "//ciri/consensus/tangle", 11 | "//ciri/consensus/tip_selection/cw_rating_calculator", 12 | "//ciri/consensus/tip_selection/entry_point_selector", 13 | "//ciri/consensus/tip_selection/exit_probability_randomizer", 14 | "//ciri/consensus/tip_selection/exit_probability_validator", 15 | "//common:errors", 16 | "//utils:logger_helper", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/cw_rating_calculator/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "cw_rating_calculator", 3 | srcs = glob(["*.c"]), 4 | hdrs = glob(["*.h"]), 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:model", 8 | "//ciri/consensus/tangle", 9 | "//common:errors", 10 | "//utils:hash_maps", 11 | "//utils:logger_helper", 12 | "//utils/containers:bitset", 13 | "//utils/containers/hash:hash243_stack", 14 | "//utils/containers/hash:hash_int64_t_map", 15 | "@com_github_uthash//:uthash", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/entry_point_selector/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "entry_point_selector", 3 | srcs = ["entry_point_selector.c"], 4 | hdrs = ["entry_point_selector.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus/milestone:milestone_tracker", 8 | "//common:errors", 9 | "//utils:macros", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/entry_point_selector/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_entry_point_selector", 3 | timeout = "moderate", 4 | srcs = ["test_entry_point_selector.c"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus/test_utils", 8 | "//ciri/consensus/tip_selection/entry_point_selector", 9 | "//ciri/utils:files", 10 | "//common/helpers:digest", 11 | "//common/model/tests:defs", 12 | "@unity", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/exit_probability_randomizer/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_exit_probability_randomizer", 3 | timeout = "moderate", 4 | srcs = ["test_exit_probability_randomizer.c"], 5 | data = [ 6 | ":snapshot.txt", 7 | "//ciri/consensus/snapshot/tests:snapshot_test_files", 8 | ], 9 | flaky = True, 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//ciri/consensus/test_utils", 13 | "//ciri/consensus/tip_selection/cw_rating_calculator", 14 | "//ciri/consensus/tip_selection/exit_probability_randomizer", 15 | "//ciri/storage", 16 | "//ciri/storage/tests:defs", 17 | "//common/trinary:trit_ptrit", 18 | "@unity", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/exit_probability_validator/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "exit_probability_validator", 3 | srcs = ["exit_probability_validator.c"], 4 | hdrs = ["exit_probability_validator.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:model", 8 | "//ciri/consensus/ledger_validator", 9 | "//ciri/consensus/tangle", 10 | "//ciri/consensus/tip_selection/entry_point_selector", 11 | "//ciri/consensus/transaction_solidifier", 12 | "//common:errors", 13 | "//utils:hash_maps", 14 | "//utils:logger_helper", 15 | "@com_github_uthash//:uthash", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /ciri/consensus/tip_selection/exit_probability_validator/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_exit_probability_validator", 3 | timeout = "moderate", 4 | srcs = ["exit_probability_validator.c"], 5 | data = [ 6 | ":snapshot.txt", 7 | "//ciri/consensus/snapshot/tests:snapshot_test_files", 8 | ], 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "//ciri/consensus/test_utils", 12 | "//ciri/consensus/tip_selection/exit_probability_validator", 13 | "//ciri/storage/tests:defs", 14 | "//common/trinary:trit_ptrit", 15 | "@unity", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /ciri/consensus/transaction_solidifier/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "transaction_solidifier", 3 | srcs = ["transaction_solidifier.c"], 4 | hdrs = ["transaction_solidifier.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:conf", 8 | "//ciri/consensus/snapshot:snapshots_provider", 9 | "//ciri/consensus/tangle", 10 | "//ciri/consensus/tangle:traversal", 11 | "//ciri/node:tips_cache", 12 | "//ciri/node/pipeline:transaction_requester", 13 | "//common:errors", 14 | "//common/model:transaction", 15 | "//utils:logger_helper", 16 | "//utils/containers/hash:hash243_set", 17 | "//utils/handles:cond", 18 | "//utils/handles:lock", 19 | "//utils/handles:thread", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /ciri/consensus/transaction_validator/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "transaction_validator", 3 | srcs = ["transaction_validator.c"], 4 | hdrs = ["transaction_validator.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//ciri/consensus:conf", 8 | "//ciri/consensus/snapshot:snapshots_provider", 9 | "//ciri/node/pipeline:transaction_requester_shared", 10 | "//common:errors", 11 | "//common/model:transaction", 12 | "//utils:logger_helper", 13 | "//utils:time", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /ciri/consensus/transaction_validator/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_transaction_validator", 3 | timeout = "moderate", 4 | srcs = [ 5 | "test_transaction_validator.c", 6 | ], 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "//ciri/consensus/test_utils", 10 | "//ciri/consensus/transaction_validator", 11 | "//ciri/node", 12 | "@unity", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /ciri/db/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/ciri/db/.gitkeep -------------------------------------------------------------------------------- /ciri/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup ciri cIRI 10 | * @brief IOTA Reference Implementation in C language. 11 | * 12 | * TODO 13 | */ 14 | -------------------------------------------------------------------------------- /ciri/node/conf.bzl: -------------------------------------------------------------------------------- 1 | NODE_MAINNET_VARIABLES = [ 2 | "MWM=14", 3 | "COORDINATOR_ADDRESS='\"EQSAUZXULTTYZCLNJNTXQTQHOMOFZERHTCGTXOLTVAHKSA9OGAZDEKECURBRIXIJWNPFCQIOVFVVXJVD9\"'", 4 | ] 5 | 6 | NODE_TESTNET_VARIABLES = [ 7 | "MWM=9", 8 | "COORDINATOR_ADDRESS='\"EQQFCZBIHRHWPXKMTOLMYUYPCN9XLMJPYZVFJSAY9FQHCCLWTOLLUGKKMXYFDBOOYFBLBI9WUEILGECYM\"'", 9 | ] 10 | -------------------------------------------------------------------------------- /ciri/node/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup node Node 10 | * @brief The node implementation. 11 | * 12 | * TODO 13 | */ 14 | -------------------------------------------------------------------------------- /ciri/node/network/endpoint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "ciri/node/network/endpoint.h" 11 | 12 | int endpoint_cmp(endpoint_t const *const lhs, endpoint_t const *const rhs) { 13 | int ip_cmp = 0; 14 | 15 | if (lhs == NULL || rhs == NULL) { 16 | return -1; 17 | } 18 | 19 | if (lhs->port != rhs->port) { 20 | return lhs->port - rhs->port; 21 | } 22 | 23 | if ((ip_cmp = strcmp(lhs->ip, rhs->ip)) == 0 || strcmp(lhs->domain, rhs->domain) == 0) { 24 | return 0; 25 | } 26 | 27 | return ip_cmp; 28 | } 29 | -------------------------------------------------------------------------------- /ciri/node/network/endpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_NODE_NETWORK_ENDPOINT_H__ 9 | #define __CIRI_NODE_NETWORK_ENDPOINT_H__ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "ciri/node/network/network.h" 17 | 18 | typedef struct endpoint_s { 19 | char domain[MAX_HOST_LENGTH]; 20 | char ip[INET6_ADDRSTRLEN]; 21 | uint16_t port; 22 | void *stream; 23 | } endpoint_t; 24 | 25 | int endpoint_cmp(endpoint_t const *const lhs, endpoint_t const *const rhs); 26 | 27 | #endif // __CIRI_NODE_NETWORK_ENDPOINT_H__ 28 | -------------------------------------------------------------------------------- /ciri/node/network/network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_NODE_NETWORK_NETWORK_H__ 9 | #define __CIRI_NODE_NETWORK_NETWORK_H__ 10 | 11 | #define MAX_SCHEME_LENGTH 8 12 | #define MAX_HOST_LENGTH 255 13 | #define MAX_PORT_LENGTH 5 14 | 15 | #endif // __CIRI_NODE_NETWORK_NETWORK_H__ 16 | -------------------------------------------------------------------------------- /ciri/node/protocol/header.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_NODE_PROTOCOL_HEADER_H__ 9 | #define __CIRI_NODE_PROTOCOL_HEADER_H__ 10 | 11 | // The amount of bytes dedicated for the message type in the packet header 12 | #define HEADER_TYPE_BYTES_LENGTH 1 13 | // The amount of bytes dedicated for the message length denotation in the packet header 14 | #define HEADER_LENGTH_BYTES_LENGTH 2 15 | // The amount of bytes making up the packet header 16 | #define HEADER_BYTES_LENGTH ((HEADER_TYPE_BYTES_LENGTH) + (HEADER_LENGTH_BYTES_LENGTH)) 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * The message header sent in each message denoting the TLV fields 24 | */ 25 | typedef struct __attribute__((__packed__)) protocol_header_s { 26 | uint8_t type; 27 | uint16_t length; 28 | } protocol_header_t; 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // __CIRI_NODE_PROTOCOL_HEADER_H__ 35 | -------------------------------------------------------------------------------- /ciri/node/protocol/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_NODE_PROTOCOL_PROTOCOL_H__ 9 | #define __CIRI_NODE_PROTOCOL_PROTOCOL_H__ 10 | 11 | #include "ciri/node/protocol/gossip.h" 12 | #include "ciri/node/protocol/handshake.h" 13 | #include "ciri/node/protocol/header.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define PACKET_TYPES_NUM 3 20 | #define PACKET_MAX_BYTES_LENGTH ((HEADER_BYTES_LENGTH) + (GOSSIP_MAX_BYTES_LENGTH)) 21 | 22 | typedef enum protocol_packet_type_e { 23 | PROTOCOL_HEADER = 0, 24 | PROTOCOL_HANDSHAKE = 1, 25 | PROTOCOL_GOSSIP = 2 26 | } protocol_packet_type_t; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif // __CIRI_NODE_PROTOCOL_PROTOCOL_H__ 33 | -------------------------------------------------------------------------------- /ciri/node/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_tips_cache", 3 | timeout = "short", 4 | srcs = ["test_tips_cache.c"], 5 | deps = [ 6 | "//ciri/node:tips_cache", 7 | "@unity", 8 | ], 9 | ) 10 | 11 | cc_test( 12 | name = "test_recent_seen_bytes_cache", 13 | timeout = "short", 14 | srcs = ["test_recent_seen_bytes_cache.c"], 15 | deps = [ 16 | "//ciri/consensus/test_utils", 17 | "//ciri/node:recent_seen_bytes_cache", 18 | "@unity", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /ciri/storage/sql/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "statements", 3 | srcs = ["statements.c"], 4 | hdrs = glob(["*.h"]), 5 | visibility = ["//visibility:public"], 6 | deps = ["//ciri/storage:storage_common"], 7 | ) 8 | -------------------------------------------------------------------------------- /ciri/storage/sql/mariadb/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "storage_mariadb", 3 | srcs = [ 4 | "connection.c", 5 | "storage.c", 6 | "wrappers.c", 7 | ], 8 | hdrs = [ 9 | "connection.h", 10 | "wrappers.h", 11 | ], 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//ciri/storage/sql:statements", 15 | "//common/model:milestone", 16 | "//common/model:transaction", 17 | "//utils:logger_helper", 18 | "//utils:time", 19 | "@mariadb", 20 | ], 21 | ) 22 | 23 | filegroup( 24 | name = "tangle-schema", 25 | srcs = ["tangle-schema.sql"], 26 | visibility = ["//visibility:public"], 27 | ) 28 | 29 | filegroup( 30 | name = "spent-addresses-schema", 31 | srcs = ["spent-addresses-schema.sql"], 32 | visibility = ["//visibility:public"], 33 | ) 34 | 35 | cc_library( 36 | name = "test_utils_mariadb", 37 | srcs = ["test_utils.c"], 38 | visibility = ["//visibility:public"], 39 | deps = [ 40 | ":storage_mariadb", 41 | "//ciri/storage:test_utils_hdr", 42 | ], 43 | ) 44 | -------------------------------------------------------------------------------- /ciri/storage/sql/mariadb/connection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_STORAGE_SQL_MARIADB_CONNECTION_H__ 9 | #define __CIRI_STORAGE_SQL_MARIADB_CONNECTION_H__ 10 | 11 | #include 12 | 13 | #include "ciri/storage/connection.h" 14 | #include "ciri/storage/sql/statements.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef struct mariadb_tangle_connection_s { 21 | MYSQL db; 22 | tangle_statements_t statements; 23 | } mariadb_tangle_connection_t; 24 | 25 | typedef struct mariadb_spent_addresses_connection_s { 26 | MYSQL db; 27 | spent_addresses_statements_t statements; 28 | } mariadb_spent_addresses_connection_t; 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // __CIRI_STORAGE_SQL_MARIADB_CONNECTION_H__ 35 | -------------------------------------------------------------------------------- /ciri/storage/sql/mariadb/setup.sql: -------------------------------------------------------------------------------- 1 | CREATE USER 'ciri'@'localhost' IDENTIFIED BY ''; 2 | CREATE DATABASE `tangle` CHARACTER SET utf8; 3 | GRANT ALL PRIVILEGES ON `tangle` . * TO 'ciri'@'localhost'; 4 | CREATE DATABASE `spent-addresses` CHARACTER SET utf8; 5 | GRANT ALL PRIVILEGES ON `spent-addresses` . * TO 'ciri'@'localhost'; 6 | FLUSH PRIVILEGES; 7 | -------------------------------------------------------------------------------- /ciri/storage/sql/mariadb/spent-addresses-schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS iota_spent_address ( 2 | hash BLOB NOT NULL, 3 | PRIMARY KEY (hash(243)) 4 | ); 5 | 6 | CREATE UNIQUE INDEX IF NOT EXISTS spent_address_hash_index ON iota_spent_address(hash(243)); 7 | -------------------------------------------------------------------------------- /ciri/storage/sql/sqlite3/connection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_STORAGE_SQL_SQLITE3_CONNECTION_H__ 9 | #define __CIRI_STORAGE_SQL_SQLITE3_CONNECTION_H__ 10 | 11 | #include 12 | 13 | #include "ciri/storage/connection.h" 14 | #include "ciri/storage/sql/statements.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef struct sqlite3_tangle_connection_s { 21 | sqlite3* db; 22 | tangle_statements_t statements; 23 | } sqlite3_tangle_connection_t; 24 | 25 | typedef struct sqlite3_spent_addresses_connection_s { 26 | sqlite3* db; 27 | spent_addresses_statements_t statements; 28 | } sqlite3_spent_addresses_connection_t; 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // __CIRI_STORAGE_SQL_SQLITE3_CONNECTION_H__ 35 | -------------------------------------------------------------------------------- /ciri/storage/sql/sqlite3/spent-addresses-schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS iota_spent_address ( 2 | hash BLOB NOT NULL PRIMARY KEY ON CONFLICT IGNORE 3 | ); 4 | 5 | CREATE INDEX IF NOT EXISTS spent_address_hash_index ON iota_spent_address(hash); 6 | -------------------------------------------------------------------------------- /ciri/storage/test_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_STORAGE_TEST_UTILS_H__ 9 | #define __CIRI_STORAGE_TEST_UTILS_H__ 10 | 11 | #include "ciri/storage/connection.h" 12 | #include "common/errors.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | retcode_t storage_test_setup(storage_connection_t* const connection, storage_connection_config_t const* const config, 19 | char const* const test_db_path, storage_connection_type_t const type); 20 | retcode_t storage_test_teardown(storage_connection_t* const connection, char const* const test_db_path, 21 | storage_connection_type_t const type); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif // __CIRI_STORAGE_TEST_UTILS_H__ 28 | -------------------------------------------------------------------------------- /ciri/usage.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "ciri/usage.h" 11 | 12 | void iota_usage() { 13 | int i = 0; 14 | 15 | fprintf(stderr, "cIRI usage:\n"); 16 | while (cli_arguments_g[i].desc) { 17 | fprintf(stderr, "--%-46s ", cli_arguments_g[i].name); 18 | if (cli_arguments_g[i].val < CONF_START) { 19 | fprintf(stderr, "(-%c)", cli_arguments_g[i].val); 20 | } else { 21 | fprintf(stderr, " "); 22 | } 23 | fprintf(stderr, " %s", cli_arguments_g[i].desc); 24 | fprintf(stderr, "\n"); 25 | i++; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ciri/utils/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "files", 5 | srcs = ["files.c"], 6 | hdrs = ["files.h"], 7 | deps = [ 8 | "//common:errors", 9 | ], 10 | ) 11 | 12 | cc_library( 13 | name = "signed_files", 14 | srcs = ["signed_files.c"], 15 | hdrs = ["signed_files.h"], 16 | deps = [ 17 | "//common:errors", 18 | "//common/crypto/curl-p:trit", 19 | "//common/crypto/iss:normalize", 20 | "//common/crypto/iss/v1:iss_curl", 21 | "//common/crypto/kerl", 22 | "//common/model:bundle", 23 | "//common/trinary:trit_long", 24 | "//common/trinary:tryte_ascii", 25 | "//utils:merkle", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /ciri/utils/signed_files.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __CIRI_UTILS_SIGNED_FILES_H__ 9 | #define __CIRI_UTILS_SIGNED_FILES_H__ 10 | 11 | #include 12 | 13 | #include "common/errors.h" 14 | #include "common/trinary/flex_trit.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | retcode_t iota_file_signature_validate(char const *const filename, char const *const signature_filename, 21 | flex_trit_t const *const public_key, uint32_t depth, size_t index, 22 | bool *const valid); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // __CIRI_UTILS_SIGNED_FILES_H__ 29 | -------------------------------------------------------------------------------- /ciri/utils/tests/BUILD: -------------------------------------------------------------------------------- 1 | load("//ciri/consensus:conf.bzl", "CONSENSUS_MAINNET_VARIABLES") 2 | 3 | cc_test( 4 | name = "test_signed_files", 5 | timeout = "long", 6 | srcs = ["test_signed_files.c"], 7 | data = [ 8 | "fake.sig", 9 | "//ciri/consensus/snapshot:snapshot_files", 10 | ], 11 | defines = CONSENSUS_MAINNET_VARIABLES, 12 | deps = [ 13 | "//ciri/consensus/snapshot", 14 | "//ciri/utils:signed_files", 15 | "@unity", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /cmake/cjson.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | Copyright (c) 2019 IOTA Stiftung 3 | https://github.com/iotaledger/entangled 4 | 5 | Refer to the LICENSE file for licensing information 6 | ]] 7 | 8 | if (NOT __CJSON_INCLUDED) 9 | set(__CJSON_INCLUDED TRUE) 10 | 11 | ExternalProject_Add( 12 | ext_cjson 13 | PREFIX ${EXTERNAL_BUILD_DIR}/cjson 14 | DOWNLOAD_DIR ${EXTERNAL_DOWNLOAD_DIR} 15 | DOWNLOAD_NAME cjson_v1.7.12.tar.gz 16 | URL https://github.com/DaveGamble/cJSON/archive/v1.7.12.tar.gz 17 | URL_HASH SHA256=760687665ab41a5cff9c40b1053c19572bcdaadef1194e5cba1b5e6f824686e7 18 | CMAKE_ARGS 19 | -DENABLE_CJSON_TEST:STRING=Off 20 | -DENABLE_CJSON_UTILS:STRING=Off 21 | -DBUILD_SHARED_LIBS:STRING=Off 22 | -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX} 23 | -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE} 24 | # for debug 25 | # LOG_DOWNLOAD 1 26 | # LOG_CONFIGURE 1 27 | # LOG_INSTALL 1 28 | ) 29 | 30 | include_directories("${CMAKE_INSTALL_PREFIX}/include/cjson") 31 | list(APPEND EXTERNAL_LINK_LIBS cjson) 32 | 33 | endif() -------------------------------------------------------------------------------- /cmake/embear_logger.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | Copyright (c) 2019 IOTA Stiftung 3 | https://github.com/iotaledger/entangled 4 | 5 | Refer to the LICENSE file for licensing information 6 | ]] 7 | 8 | if (NOT __EMBEAR_LOGGER_INCLUDED) 9 | set(__EMBEAR_LOGGER_INCLUDED TRUE) 10 | 11 | ExternalProject_Add( 12 | ext_embear_logger 13 | PREFIX ${EXTERNAL_BUILD_DIR}/embear_logger 14 | DOWNLOAD_DIR ${EXTERNAL_DOWNLOAD_DIR} 15 | DOWNLOAD_NAME embear_logger_v4.0.x.tar.gz 16 | URL https://github.com/embear/logger/archive/v4.0.x.tar.gz 17 | URL_HASH SHA256=af36b44bbc4aea3618962f68e24bc1efcc2c53d490b8b4a56463ea7afc910d67 18 | # copy header 19 | UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_directory 20 | /include ${CMAKE_INSTALL_PREFIX}/include 21 | CMAKE_ARGS 22 | -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX} 23 | -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE} 24 | # for debug 25 | # LOG_DOWNLOAD 1 26 | # LOG_CONFIGURE 1 27 | # LOG_INSTALL 1 28 | ) 29 | 30 | list(APPEND EXTERNAL_LINK_LIBS logger) 31 | 32 | endif() -------------------------------------------------------------------------------- /cmake/gen_hash_container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HASH_SIZE_LIST=("27" "81" "243" "6561" "8019") 3 | TYPE_LIST=("queue" "stack") 4 | 5 | HASH_TEMPLATE_DIR="./utils/containers/hash" 6 | for HASH_TYPE in ${TYPE_LIST[@]}; do 7 | for HASH_FILE in ${HASH_TEMPLATE_DIR}/hash_${HASH_TYPE}*.tpl; do 8 | FILE_NAME=$(basename "${HASH_FILE}" .tpl) 9 | for HASH_SIZE in ${HASH_SIZE_LIST[@]}; do 10 | HASH_FILE_NAME=${FILE_NAME/hash/hash${HASH_SIZE}} 11 | echo "cp ${HASH_FILE} ${HASH_TEMPLATE_DIR}/${HASH_FILE_NAME}" 12 | cp ${HASH_FILE} ${HASH_TEMPLATE_DIR}/${HASH_FILE_NAME} 13 | if [[ "$OSTYPE" == "darwin"* ]]; then 14 | sed -i.bak "s/{SIZE}/${HASH_SIZE}/g" ${HASH_TEMPLATE_DIR}/${HASH_FILE_NAME} && rm -- "${HASH_TEMPLATE_DIR}/${HASH_FILE_NAME}.bak" 15 | else 16 | sed -i "s/{SIZE}/${HASH_SIZE}/g" ${HASH_TEMPLATE_DIR}/${HASH_FILE_NAME} 17 | fi 18 | done 19 | done 20 | done 21 | -------------------------------------------------------------------------------- /cmake/uthash.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | Copyright (c) 2019 IOTA Stiftung 3 | https://github.com/iotaledger/entangled 4 | 5 | Refer to the LICENSE file for licensing information 6 | ]] 7 | 8 | if (NOT __UTHASH_INCLUDED) 9 | set(__UTHASH_INCLUDED TRUE) 10 | 11 | ExternalProject_Add( 12 | ext_uthash 13 | PREFIX ${EXTERNAL_BUILD_DIR}/uthash 14 | DOWNLOAD_DIR ${EXTERNAL_DOWNLOAD_DIR} 15 | DOWNLOAD_NAME uthash_v2.1.0.tar.gz 16 | URL https://github.com/troydhanson/uthash/archive/v2.1.0.tar.gz 17 | URL_HASH SHA256=152ccd8e64d0f495377232e3964d06c7ec8bb8c3fbd3217f8a5702614f9a669e 18 | CONFIGURE_COMMAND "" 19 | BUILD_COMMAND "" 20 | INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory 21 | /src ${CMAKE_INSTALL_PREFIX}/include 22 | ) 23 | 24 | endif() -------------------------------------------------------------------------------- /common/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "defs", 5 | hdrs = ["defs.h"], 6 | ) 7 | 8 | cc_library( 9 | name = "errors", 10 | srcs = [ 11 | "error_strings.h", 12 | "errors.c", 13 | "errors.h", 14 | ], 15 | hdrs = ["errors.h"], 16 | ) 17 | 18 | cc_library( 19 | name = "stdint", 20 | hdrs = ["stdint.h"], 21 | ) 22 | -------------------------------------------------------------------------------- /common/crypto/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | -------------------------------------------------------------------------------- /common/crypto/curl-p/const.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "common/crypto/curl-p/const.h" 11 | #include "common/crypto/curl-p/indices.h" 12 | 13 | size_t const CURL_INDEX[STATE_LENGTH + 1] = {__INDEX_TABLE}; 14 | trit_t const TRUTH_TABLE[11] = {__TRUTH_TABLE}; 15 | -------------------------------------------------------------------------------- /common/crypto/curl-p/const.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CURL_P_CONST_H 9 | #define __COMMON_CURL_P_CONST_H 10 | 11 | #include "common/defs.h" 12 | #include "common/trinary/trits.h" 13 | 14 | #define __TRUTH_TABLE 1, 0, -1, 2, 1, -1, 0, 2, -1, 1, 0 15 | #define STATE_LENGTH 3 * HASH_LENGTH_TRIT 16 | 17 | extern const size_t CURL_INDEX[STATE_LENGTH + 1]; 18 | extern const trit_t TRUTH_TABLE[11]; 19 | 20 | typedef enum { 21 | CURL_P_27 = 27, 22 | CURL_P_81 = 81, 23 | } CurlType; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /common/crypto/curl-p/digest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "common/crypto/curl-p/digest.h" 11 | #include "common/trinary/trit_tryte.h" 12 | 13 | void curl_digest(trit_t const* const trits, size_t const len, trit_t* const out, Curl* const curl) { 14 | trit_t digest[HASH_LENGTH_TRIT]; 15 | curl_absorb(curl, trits, len); 16 | curl_squeeze(curl, digest, HASH_LENGTH_TRIT); 17 | memcpy((tryte_t*)out, digest, HASH_LENGTH_TRIT); 18 | } 19 | -------------------------------------------------------------------------------- /common/crypto/curl-p/digest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __DIGEST_H 9 | #define __DIGEST_H 10 | 11 | #include "common/crypto/curl-p/trit.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void curl_digest(trit_t const* const trits, size_t const len, trit_t* const out, Curl* const curl); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif //__DIGEST_H 24 | -------------------------------------------------------------------------------- /common/crypto/curl-p/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_curl_p curl-p 10 | * @ingroup common_crypto 11 | * @brief The curl-p implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/curl-p/hamming.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/curl-p/hamming.h" 9 | #include "common/crypto/curl-p/ptrit.h" 10 | #include "common/crypto/curl-p/search.h" 11 | #include "common/crypto/curl-p/trit.h" 12 | 13 | static test_result_t test(pcurl_t const *pcurl, test_arg_t security) { 14 | size_t i; 15 | 16 | for (i = 0; i < PTRIT_SIZE; i++) { 17 | ptrit_t const *p = pcurl->state; 18 | long sum = 0; 19 | size_t j = 0; 20 | 21 | for (; j++ < (size_t)security;) { 22 | sum += ptrits_sum_slice(HASH_LENGTH_TRIT / 3, p, i); 23 | p += HASH_LENGTH_TRIT / 3; 24 | 25 | if (0 == sum) { 26 | break; 27 | } 28 | } 29 | 30 | if ((size_t)security == j) { 31 | break; 32 | } 33 | } 34 | 35 | return (PTRIT_SIZE == i) ? (test_result_t)-1 : (test_result_t)i; 36 | } 37 | 38 | PearlDiverStatus hamming(Curl *ctx, size_t begin, size_t end, intptr_t security) { 39 | return pd_search(ctx, begin, end, test, security); 40 | } 41 | -------------------------------------------------------------------------------- /common/crypto/curl-p/hamming.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CURL_P_HAMMING_H_ 9 | #define __COMMON_CURL_P_HAMMING_H_ 10 | 11 | #include "common/crypto/curl-p/pearl_diver.h" 12 | #include "common/crypto/curl-p/trit.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | PearlDiverStatus hamming(Curl *ctx, size_t begin, size_t end, intptr_t security); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /common/crypto/curl-p/hashcash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/curl-p/hashcash.h" 9 | #include "common/crypto/curl-p/ptrit.h" 10 | #include "common/crypto/curl-p/search.h" 11 | 12 | static test_result_t test(pcurl_t const *pcurl, test_arg_t mwm) { 13 | ptrit_t const *p = pcurl->state + HASH_LENGTH_TRIT - mwm; 14 | size_t i = ptrits_find_zero_slice((size_t)mwm, p); 15 | return (PTRIT_SIZE == i) ? (test_result_t)-1 : (test_result_t)i; 16 | } 17 | 18 | PearlDiverStatus hashcash(Curl *ctx, size_t begin, size_t end, intptr_t min_weight) { 19 | return pd_search(ctx, begin, end, &test, min_weight); 20 | } 21 | -------------------------------------------------------------------------------- /common/crypto/curl-p/hashcash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CURL_P_HASHCASH_H_ 9 | #define __COMMON_CURL_P_HASHCASH_H_ 10 | 11 | #include "common/crypto/curl-p/pearl_diver.h" 12 | #include "common/crypto/curl-p/trit.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | PearlDiverStatus hashcash(Curl *ctx, size_t begin, size_t end, intptr_t min_weight); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /common/crypto/curl-p/pearl_diver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CURL_P_PEARL_DIVER_H_ 9 | #define __COMMON_CURL_P_PEARL_DIVER_H_ 10 | 11 | typedef enum { PEARL_DIVER_SUCCESS, PEARL_DIVER_RUNNING, PEARL_DIVER_INTERRUPTED, PEARL_DIVER_ERROR } PearlDiverStatus; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /common/crypto/curl-p/search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CURL_P_SEARCH_H_ 9 | #define __COMMON_CURL_P_SEARCH_H_ 10 | 11 | #include "common/crypto/curl-p/pearl_diver.h" 12 | #include "common/crypto/curl-p/ptrit.h" 13 | #include "common/crypto/curl-p/trit.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef intptr_t test_arg_t; 20 | typedef intptr_t test_result_t; 21 | typedef test_result_t (*test_fun_t)(pcurl_t const *, test_arg_t); 22 | 23 | PearlDiverStatus pd_search(Curl *ctx, size_t begin, size_t end, test_fun_t test, test_arg_t param); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /common/crypto/curl-p/trit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CRYPTO_CURL_P_TRIT_H__ 9 | #define __COMMON_CRYPTO_CURL_P_TRIT_H__ 10 | 11 | #include 12 | 13 | #include "common/crypto/curl-p/const.h" 14 | #include "common/trinary/trits.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef struct { 21 | trit_t state[STATE_LENGTH]; 22 | CurlType type; 23 | } Curl; 24 | 25 | void curl_init(Curl* const ctx); 26 | void curl_absorb(Curl* const ctx, trit_t const* const trits, size_t length); 27 | void curl_squeeze(Curl* const ctx, trit_t* const trits, size_t length); 28 | void curl_reset(Curl* const ctx); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // __COMMON_CRYPTO_CURL_P_TRIT_H__ 35 | -------------------------------------------------------------------------------- /common/crypto/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup common_crypto crypto 10 | * @ingroup common 11 | * @brief The crypto implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/ftroika/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "ftroika", 5 | srcs = glob(["*.c"]) + glob(["*.h"]), 6 | hdrs = ["ftroika.h"], 7 | deps = [ 8 | ":t27", 9 | "//common:stdint", 10 | "//common/trinary:trits", 11 | "//common/trinary:tryte", 12 | ], 13 | ) 14 | 15 | cc_library( 16 | name = "t27", 17 | srcs = ["t27.h"], 18 | deps = [ 19 | "//common:stdint", 20 | "//common/trinary:trits", 21 | "//common/trinary:tryte", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /common/crypto/ftroika/README.md: -------------------------------------------------------------------------------- 1 | ## Ftroika 2 | 3 | This library contains a community implementation of the Troika trinary hash function 4 | 5 | based on: https://github.com/c-mnd/troika 6 | 7 | This implementation should be regarded as alpha and should not be used in production yet 8 | -------------------------------------------------------------------------------- /common/crypto/ftroika/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_ftroika ftroika 10 | * @ingroup common_crypto 11 | * @brief The ftroika implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/ftroika/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_ftroika", 3 | timeout = "moderate", 4 | srcs = ["test_ftroika.c"], 5 | deps = [ 6 | "//common/crypto/ftroika", 7 | "//common/crypto/troika", 8 | "@unity", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /common/crypto/iss/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "normalize", 5 | srcs = ["normalize.c"], 6 | hdrs = ["normalize.h"], 7 | deps = [ 8 | "//common:defs", 9 | "//common/trinary:flex_trit", 10 | "//common/trinary:trit_long", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /common/crypto/iss/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_iss ISS 10 | * @ingroup common_crypto 11 | * @brief The ISS implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/iss/normalize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_SIGN_NORMALIZE_H__ 9 | #define __COMMON_SIGN_NORMALIZE_H__ 10 | 11 | #include "common/trinary/flex_trit.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | bool normalized_hash_is_secure(byte_t const *const normalized_hash, size_t const length); 18 | void normalize_hash(trit_t const *const hash, byte_t *const normalized_hash); 19 | void normalize_hash_to_trits(trit_t const *const hash, trit_t *const normalized_hash); 20 | void normalize_flex_hash(flex_trit_t const *const hash, byte_t *const normalized_hash); 21 | void normalize_flex_hash_to_trits(flex_trit_t const *const hash, trit_t *const normalized_hash); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif // __COMMON_SIGN_NORMALIZE_H__ 28 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "iss", 5 | srcs = ["iss.c"], 6 | hdrs = ["iss.h"], 7 | deps = [ 8 | "//common/crypto/sponge", 9 | "//common/trinary:add", 10 | ], 11 | ) 12 | 13 | cc_library( 14 | name = "iss_curl", 15 | srcs = [ 16 | "iss.c.inc", 17 | "iss_curl.c", 18 | ], 19 | hdrs = [ 20 | "iss.h.inc", 21 | "iss_curl.h", 22 | ], 23 | deps = [ 24 | "//common:defs", 25 | "//common/crypto/curl-p:trit", 26 | "//common/trinary:add", 27 | ], 28 | ) 29 | 30 | cc_library( 31 | name = "iss_kerl", 32 | srcs = [ 33 | "iss.c.inc", 34 | "iss_kerl.c", 35 | ], 36 | hdrs = [ 37 | "iss.h.inc", 38 | "iss_kerl.h", 39 | ], 40 | deps = [ 41 | "//common:defs", 42 | "//common/crypto/kerl", 43 | "//common/trinary:add", 44 | ], 45 | ) 46 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/iss_curl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/iss/v1/iss_curl.h" 9 | #include "common/crypto/curl-p/trit.h" 10 | 11 | #define HASH_PREFIX curl 12 | #define HASH_STATE Curl 13 | 14 | #include "iss.c.inc" 15 | 16 | #undef HASH_PREFIX 17 | #undef HASH_STATE 18 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/iss_curl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __ISS_CURL_H_ 9 | #define __ISS_CURL_H_ 10 | 11 | #include "common/crypto/curl-p/trit.h" 12 | 13 | #define HASH_PREFIX curl 14 | #define HASH_STATE Curl 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "iss.h.inc" 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #undef HASH_PREFIX 27 | #undef HASH_STATE 28 | 29 | #endif /* __ISS_CURL_H_ */ 30 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/iss_kerl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/iss/v1/iss_kerl.h" 9 | #include "common/crypto/kerl/kerl.h" 10 | 11 | #define HASH_PREFIX kerl 12 | #define HASH_STATE Kerl 13 | 14 | #include "iss.c.inc" 15 | 16 | #undef HASH_PREFIX 17 | #undef HASH_STATE 18 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/iss_kerl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __ISS_KERL_H_ 9 | #define __ISS_KERL_H_ 10 | 11 | #include "common/crypto/kerl/kerl.h" 12 | 13 | #define HASH_PREFIX kerl 14 | #define HASH_STATE Kerl 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "iss.h.inc" 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #undef HASH_PREFIX 27 | #undef HASH_STATE 28 | 29 | #endif /* __ISS_KERL_H_ */ 30 | -------------------------------------------------------------------------------- /common/crypto/iss/v1/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_iss", 3 | timeout = "moderate", 4 | srcs = [ 5 | "test_iss.c", 6 | ], 7 | deps = [ 8 | "//common/crypto/iss:normalize", 9 | "//common/crypto/iss/v1:iss", 10 | "//common/trinary:trit_tryte", 11 | "@unity", 12 | ], 13 | ) 14 | 15 | cc_test( 16 | name = "test_iss_curl", 17 | timeout = "short", 18 | srcs = [ 19 | "test_iss_curl.c", 20 | ], 21 | deps = [ 22 | "//common/crypto/iss/v1:iss_curl", 23 | "//common/trinary:trit_tryte", 24 | "@unity", 25 | ], 26 | ) 27 | 28 | cc_test( 29 | name = "test_iss_kerl", 30 | timeout = "short", 31 | srcs = [ 32 | "test_iss_kerl.c", 33 | ], 34 | deps = [ 35 | "//common/crypto/iss/v1:iss_kerl", 36 | "//common/trinary:trit_tryte", 37 | "@unity", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "iss_curl", 5 | srcs = [ 6 | "iss.c.inc", 7 | "iss_curl.c", 8 | ], 9 | hdrs = [ 10 | "iss.h.inc", 11 | "iss_curl.h", 12 | ], 13 | deps = [ 14 | "//common:defs", 15 | "//common/crypto/curl-p:trit", 16 | "//common/trinary:add", 17 | ], 18 | ) 19 | 20 | cc_library( 21 | name = "iss_kerl", 22 | srcs = [ 23 | "iss.c.inc", 24 | "iss_kerl.c", 25 | ], 26 | hdrs = [ 27 | "iss.h.inc", 28 | "iss_kerl.h", 29 | ], 30 | deps = [ 31 | "//common:defs", 32 | "//common/crypto/kerl", 33 | "//common/trinary:add", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/iss_curl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/curl-p/trit.h" 9 | 10 | #define HASH_PREFIX curl 11 | #define HASH_STATE Curl 12 | 13 | #include "iss.c.inc" 14 | 15 | #undef HASH_PREFIX 16 | #undef HASH_STATE 17 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/iss_curl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __ISS_CURL_H_ 9 | #define __ISS_CURL_H_ 10 | 11 | #include "common/crypto/curl-p/trit.h" 12 | 13 | #define HASH_PREFIX curl 14 | #define HASH_STATE Curl 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "iss.h.inc" 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #undef HASH_PREFIX 27 | #undef HASH_STATE 28 | 29 | #endif /* __ISS_CURL_H_ */ 30 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/iss_kerl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/kerl/kerl.h" 9 | 10 | #define HASH_PREFIX kerl 11 | #define HASH_STATE Kerl 12 | 13 | #include "iss.c.inc" 14 | 15 | #undef HASH_PREFIX 16 | #undef HASH_STATE 17 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/iss_kerl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __ISS_V2_KERL_H_ 9 | #define __ISS_V2_KERL_H_ 10 | 11 | #include "common/crypto/kerl/kerl.h" 12 | 13 | #define HASH_PREFIX kerl 14 | #define HASH_STATE Kerl 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "iss.h.inc" 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #undef HASH_PREFIX 27 | #undef HASH_STATE 28 | 29 | #endif /* __ISS_V2_KERL_H_ */ 30 | -------------------------------------------------------------------------------- /common/crypto/iss/v2/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_iss_curl", 3 | timeout = "short", 4 | srcs = [ 5 | "test_iss_curl.c", 6 | ], 7 | deps = [ 8 | "//common/crypto/curl-p:trit", 9 | "//common/crypto/iss/v2:iss_curl", 10 | "//common/trinary:trit_tryte", 11 | "@unity", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /common/crypto/kerl/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "bigint", 5 | srcs = ["bigint.c"], 6 | hdrs = ["bigint.h"], 7 | deps = ["//common:stdint"], 8 | ) 9 | 10 | cc_library( 11 | name = "converter", 12 | srcs = ["converter.c"], 13 | hdrs = ["converter.h"], 14 | deps = [ 15 | ":bigint", 16 | "//common:defs", 17 | "//common:stdint", 18 | "//common/trinary:trits", 19 | "//utils:memset_safe", 20 | ], 21 | ) 22 | 23 | cc_library( 24 | name = "kerl", 25 | srcs = ["kerl.c"], 26 | hdrs = ["kerl.h"], 27 | deps = [ 28 | ":converter", 29 | "@keccak", 30 | ], 31 | ) 32 | 33 | cc_library( 34 | name = "hash", 35 | srcs = ["hash.c"], 36 | hdrs = ["hash.h"], 37 | deps = [ 38 | ":kerl", 39 | "//common/trinary:tryte", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /common/crypto/kerl/bigint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_KERL_BIGINT_H_ 9 | #define __COMMON_KERL_BIGINT_H_ 10 | 11 | #include "common/stdint.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void bigint_not(uint32_t* const base, size_t const len); 18 | size_t bigint_add_small(uint32_t* const base, uint32_t const other); 19 | void bigint_add(uint32_t* const base, uint32_t const* const rh, size_t const len); 20 | void bigint_sub(uint32_t* const base, uint32_t const* const rh, size_t const len); 21 | int8_t bigint_cmp(uint32_t const* const lh, uint32_t const* const rh, size_t const len); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /* __COMMON_KERL_BIGINT_H_ */ 28 | -------------------------------------------------------------------------------- /common/crypto/kerl/converter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_KERL_CONVERTER_H_ 9 | #define __COMMON_KERL_CONVERTER_H_ 10 | 11 | #include "common/stdint.h" 12 | #include "common/trinary/trits.h" 13 | #include "utils/memset_safe.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | void convert_trits_to_bytes(trit_t const *const trits, uint8_t *const bytes); 20 | 21 | // This method consumes the input bytes. 22 | void convert_bytes_to_trits(uint8_t *const bytes, trit_t *const trits); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif /* __COMMON_KERL_CONVERTER_H_ */ 29 | -------------------------------------------------------------------------------- /common/crypto/kerl/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_kerl Kerl 10 | * @ingroup common_crypto 11 | * @brief The Kerl implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/kerl/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/crypto/kerl/hash.h" 9 | #include "common/defs.h" 10 | #include "common/trinary/tryte.h" 11 | 12 | void kerl_hash(const trit_t* const trits, size_t len, trit_t* out, Kerl* kerl) { 13 | trit_t digest[HASH_LENGTH_TRIT]; 14 | 15 | kerl_init(kerl); 16 | kerl_absorb(kerl, trits, len); 17 | kerl_squeeze(kerl, digest, HASH_LENGTH_TRIT); 18 | memcpy((tryte_t*)out, digest, HASH_LENGTH_TRIT); 19 | } 20 | -------------------------------------------------------------------------------- /common/crypto/kerl/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __KERL_HASH_H 9 | #define __KERL_HASH_H 10 | 11 | #include "common/crypto/kerl/kerl.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void kerl_hash(const trit_t* const trits, size_t len, trit_t* out, Kerl* kerl); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif //__KERL_HASH_H 24 | -------------------------------------------------------------------------------- /common/crypto/kerl/kerl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_CRYPTO_KERL_KERL_H__ 9 | #define __COMMON_CRYPTO_KERL_KERL_H__ 10 | 11 | #ifdef __XTENSA__ 12 | #include "FIPS202/KeccakHash.h" 13 | #else 14 | #include 15 | #endif 16 | 17 | #include "common/stdint.h" 18 | #include "common/trinary/trits.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct { 25 | Keccak_HashInstance keccak; 26 | } Kerl; 27 | 28 | void kerl_init(Kerl* const ctx); 29 | void kerl_absorb(Kerl* const ctx, trit_t const* trits, size_t const length); 30 | void kerl_squeeze(Kerl* const ctx, trit_t* trits, size_t const length); 31 | void kerl_reset(Kerl* const ctx); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // __COMMON_CRYPTO_KERL_KERL_H__ 38 | -------------------------------------------------------------------------------- /common/crypto/kerl/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_converter", 3 | timeout = "short", 4 | srcs = ["test_converter.c"], 5 | deps = [ 6 | "//common/crypto/kerl:converter", 7 | "//common/trinary:trit_tryte", 8 | "@unity", 9 | ], 10 | ) 11 | 12 | cc_test( 13 | name = "test_kerl", 14 | timeout = "short", 15 | srcs = ["test_kerl.c"], 16 | deps = [ 17 | "//common/crypto/kerl", 18 | "//common/trinary:trit_tryte", 19 | "@unity", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /common/crypto/sponge/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "sponge", 5 | srcs = ["sponge.c"], 6 | hdrs = ["sponge.h"], 7 | deps = [ 8 | "//common:errors", 9 | "//common/crypto/curl-p:trit", 10 | "//common/crypto/kerl", 11 | "//common/trinary:flex_trit", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /common/crypto/sponge/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_sponge Sponge 10 | * @ingroup common_crypto 11 | * @brief The Sponge implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/crypto/sponge/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_sponge", 3 | timeout = "short", 4 | srcs = ["test_sponge.c"], 5 | deps = [ 6 | "//common/crypto/sponge", 7 | "//common/model:transaction", 8 | "@unity", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /common/crypto/troika/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "troika", 5 | srcs = ["troika.c"], 6 | hdrs = ["troika.h"], 7 | deps = [ 8 | "//common:stdint", 9 | "//common/trinary:trits", 10 | "//common/trinary:tryte", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /common/crypto/troika/README.md: -------------------------------------------------------------------------------- 1 | ## Troika 2 | 3 | This library contains the Troika trinary hash function reference implementation 4 | 5 | based on: https://github.com/Troikahash/reference 6 | 7 | This implementation should be regarded as alpha and should not be used in production yet -------------------------------------------------------------------------------- /common/crypto/troika/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup crypto_troika troika 10 | * @ingroup common_crypto 11 | * @brief The Troika implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup common Common 10 | * @brief The common modules used by entangled components. 11 | * 12 | * The common module contains crypto, trinary, data models, network, and error code implementation. 13 | */ 14 | 15 | /** 16 | * @defgroup common_error Error Codes 17 | * @ingroup common 18 | * @brief The error code implementation. 19 | * 20 | */ -------------------------------------------------------------------------------- /common/helpers/checksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_HELPERS_CHECKSUM_H_ 9 | #define __COMMON_HELPERS_CHECKSUM_H_ 10 | 11 | #include 12 | 13 | #include "common/trinary/flex_trit.h" 14 | #include "utils/export.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | IOTA_EXPORT char* iota_checksum(const char* input, const size_t input_length, const size_t checksum_length); 21 | 22 | IOTA_EXPORT flex_trit_t* iota_flex_checksum(const flex_trit_t* flex_trits, const size_t num_trits, 23 | const size_t checksum_length); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif //__COMMON_HELPERS_CHECKSUM_H_ 30 | -------------------------------------------------------------------------------- /common/helpers/digest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_HELPERS_DIGEST_H 9 | #define __COMMON_HELPERS_DIGEST_H 10 | 11 | #include "common/trinary/flex_trit.h" 12 | #include "utils/export.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | IOTA_EXPORT char* iota_digest(char const* const trytes); 19 | 20 | IOTA_EXPORT flex_trit_t* iota_flex_digest(flex_trit_t const* const flex_trits, size_t num_trits); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif //__COMMON_HELPERS_DIGEST_H 27 | -------------------------------------------------------------------------------- /common/helpers/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup common_helpers Common Helpers 10 | * @ingroup common 11 | * @brief The helpers implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/helpers/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_checksum", 3 | timeout = "short", 4 | srcs = ["test_checksum.c"], 5 | deps = [ 6 | "//common/helpers:checksum", 7 | "@unity", 8 | ], 9 | ) 10 | 11 | cc_test( 12 | name = "test_digest", 13 | timeout = "short", 14 | srcs = ["test_digest.c"], 15 | deps = [ 16 | "//common/helpers:digest", 17 | "@unity", 18 | ], 19 | ) 20 | 21 | cc_test( 22 | name = "test_pow", 23 | timeout = "short", 24 | srcs = ["test_pow.c"], 25 | deps = [ 26 | "//common/helpers:pow", 27 | "@unity", 28 | ], 29 | ) 30 | 31 | cc_test( 32 | name = "test_sign", 33 | timeout = "short", 34 | srcs = ["test_sign.c"], 35 | deps = [ 36 | "//common/helpers:sign", 37 | "@unity", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /common/model/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup common_model Data Model 10 | * @ingroup common 11 | * @brief The data model implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/model/milestone.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_MODEL_MILESTONE_H__ 9 | #define __COMMON_MODEL_MILESTONE_H__ 10 | 11 | #include "common/trinary/flex_trit.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef struct iota_milestone_s { 18 | uint64_t index; 19 | flex_trit_t hash[FLEX_TRIT_SIZE_243]; 20 | } iota_milestone_t; 21 | 22 | static inline void milestone_reset(iota_milestone_t *const milestone) { 23 | milestone->index = 0; 24 | memset(milestone->hash, FLEX_TRIT_NULL_VALUE, sizeof(milestone->hash)); 25 | } 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif // __COMMON_MODEL_MILESTONE_H__ 32 | -------------------------------------------------------------------------------- /common/model/tests/test_tryte_transaction.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "common/model/tests/defs.h" 12 | #include "common/model/tryte_transaction.h" 13 | #include "common/trinary/flex_trit.h" 14 | 15 | namespace { 16 | TEST(TransactionTest, testTransaction) { 17 | using namespace testing; 18 | using namespace iota; 19 | using namespace model; 20 | 21 | std::string trytes(TRYTES, sizeof(TRYTES)); 22 | flex_trit_t trits[FLEX_TRIT_SIZE_8019]; 23 | flex_trits_from_trytes(trits, NUM_TRITS_SERIALIZED_TRANSACTION, (tryte_t*)TRYTES, NUM_TRITS_SERIALIZED_TRANSACTION, 24 | NUM_TRYTES_SERIALIZED_TRANSACTION); 25 | 26 | TryteTransaction transaction = TryteTransaction(trytes); 27 | std::vector value = transaction.serialize(); 28 | std::vector ref(trits, trits + sizeof(trits)); 29 | ASSERT_EQ(ref, value); 30 | } 31 | } // namespace 32 | -------------------------------------------------------------------------------- /common/stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef COMMON_STDINT_H_ 9 | #define COMMON_STDINT_H_ 10 | 11 | #if defined(_WIN32) && !defined(MINGW) 12 | #else 13 | #include 14 | #endif 15 | #include 16 | #endif // COMMON_STDINT_H_ 17 | -------------------------------------------------------------------------------- /common/trinary/add.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __TRIT_ADD_H__ 9 | #define __TRIT_ADD_H__ 10 | 11 | #include "common/trinary/trits.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | trit_t trit_sum(trit_t const a, trit_t const b); 18 | int add_assign(trit_t *const t, size_t const s, int64_t const v); 19 | void add_trits(trit_t const *const lh, trit_t *const rh, size_t const len); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif //__TRIT_ADD_H__ 26 | -------------------------------------------------------------------------------- /common/trinary/bytes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_BYTE_H_ 9 | #define __COMMON_TRINARY_BYTE_H_ 10 | 11 | #include "common/stdint.h" 12 | 13 | typedef int8_t byte_t; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /common/trinary/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup common_trinary Trinary 10 | * @ingroup common 11 | * @brief The Trinary implementations. 12 | * 13 | */ -------------------------------------------------------------------------------- /common/trinary/tests/test_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "common/trinary/add.h" 12 | 13 | void test_add(void) { 14 | trit_t h[3] = {-1, 0, 1}; 15 | trit_t g[3] = {1, -1, 1}; 16 | trit_t z[3] = {-1, 0, 0}; 17 | 18 | add_trits(h, z, 3); 19 | TEST_ASSERT_EQUAL_MEMORY(g, z, sizeof(z)); 20 | add_assign(z, 3, 1); 21 | TEST_ASSERT_EQUAL_MEMORY(h, z, sizeof(z)); 22 | } 23 | 24 | int main(void) { 25 | UNITY_BEGIN(); 26 | 27 | RUN_TEST(test_add); 28 | 29 | return UNITY_END(); 30 | } 31 | -------------------------------------------------------------------------------- /common/trinary/tests/test_ptrits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include "common/trinary/ptrit.h" 13 | #include "common/trinary/ptrit_incr.h" 14 | #include "common/trinary/trit_long.h" 15 | 16 | #define TEST_N 6 17 | #define TEST_M ((3 * 3 * 3 * 3 * 3 * 3 - 1) / 2) 18 | 19 | void test_ptrits_set_iota(void) { 20 | ptrit_t p[TEST_N]; 21 | trit_t value[TEST_N]; 22 | size_t i; 23 | int64_t s; 24 | 25 | memset(value, -1, sizeof(value)); 26 | ptrit_set_iota(TEST_N, p, value); 27 | ptrits_get_slice(TEST_N, value, p, 0); 28 | s = -TEST_M; 29 | TEST_ASSERT_EQUAL_INT(s, trits_to_long(value, TEST_N)); 30 | 31 | for (i = 1; i < PTRIT_SIZE; ++i) { 32 | ptrits_get_slice(TEST_N, value, p, i); 33 | if (++s > TEST_M) { 34 | s = -TEST_M; 35 | } 36 | TEST_ASSERT_EQUAL_INT(s, trits_to_long(value, TEST_N)); 37 | } 38 | } 39 | 40 | int main(void) { 41 | UNITY_BEGIN(); 42 | 43 | RUN_TEST(test_ptrits_set_iota); 44 | 45 | return UNITY_END(); 46 | } 47 | -------------------------------------------------------------------------------- /common/trinary/tests/test_trit_ptrit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | 10 | #include "common/trinary/trit_ptrit.h" 11 | 12 | void test_trit_to_ptrit(void) { 13 | trit_t trits[] = {-1, 0, 1}; 14 | trit_t trits2[] = {0, 1, -1}; 15 | size_t i; 16 | 17 | ptrit_t ptrit[3]; 18 | trit_t trit_o[3]; 19 | 20 | trits_to_ptrits_fill(trits, ptrit, 3); 21 | for (i = 0; i < PTRIT_SIZE; ++i) { 22 | ptrits_to_trits(ptrit, trit_o, i, 3); 23 | TEST_ASSERT_EQUAL_MEMORY(trits, trit_o, sizeof(trits)); 24 | } 25 | 26 | trits_to_ptrits_fill(trits2, ptrit, 3); 27 | for (i = 0; i < PTRIT_SIZE; i++) { 28 | trits_to_ptrits(trits, ptrit, i, 3); 29 | ptrits_to_trits(ptrit, trit_o, i, 3); 30 | 31 | TEST_ASSERT_EQUAL_MEMORY(trits, trit_o, sizeof(trits)); 32 | } 33 | } 34 | 35 | int main(void) { 36 | UNITY_BEGIN(); 37 | 38 | RUN_TEST(test_trit_to_ptrit); 39 | 40 | return UNITY_END(); 41 | } 42 | -------------------------------------------------------------------------------- /common/trinary/trit_tryte.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_TRIT_TRYTE_H_ 9 | #define __COMMON_TRINARY_TRIT_TRYTE_H_ 10 | 11 | #include "common/defs.h" 12 | #include "common/trinary/trits.h" 13 | #include "common/trinary/tryte.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | static inline size_t num_trytes_for_trits(size_t num_trits) { 20 | return (num_trits + NUMBER_OF_TRITS_IN_A_TRYTE - 1) / NUMBER_OF_TRITS_IN_A_TRYTE; 21 | } 22 | 23 | trit_t get_trit_at(tryte_t const *const trytes, size_t const length, size_t const index); 24 | uint8_t set_trit_at(tryte_t *const trytes, size_t const length, size_t const index, trit_t const trit); 25 | void trits_to_trytes(trit_t const *const trits, tryte_t *const trytes, size_t const length); 26 | void trytes_to_trits(tryte_t const *const trytes, trit_t *const trits, size_t const length); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif // __COMMON_TRINARY_TRIT_TRYTE_H_ 33 | -------------------------------------------------------------------------------- /common/trinary/trits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_TRIT_H_ 9 | #define __COMMON_TRINARY_TRIT_H_ 10 | 11 | #include "common/stdint.h" 12 | 13 | typedef int8_t trit_t; 14 | 15 | #endif // __COMMON_TRINARY_TRIT_H_ 16 | -------------------------------------------------------------------------------- /common/trinary/tryte.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_TRYTE_H_ 9 | #define __COMMON_TRINARY_TRYTE_H_ 10 | 11 | #include "common/stdint.h" 12 | 13 | typedef int8_t tryte_t; 14 | 15 | #define INDEX_OF_TRYTE(tryte) ((tryte) == '9' ? 0 : ((tryte) - 'A' + 1)) 16 | 17 | #endif // __COMMON_TRINARY_TRYTE_H_ 18 | -------------------------------------------------------------------------------- /common/trinary/tryte_ascii.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/trinary/tryte_ascii.h" 9 | #include "common/defs.h" 10 | 11 | void ascii_to_trytes(char const *const input, tryte_t *const output) { 12 | int j = 0, dec = 0, first = 0, second = 0; 13 | 14 | for (size_t i = 0; input[i]; i++) { 15 | dec = input[i]; 16 | first = dec % TRYTE_SPACE_SIZE; 17 | second = (dec - first) / TRYTE_SPACE_SIZE; 18 | output[j++] = TRYTE_ALPHABET[first]; 19 | output[j++] = TRYTE_ALPHABET[second]; 20 | } 21 | } 22 | 23 | void trytes_to_ascii(tryte_t const *const input, size_t const input_size, char *const output) { 24 | for (size_t i = 0; i < input_size; i += 2) { 25 | output[i / 2] = INDEX_OF_TRYTE(input[i]) + INDEX_OF_TRYTE(input[i + 1]) * TRYTE_SPACE_SIZE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/trinary/tryte_ascii.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_TRYTE_ASCII_H_ 9 | #define __COMMON_TRINARY_TRYTE_ASCII_H_ 10 | 11 | #include 12 | 13 | #include "common/trinary/tryte.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | void ascii_to_trytes(char const *const input, tryte_t *const output); 20 | void trytes_to_ascii(tryte_t const *const intput, size_t const input_size, char *const ouput); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif // __COMMON_TRINARY_TRYTE_ASCII_H_ 27 | -------------------------------------------------------------------------------- /common/trinary/tryte_long.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __COMMON_TRINARY_TRYTE_LONG_H_ 9 | #define __COMMON_TRINARY_TRYTE_LONG_H_ 10 | 11 | #include "common/trinary/tryte.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | size_t min_trytes(int64_t const value); 18 | int64_t trytes_to_long(tryte_t const *const trytes, size_t const length); 19 | size_t long_to_trytes(int64_t const value, tryte_t *const trytes); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif // __COMMON_TRINARY_TRYTE_LONG_H_ 26 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | This folder contains various repository-wide documentation. 2 | 3 | - `labels.json` use, e.g. https://github.com/th0br0/github-label-maker/ to setup or delete the issues 4 | -------------------------------------------------------------------------------- /docs/doxygen/IOTA_Logo_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/docs/doxygen/IOTA_Logo_black.png -------------------------------------------------------------------------------- /docs/doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/pull_request_template.md: -------------------------------------------------------------------------------- 1 | <> 2 | 3 | # Test Plan: 4 | <> 5 | -------------------------------------------------------------------------------- /mam/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("@iota_toolchains//tools/emscripten:defs.bzl", "emcc_binary") 4 | 5 | cc_library( 6 | name = "defs", 7 | hdrs = ["defs.h"], 8 | ) 9 | 10 | # Build command: 11 | # bazel clean (recommended) 12 | # bazel build --spawn_strategy=local --define=workspace=$(bazel info workspace) --define=output_base=$(bazel info output_base) --config=emscripten //mam:mam.js 13 | 14 | #Uncomment the following rule when you want to build it explicitly 15 | 16 | #emcc_binary( 17 | # name = "mam.js", 18 | # deps = [ 19 | # "//mam/api", 20 | # ], 21 | #) 22 | 23 | cc_binary( 24 | name = "libmam.so", 25 | linkshared = True, 26 | deps = ["//mam/api"], 27 | ) 28 | -------------------------------------------------------------------------------- /mam/api/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | load("//utils/containers:map_generator.bzl", "map_generate") 4 | 5 | cc_library( 6 | name = "api", 7 | srcs = ["api.c"], 8 | hdrs = ["api.h"], 9 | deps = [ 10 | ":trit_t_to_mam_msg_read_context_t_map", 11 | ":trit_t_to_mam_msg_write_context_t_map", 12 | "//common:errors", 13 | "//common/model:bundle", 14 | "//mam/mam:message", 15 | "//utils:time", 16 | ], 17 | ) 18 | 19 | map_generate( 20 | additional_deps = ["//mam/mam:message"], 21 | additional_include_path = "mam/mam/message.h", 22 | key_type = "trit_t", 23 | parent_directory = "mam/api", 24 | value_type = "mam_msg_write_context_t", 25 | ) 26 | 27 | map_generate( 28 | additional_deps = ["//mam/mam:message"], 29 | additional_include_path = "mam/mam/message.h", 30 | key_type = "trit_t", 31 | parent_directory = "mam/api", 32 | value_type = "mam_msg_read_context_t", 33 | ) 34 | -------------------------------------------------------------------------------- /mam/api/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_api", 3 | timeout = "eternal", 4 | srcs = ["test_api.c"], 5 | deps = [ 6 | "//common/trinary:tryte_ascii", 7 | "//mam/api", 8 | "//mam/mam/tests:test_channel_utils", 9 | "@unity", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /mam/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup mam MAM 10 | * @brief The Masked Authenticated Messaging (MAM) implementation. 11 | * 12 | * TODO 13 | */ 14 | -------------------------------------------------------------------------------- /mam/mam/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "test_channel_utils", 3 | srcs = ["test_channel_utils.c"], 4 | hdrs = ["test_channel_utils.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//mam/mam:channel", 8 | "//mam/mam:mam_channel_t_set", 9 | ], 10 | ) 11 | 12 | cc_test( 13 | name = "test_message", 14 | timeout = "eternal", 15 | srcs = ["test_message.c"], 16 | deps = [ 17 | "//mam/mam:message", 18 | "@unity", 19 | ], 20 | ) 21 | 22 | cc_test( 23 | name = "test_endpoint", 24 | timeout = "long", 25 | srcs = ["test_endpoint.c"], 26 | deps = [ 27 | "//mam/mam:endpoint", 28 | "//mam/mam:mam_endpoint_t_set", 29 | "//mam/mam:message", 30 | "@unity", 31 | ], 32 | ) 33 | 34 | cc_test( 35 | name = "test_channel", 36 | timeout = "long", 37 | srcs = ["test_channel.c"], 38 | deps = [ 39 | ":test_channel_utils", 40 | "//mam/mam:message", 41 | "@unity", 42 | ], 43 | ) 44 | -------------------------------------------------------------------------------- /mam/mam/tests/test_channel_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * MAM is based on an original implementation & specification by apmi.bsu.by 6 | * [ITSec Lab] 7 | * 8 | * Refer to the LICENSE file for licensing information 9 | */ 10 | 11 | #ifndef __MAM_MAM_TESTS_TEST_CHANNEL_UTILS_H__ 12 | #define __MAM_MAM_TESTS_TEST_CHANNEL_UTILS_H__ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | bool mam_channel_t_set_cmp_test(mam_channel_t_set_t const channels_1, mam_channel_t_set_t const channels_2); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif // __MAM_MAM_TESTS_TEST_CHANNEL_UTILS_H__ 25 | -------------------------------------------------------------------------------- /mam/mss/mss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * MAM is based on an original implementation & specification by apmi.bsu.by [ITSec Lab] 6 | * 7 | * Refer to the LICENSE file for licensing information 8 | */ 9 | 10 | /** 11 | * @ingroup mam 12 | * 13 | * @{ 14 | * 15 | * @file 16 | * @brief 17 | * 18 | */ 19 | #ifndef __MAM_MSS_MSS_H__ 20 | #define __MAM_MSS_MSS_H__ 21 | 22 | #include "mam/mss/mss_common.h" 23 | 24 | #if defined(MAM_MSS_TRAVERSAL) 25 | #include "mam/mss/mss_traversal.h" 26 | #else 27 | #include "mam/mss/mss_classic.h" 28 | #endif 29 | 30 | #endif // __MAM_MSS_MSS_H__ 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /mam/mss/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_mss_classic", 3 | timeout = "eternal", 4 | srcs = ["test_mss.c"], 5 | deps = [ 6 | "//mam/mss:mss_classic", 7 | "//utils/handles:rand", 8 | "@unity", 9 | ], 10 | ) 11 | 12 | cc_test( 13 | name = "test_mss_traversal", 14 | timeout = "eternal", 15 | srcs = ["test_mss.c"], 16 | deps = [ 17 | "//mam/mss:mss_traversal", 18 | "//utils/handles:rand", 19 | "@unity", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /mam/ntru/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_ntru", 3 | timeout = "short", 4 | srcs = ["test_ntru.c"], 5 | deps = [ 6 | "//mam/ntru", 7 | "@unity", 8 | ], 9 | ) 10 | 11 | cc_test( 12 | name = "test_poly_mred_binary", 13 | timeout = "moderate", 14 | srcs = ["test_poly.c"], 15 | deps = [ 16 | "//mam/ntru:poly_mred_binary", 17 | "@unity", 18 | ], 19 | ) 20 | 21 | cc_test( 22 | name = "test_poly_no_mred_binary", 23 | timeout = "moderate", 24 | srcs = ["test_poly.c"], 25 | deps = [ 26 | "//mam/ntru:poly_no_mred_binary", 27 | "@unity", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /mam/pb3/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pb3", 5 | srcs = ["pb3.c"], 6 | hdrs = ["pb3.h"], 7 | deps = [ 8 | "//common:errors", 9 | "//common/trinary:trit_long", 10 | "//mam/sponge:spongos", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /mam/pb3/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_pb3", 3 | timeout = "short", 4 | srcs = ["test_pb3.c"], 5 | deps = [ 6 | "//mam/pb3", 7 | "@unity", 8 | ], 9 | ) 10 | -------------------------------------------------------------------------------- /mam/prng/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "prng", 3 | srcs = ["prng.c"], 4 | hdrs = ["prng.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//common:errors", 8 | "//mam:defs", 9 | "//mam/pb3", 10 | "//mam/sponge", 11 | "//mam/trits", 12 | "//utils:memset_safe", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /mam/prng/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_prng", 3 | timeout = "short", 4 | srcs = ["test_prng.c"], 5 | visibility = ["//visibility:private"], 6 | deps = [ 7 | "//common/trinary:trit_tryte", 8 | "//mam/prng", 9 | "@unity", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /mam/prototype/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "mam", 5 | srcs = ["mam.c"], 6 | hdrs = ["mam.h"], 7 | deps = 8 | [ 9 | ":mask", 10 | "//common/crypto/curl-p:hamming", 11 | "//common/trinary:trit_long", 12 | "//utils:merkle", 13 | ], 14 | ) 15 | 16 | cc_library( 17 | name = "mask", 18 | srcs = ["mask.c"], 19 | hdrs = ["mask.h"], 20 | deps = 21 | [ 22 | "//common/crypto/curl-p:trit", 23 | "//common/trinary:add", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /mam/prototype/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_mam", 3 | timeout = "long", 4 | srcs = ["test_mam.c"], 5 | linkopts = ["-lpthread"], 6 | deps = 7 | [ 8 | "//common/trinary:trit_tryte", 9 | "//mam/prototype:mam", 10 | "@unity", 11 | ], 12 | ) 13 | 14 | cc_test( 15 | name = "test_mask", 16 | timeout = "short", 17 | srcs = ["test_mask.c"], 18 | deps = 19 | [ 20 | "//common/trinary:trit_tryte", 21 | "//mam/prototype:mask", 22 | "@unity", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /mam/psk/BUILD: -------------------------------------------------------------------------------- 1 | load("//utils/containers:typed_container_generator.bzl", "typed_container_generate") 2 | 3 | cc_library( 4 | name = "psk_hdr", 5 | hdrs = ["psk.h"], 6 | visibility = ["//visibility:private"], 7 | deps = [ 8 | "//common:errors", 9 | "//mam/prng", 10 | "//mam/trits", 11 | "//utils:memset_safe", 12 | ], 13 | ) 14 | 15 | cc_library( 16 | name = "psk", 17 | srcs = ["psk.c"], 18 | visibility = ["//visibility:public"], 19 | deps = [ 20 | ":mam_psk_t_set", 21 | ":psk_hdr", 22 | "//mam/pb3", 23 | ], 24 | ) 25 | 26 | typed_container_generate( 27 | additional_deps = ":psk_hdr", 28 | additional_include_path = "mam/psk/psk.h", 29 | container_type = "set", 30 | parent_directory = "mam/psk", 31 | value_type = "mam_psk_t", 32 | ) 33 | -------------------------------------------------------------------------------- /mam/psk/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_psk", 3 | timeout = "short", 4 | srcs = ["test_psk.c"], 5 | visibility = ["//visibility:private"], 6 | deps = [ 7 | "//common/trinary:trit_tryte", 8 | "//mam/psk", 9 | "//mam/psk:mam_psk_t_set", 10 | "@unity", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /mam/rep.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/mam/rep.pdf -------------------------------------------------------------------------------- /mam/spec.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/mam/spec.pdf -------------------------------------------------------------------------------- /mam/sponge/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "sponge", 5 | srcs = ["sponge.c"], 6 | hdrs = ["sponge.h"], 7 | deps = [ 8 | "//common:errors", 9 | "//common/trinary:add", 10 | "//mam:defs", 11 | "//mam/trits", 12 | "//mam/trits:buffers", 13 | "//mam/troika", 14 | ], 15 | ) 16 | 17 | cc_library( 18 | name = "spongos", 19 | srcs = ["spongos.c"], 20 | hdrs = ["spongos.h"], 21 | deps = [ 22 | ":sponge", 23 | ":spongos_types_hdr", 24 | ], 25 | ) 26 | 27 | cc_library( 28 | name = "spongos_types_hdr", 29 | hdrs = ["spongos_types.h"], 30 | deps = [ 31 | ":sponge", 32 | ], 33 | ) 34 | 35 | cc_library( 36 | name = "spongos_types", 37 | srcs = ["spongos_types.c"], 38 | hdrs = ["spongos_types.h"], 39 | deps = [ 40 | ":sponge", 41 | "//mam/pb3", 42 | ], 43 | ) 44 | -------------------------------------------------------------------------------- /mam/sponge/spongos_types.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * MAM is based on an original implementation & specification by apmi.bsu.by 6 | * [ITSec Lab] 7 | * 8 | * Refer to the LICENSE file for licensing information 9 | */ 10 | 11 | #include "mam/sponge/spongos_types.h" 12 | #include "mam/pb3/pb3.h" 13 | 14 | size_t mam_spongos_serialized_size(mam_spongos_t const *const spongos) { 15 | return pb3_sizeof_size_t(spongos->pos) + MAM_SPONGE_WIDTH; 16 | } 17 | 18 | void mam_spongos_serialize(mam_spongos_t const *const spongos, trits_t *const trits) { 19 | pb3_encode_size_t(spongos->pos, trits); 20 | pb3_encode_ntrytes(trits_from_rep(MAM_SPONGE_WIDTH, spongos->sponge.state), trits); 21 | } 22 | 23 | retcode_t mam_spongos_deserialize(trits_t *const trits, mam_spongos_t *const spongos) { 24 | retcode_t err; 25 | ERR_BIND_RETURN(pb3_decode_size_t(&spongos->pos, trits), err); 26 | ERR_BIND_RETURN(pb3_decode_ntrytes(trits_from_rep(MAM_SPONGE_WIDTH, spongos->sponge.state), trits), err); 27 | return err; 28 | } 29 | -------------------------------------------------------------------------------- /mam/sponge/spongos_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * MAM is based on an original implementation & specification by apmi.bsu.by 6 | * [ITSec Lab] 7 | * 8 | * Refer to the LICENSE file for licensing information 9 | */ 10 | 11 | /** 12 | * @ingroup mam 13 | * 14 | * @{ 15 | * 16 | * @file 17 | * @brief 18 | * 19 | */ 20 | #ifndef __MAM_SPONGE_SPONGOS_TYPES_H__ 21 | #define __MAM_SPONGE_SPONGOS_TYPES_H__ 22 | 23 | #include "mam/defs.h" 24 | #include "mam/sponge/sponge.h" 25 | #include "mam/trits/trits.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | typedef struct mam_spongos_s { 32 | mam_sponge_t sponge; 33 | size_t pos; 34 | } mam_spongos_t; 35 | 36 | size_t mam_spongos_serialized_size(mam_spongos_t const *const spongos); 37 | 38 | void mam_spongos_serialize(mam_spongos_t const *const spongos, trits_t *const trits); 39 | 40 | retcode_t mam_spongos_deserialize(trits_t *const trits, mam_spongos_t *const spongos); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif // __MAM_SPONGE_SPONGOS_TYPES_H__ 47 | 48 | /** @} */ 49 | -------------------------------------------------------------------------------- /mam/sponge/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_sponge", 3 | timeout = "short", 4 | srcs = ["test_sponge.c"], 5 | deps = [ 6 | "//mam/sponge", 7 | "@unity", 8 | ], 9 | ) 10 | 11 | cc_test( 12 | name = "test_spongos", 13 | timeout = "short", 14 | srcs = ["test_spongos.c"], 15 | deps = [ 16 | "//mam/sponge:spongos", 17 | "//mam/sponge:spongos_types", 18 | "@unity", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /mam/trits/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "buffers", 5 | srcs = ["buffers.c"], 6 | hdrs = ["buffers.h"], 7 | deps = [ 8 | ":trits", 9 | "//mam:defs", 10 | ], 11 | ) 12 | 13 | cc_library( 14 | name = "trits", 15 | srcs = ["trits.c"], 16 | hdrs = ["trits.h"], 17 | deps = [ 18 | "//common:errors", 19 | "//common/trinary:trit_long", 20 | "//common/trinary:trit_tryte", 21 | "//mam:defs", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /mam/trits/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_trits", 3 | timeout = "short", 4 | srcs = ["test_trits.c"], 5 | deps = [ 6 | "//mam/trits", 7 | "@unity", 8 | ], 9 | ) 10 | -------------------------------------------------------------------------------- /mam/troika/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "troika", 5 | srcs = ["troika.c"], 6 | hdrs = ["troika.h"], 7 | deps = [ 8 | "//common:stdint", 9 | "//common/crypto/ftroika", 10 | "//common/crypto/troika", 11 | "//mam:defs", 12 | "//mam/trits", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /mam/troika/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_troika", 3 | timeout = "short", 4 | srcs = ["test_troika.c"], 5 | deps = [ 6 | "//common/trinary:trit_tryte", 7 | "//mam/troika", 8 | "@unity", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /mam/troika/troika.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * MAM is based on an original implementation & specification by apmi.bsu.by 6 | * [ITSec Lab] 7 | * 8 | * Refer to the LICENSE file for licensing information 9 | */ 10 | 11 | #include "mam/troika/troika.h" 12 | #include "mam/trits/trits.h" 13 | 14 | void mam_ftroika_transform(trit_t *const state, size_t state_size) { 15 | size_t i; 16 | t27_t fstate[SLICES]; 17 | for (i = 0; i != state_size; ++i) { 18 | state[i] += 1; 19 | } 20 | state_to_fstate(state, fstate); 21 | ftroika_permutation(fstate, MAM_TROIKA_NUM_ROUNDS); 22 | fstate_to_state(fstate, state); 23 | for (i = 0; i != state_size; ++i) { 24 | state[i] -= 1; 25 | } 26 | } 27 | 28 | void mam_troika_transform(trit_t *const state, size_t state_size) { 29 | size_t i; 30 | for (i = 0; i != state_size; ++i) { 31 | state[i] += 1; 32 | } 33 | troika_permutation(state, MAM_TROIKA_NUM_ROUNDS); 34 | for (i = 0; i != state_size; ++i) { 35 | state[i] -= 1; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mam/troika/troika.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * MAM is based on an original implementation & specification by apmi.bsu.by 5 | * [ITSec Lab] 6 | * 7 | * Refer to the LICENSE file for licensing information 8 | */ 9 | 10 | /** 11 | * @ingroup mam 12 | * 13 | * @{ 14 | * 15 | * @file 16 | * @brief 17 | * 18 | */ 19 | #ifndef __MAM_TROIKA_TROIKA_H__ 20 | #define __MAM_TROIKA_TROIKA_H__ 21 | 22 | #include "common/crypto/ftroika/ftroika.h" 23 | #include "common/crypto/troika/troika.h" 24 | #include "mam/defs.h" 25 | 26 | #define MAM_TROIKA_NUM_ROUNDS 24 27 | 28 | void mam_ftroika_transform(trit_t *const state, size_t state_size); 29 | void mam_troika_transform(trit_t *const state, size_t state_size); 30 | 31 | #endif //__MAM_TROIKA_TROIKA_H__ 32 | 33 | /** @} */ 34 | -------------------------------------------------------------------------------- /mam/wots/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "wots", 3 | srcs = ["wots.c"], 4 | hdrs = ["wots.h"], 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "//common:errors", 8 | "//mam:defs", 9 | "//mam/prng", 10 | "//mam/sponge:spongos", 11 | "//mam/trits", 12 | "//utils:memset_safe", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /mam/wots/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_wots", 3 | timeout = "short", 4 | srcs = ["test_wots.c"], 5 | visibility = ["//visibility:private"], 6 | deps = [ 7 | "//mam/wots", 8 | "@unity", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /mobile/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /mobile/android/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "jni", 3 | srcs = [ 4 | "Interface.cpp", 5 | "jni.h", 6 | ], 7 | hdrs = ["Interface.h"], 8 | linkopts = [ 9 | "-lm", 10 | "-ldl", 11 | ], 12 | deps = [ 13 | "//common/helpers", 14 | "//utils:bundle_miner", 15 | "//utils:memset_safe", 16 | ], 17 | alwayslink = True, 18 | ) 19 | 20 | android_binary( 21 | name = "dummy", 22 | srcs = [ 23 | "demo/App.java", 24 | "demo/DummyActivity.java", 25 | "java/Interface.java", 26 | ], 27 | custom_package = "org.iota.mobile", 28 | manifest = "AndroidManifest.xml", 29 | deps = [":jni"], 30 | ) 31 | -------------------------------------------------------------------------------- /mobile/android/demo/App.java: -------------------------------------------------------------------------------- 1 | package org.iota.mobile; 2 | 3 | import android.app.*; 4 | import android.util.Log; 5 | 6 | public class App extends Application { 7 | @Override 8 | public void onCreate() { 9 | super.onCreate(); 10 | System.loadLibrary("dummy"); 11 | 12 | Log.e("IOTA", "Library loaded."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mobile/android/java/Interface.java: -------------------------------------------------------------------------------- 1 | package org.iota.mobile; 2 | 3 | public class Interface { 4 | public static native String iota_pow_trytes(String trytes, int mwm); 5 | public static native String[] iota_pow_bundle(String[] bundle, String trunk, String branch, int mwm); 6 | public static native String iota_sign_address_gen_trytes(String seed, int index, int security); 7 | public static native byte[] iota_sign_address_gen_trits(byte[] seed, int index, int security); 8 | public static native String iota_sign_signature_gen_trytes(String seed, int index, int security, String bundleHash); 9 | public static native byte[] iota_sign_signature_gen_trits(byte[] seed, int index, int security, byte[] bundleHash); 10 | public static native String iota_digest(String trytes); 11 | public static native long bundle_miner_mine(byte[] bundle_normalized_max, int security, byte[] essence, int essence_length, int count, int nprocs, int mining_threshold); 12 | } 13 | -------------------------------------------------------------------------------- /mobile/ios/BUILD: -------------------------------------------------------------------------------- 1 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_static_framework") 2 | 3 | ios_static_framework( 4 | name = "ios_bindings", 5 | hdrs = ["Interface.h"], 6 | bundle_name = "EntangledKit", 7 | minimum_os_version = "9.0", 8 | deps = [":ios_bindings_classes"], 9 | ) 10 | 11 | objc_library( 12 | name = "ios_bindings_classes", 13 | srcs = ["Interface.mm"], 14 | hdrs = ["Interface.h"], 15 | deps = [ 16 | "//common/helpers", 17 | "//utils:bundle_miner", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // EntangledDemo 4 | // 5 | // 6 | // Copyright © 2018 IOTA Foundation. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property(strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo/Constants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.h 3 | // EntangledDemo 4 | // 5 | // 6 | // Copyright © 2018 IOTA Foundation. All rights reserved. 7 | // 8 | 9 | #ifndef Constants_h 10 | #define Constants_h 11 | 12 | #import 13 | 14 | extern NSString* const TX_TRYTES; 15 | extern NSString* const SEED; 16 | extern NSString* const TX_0_TRYTES; 17 | extern NSString* const TX_1_TRYTES; 18 | extern NSString* const TX_2_TRYTES; 19 | extern int8_t* SEED_TRITS[243]; 20 | extern int8_t BUNDLE_NORMALIZED_MAX[81]; 21 | 22 | #endif /* Constants_h */ 23 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // EntangledDemo 4 | // 5 | // 6 | // Copyright © 2018 IOTA Foundation. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "Constants.h" 12 | 13 | @interface ViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // EntangledDemo 4 | // 5 | // 6 | // Copyright © 2018 IOTA Foundation. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char* argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /mobile/ios/Demo/DemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /mobile/ios/Demo/DemoTests/TestConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestConstants.h 3 | // EntangledDemoTests 4 | // 5 | // 6 | // Copyright © 2018 IOTA Foundation. All rights reserved. 7 | // 8 | 9 | #ifndef TestConstants_h 10 | #define TestConstants_h 11 | 12 | #import 13 | 14 | extern NSString* const EXPECTED_NONCE; 15 | extern NSString* const EXPECTED_ADDRESS; 16 | extern NSString* const EXPECTED_SIGNATURE; 17 | 18 | #endif /* TestConstants_h */ 19 | -------------------------------------------------------------------------------- /mobile/ios/Demo/Frameworks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iotaledger-archive/entangled/c7e0052bb7000f51e7c53f9eaf3cb6f20e874b5b/mobile/ios/Demo/Frameworks/.gitkeep -------------------------------------------------------------------------------- /tanglescope/collector/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "collector", 3 | srcs = glob(["*.cpp"]), 4 | hdrs = glob(["*.hpp"]), 5 | visibility = ["//visibility:public"], 6 | deps = ["@yaml_cpp"], 7 | ) 8 | -------------------------------------------------------------------------------- /tanglescope/collector/collector.cpp: -------------------------------------------------------------------------------- 1 | #include "tanglescope/collector/collector.hpp" 2 | 3 | namespace iota { 4 | namespace tanglescope { 5 | bool CollectorBase::parseConfiguration(const YAML::Node &conf) { 6 | if (!conf) { 7 | return false; 8 | } 9 | return true; 10 | } 11 | } // namespace tanglescope 12 | } // namespace iota 13 | -------------------------------------------------------------------------------- /tanglescope/collector/collector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace iota { 7 | namespace tanglescope { 8 | 9 | class CollectorBase { 10 | public: 11 | virtual ~CollectorBase(){}; 12 | virtual void collect() = 0; 13 | virtual bool parseConfiguration(const YAML::Node& conf); 14 | }; 15 | } // namespace tanglescope 16 | } // namespace iota 17 | -------------------------------------------------------------------------------- /tanglescope/common/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "common", 3 | srcs = glob([ 4 | "*.cpp", 5 | "*.hpp", 6 | ]), 7 | hdrs = glob(["*.hpp"]), 8 | defines = [ 9 | "ZMQ_BUILD_DRAFT_API", 10 | ], 11 | include_prefix = "iota/tanglescope/common", 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//common/helpers", 15 | "//common/trinary:tryte_long", 16 | "//cppclient:beast", 17 | "@com_github_google_glog//:glog", 18 | "@cppzmq", 19 | "@iota_lib_cpp", 20 | "@libcuckoo", 21 | "@rxcpp", 22 | "@yaml_cpp", 23 | ], 24 | ) 25 | 26 | cc_test( 27 | name = "common_test", 28 | timeout = "short", 29 | srcs = ["tests/iri.cpp"], 30 | deps = [ 31 | ":common", 32 | "@com_github_gflags_gflags//:gflags", 33 | "@com_google_googletest//:gtest_main", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /tanglescope/common/iri.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "iri.hpp" 4 | 5 | namespace iota { 6 | namespace tanglescope { 7 | namespace iri { 8 | 9 | std::shared_ptr payloadToMsg(std::string_view payload) { 10 | auto idx = payload.find(' '); 11 | auto what = payload.substr(0, idx); 12 | auto actual = payload.substr(idx + 1); 13 | 14 | if (what == "tx") { 15 | return std::make_shared(actual); 16 | } else if (what == "sn") { 17 | return std::make_shared(actual); 18 | } else if (what == "lmhs") { 19 | return std::make_shared(actual); 20 | } else if (what == "lmsi") { 21 | return std::make_shared(actual); 22 | } else if (what == "rstat") { 23 | return std::make_shared(actual); 24 | } 25 | 26 | return nullptr; 27 | } 28 | } // namespace iri 29 | } // namespace tanglescope 30 | } // namespace iota 31 | -------------------------------------------------------------------------------- /tanglescope/common/tangledb.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class TangleDB { 9 | public: 10 | struct TXRecord { 11 | std::string hash; 12 | std::string trunk; 13 | std::string branch; 14 | std::chrono::system_clock::time_point timestamp; 15 | 16 | TXRecord() = default; 17 | }; 18 | 19 | nonstd::optional find(const std::string& hash); 20 | 21 | void put(const TXRecord& tx); 22 | void removeAgedTxs(uint32_t ageInSeconds); 23 | 24 | std::unordered_map getTXsMap() const; 25 | 26 | static TangleDB& instance(); 27 | 28 | private: 29 | mutable std::shared_mutex mutex_; 30 | std::unordered_map _txs; 31 | 32 | TangleDB() = default; 33 | ~TangleDB() = default; 34 | 35 | TangleDB(const TangleDB&) = delete; 36 | TangleDB& operator=(const TangleDB&) = delete; 37 | TangleDB(TangleDB&&) = delete; 38 | TangleDB& operator=(TangleDB&&) = delete; 39 | }; 40 | -------------------------------------------------------------------------------- /tanglescope/common/zmqdbloader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "tanglescope/common/iri.hpp" 11 | 12 | namespace iota { 13 | namespace tanglescope { 14 | 15 | class ZmqDBLoader { 16 | public: 17 | void start(); 18 | bool parseConfiguration(const YAML::Node& conf); 19 | 20 | constexpr static auto PUBLISHER = "publisher"; 21 | constexpr static auto OLDEST_TX_AGE = "oldest_tx_age"; 22 | constexpr static auto CLEANUP_INTERVAL = "cleanup_interval"; 23 | 24 | private: 25 | virtual void loadDB(); 26 | void cleanDBPeriodically(); 27 | 28 | std::string _zmqPublisherURL; 29 | uint32_t _oldestTXAge; 30 | uint32_t _cleanupInterval; 31 | }; 32 | 33 | } // namespace tanglescope 34 | } // namespace iota 35 | -------------------------------------------------------------------------------- /tanglescope/common/zmqpub.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "tanglescope/common/iri.hpp" 9 | 10 | namespace iota { 11 | namespace tanglescope { 12 | using ZmqObservable = rxcpp::observable>; 13 | void zmqPublisher(rxcpp::subscriber>, const std::string& uri, 14 | const std::atomic& shouldFinish = false); 15 | static std::map urlToZmqObservables; 16 | } // namespace tanglescope 17 | } // namespace iota 18 | -------------------------------------------------------------------------------- /tanglescope/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup tanglescope Tanglescope 10 | * @brief Tanglescope is a program composed of metric collectors. 11 | * 12 | * Tanglescope is a program composed of metric collectors, Each collector is responsible for a different aspect 13 | * of the Tangle behavior and collects different set of metrics and exposes them to a configurable prometheus end point. 14 | */ -------------------------------------------------------------------------------- /tanglescope/prometheus_collector/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "prometheus_collector", 3 | srcs = glob([ 4 | "*.cpp", 5 | "*.hpp", 6 | ]), 7 | hdrs = glob(["*.hpp"]), 8 | visibility = ["//visibility:public"], 9 | deps = [ 10 | "//tanglescope/collector", 11 | "@prometheus_cpp", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /tanglescope/statscollector/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "shared", 3 | srcs = glob( 4 | ["**/*.cpp"], 5 | exclude = [ 6 | "statscollector.cpp", 7 | "tests/**/*.cpp", 8 | ], 9 | ), 10 | hdrs = glob( 11 | ["**/*.hpp"], 12 | exclude = ["tests/**/*.hpp"], 13 | ), 14 | deps = [ 15 | "//tanglescope/common", 16 | "//tanglescope/prometheus_collector", 17 | "@com_github_gflags_gflags//:gflags", 18 | "@com_github_google_glog//:glog", 19 | ], 20 | ) 21 | 22 | cc_test( 23 | name = "tests", 24 | timeout = "short", 25 | srcs = glob([ 26 | "tests/**/*.cpp", 27 | "**/*.hpp", 28 | ]), 29 | deps = [ 30 | ":shared", 31 | "@com_google_googletest//:gtest_main", 32 | ], 33 | ) 34 | 35 | cc_library( 36 | name = "statscollector", 37 | srcs = ["statscollector.cpp"], 38 | hdrs = glob(["statscollector.hpp"]), 39 | visibility = ["//visibility:public"], 40 | deps = [ 41 | ":shared", 42 | "@prometheus_cpp", 43 | ], 44 | ) 45 | -------------------------------------------------------------------------------- /tanglescope/statscollector/stats/frame.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "tanglescope/common/iri.hpp" 8 | 9 | #include "stats.hpp" 10 | 11 | using namespace iota::tanglescope; 12 | 13 | namespace iota { 14 | namespace tanglescope { 15 | namespace statscollector { 16 | 17 | class FrameTXStats : public TXStats { 18 | public: 19 | FrameTXStats(uint32_t bundleConfirmationHistogramRange, uint32_t bundleConfirmationHistogramBucketSize); 20 | void trackNewTX(iri::TXMessage&, PrometheusCollector::CountersMap& counters); 21 | void trackReattachedTX(PrometheusCollector::CountersMap& counters); 22 | void trackNewBundle(PrometheusCollector::CountersMap& counters); 23 | void trackConfirmedBundle(int64_t totalValue, uint64_t size, uint64_t bundleDuration, 24 | PrometheusCollector::CountersMap& counters, PrometheusCollector::HistogramsMap& histograms); 25 | 26 | std::vector _buckets; 27 | }; 28 | } // namespace statscollector 29 | } // namespace tanglescope 30 | } // namespace iota 31 | -------------------------------------------------------------------------------- /tools/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | -------------------------------------------------------------------------------- /tools/buildifier: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | buildifier -mode=fix $(find $(git rev-parse --show-toplevel) | grep -E "WORKSPACE|BUILD(\.(bazel|bzl))?\$") 4 | -------------------------------------------------------------------------------- /tools/ci_buildifier_check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | buildifier -mode=check $(find . -type f | grep -E "WORKSPACE|BUILD(\.(bazel|bzl))?\$") 4 | -------------------------------------------------------------------------------- /tools/ci_format_check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | root=$(git rev-parse --show-toplevel) 4 | status=0 5 | for file in $(find "${@}" -type f | grep -E "\.(c|cc|cpp|h|hh|hpp)\$") 6 | do 7 | filepath="$root/$file" 8 | output=$(diff <(cat $filepath) <(clang-format -style=file -fallback-style=none $filepath)) 9 | if [ $? -ne 0 ] 10 | then 11 | echo -e "\nFile \e[31m\""$file"\"\e[39m is not compliant with the coding style" 12 | echo "$output" 13 | status=1 14 | fi 15 | done 16 | exit $status 17 | -------------------------------------------------------------------------------- /tools/ci_test_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /etc/init.d/mysql start 4 | mysql -u root < ciri/storage/sql/mariadb/setup.sql 5 | mysql -u ciri tangle < ciri/storage/sql/mariadb/tangle-schema.sql 6 | mysql -u ciri spent-addresses < ciri/storage/sql/mariadb/spent-addresses-schema.sql 7 | -------------------------------------------------------------------------------- /tools/cpplint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | root=$(git rev-parse --show-toplevel) 4 | python $root/tools/cpplint.py --linelength=120 --filter=-build/include_order,-whitespace/comments,-runtime/references --extensions=h,cc $(find $root/cppclient | grep -E "\.(cc|cpp|h|hh|hpp)\$") 5 | -------------------------------------------------------------------------------- /tools/formatter: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for file in $(find $(git rev-parse --show-toplevel) | grep -E "\.(c|cc|cpp|h|hh|hpp|m|mm)\$") 4 | do 5 | clang-format -style=file -fallback-style=none -i $file 6 | done 7 | -------------------------------------------------------------------------------- /tools/hooks/pre-commit/01-buildifier-check: -------------------------------------------------------------------------------- 1 | ../scripts/buildifier_check -------------------------------------------------------------------------------- /tools/hooks/pre-commit/02-cpplint: -------------------------------------------------------------------------------- 1 | ../scripts/cpplint -------------------------------------------------------------------------------- /tools/hooks/pre-commit/03-format-check: -------------------------------------------------------------------------------- 1 | ../scripts/format_check -------------------------------------------------------------------------------- /tools/hooks/scripts/buildifier_check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | buildifier -mode=check $(git ls-files $(git rev-parse --show-toplevel) | grep -E "WORKSPACE|BUILD(\.(bazel|bzl))?\$") 4 | -------------------------------------------------------------------------------- /tools/hooks/scripts/cpplint: -------------------------------------------------------------------------------- 1 | ../../cpplint -------------------------------------------------------------------------------- /tools/hooks/scripts/format_check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | root=$(git rev-parse --show-toplevel) 4 | status=0 5 | for file in $(git diff --staged --name-only | grep -E "\.(c|cc|cpp|h|hh|hpp)\$") 6 | do 7 | filepath="$root/$file" 8 | output=$(diff <(cat $filepath) <(clang-format -style=file -fallback-style=none $filepath)) 9 | if [ $? -ne 0 ] 10 | then 11 | echo -e "\nFile \""$file"\" is not compliant with the coding style" 12 | echo "$output" 13 | status=1 14 | fi 15 | done 16 | exit $status 17 | -------------------------------------------------------------------------------- /utils/char_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_CHAR_BUFFER_H__ 9 | #define __UTILS_CHAR_BUFFER_H__ 10 | 11 | #include 12 | 13 | #include "common/errors.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct { 20 | size_t length; 21 | char* data; 22 | } char_buffer_t; 23 | 24 | char_buffer_t* char_buffer_new(); 25 | retcode_t char_buffer_allocate(char_buffer_t* in, const size_t n); 26 | retcode_t char_buffer_set(char_buffer_t* in, char const* const str); 27 | void char_buffer_free(char_buffer_t* in); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // __UTILS_CHAR_BUFFER_H__ 34 | -------------------------------------------------------------------------------- /utils/containers/BUILD: -------------------------------------------------------------------------------- 1 | load(":map_generator.bzl", "map_generate") 2 | load(":typed_container_generator.bzl", "typed_container_generate") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | cc_library( 7 | name = "bitset", 8 | srcs = ["bitset.c"], 9 | hdrs = ["bitset.h"], 10 | ) 11 | 12 | cc_library( 13 | name = "person_example", 14 | hdrs = ["person_example.h"], 15 | deps = ["//common/trinary:flex_trit"], 16 | ) 17 | 18 | map_generate( 19 | additional_deps = [":person_example"], 20 | additional_include_path = "utils/containers/person_example.h", 21 | key_type = "person_example_t", 22 | value_type = "int", 23 | ) 24 | 25 | typed_container_generate( 26 | container_type = "set", 27 | value_type = "int", 28 | ) 29 | 30 | cc_library( 31 | name = "dummy_dep", 32 | ) 33 | -------------------------------------------------------------------------------- /utils/containers/bitset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "bitset.h" 9 | #include 10 | #include 11 | 12 | size_t bistset_required_size(size_t num_elements) { return (num_elements / (sizeof(int64_t) * 8) + 1); } 13 | 14 | void bitset_reset(bitset_t* const bitset) { 15 | if (bitset->size == 0) { 16 | return; 17 | } 18 | memset(bitset->raw_bits, 0, bitset->size * sizeof(*(bitset->raw_bits))); 19 | } 20 | 21 | bool bitset_is_set(bitset_t* const bitset, size_t pos) { 22 | bitset->bitset_integer_index = pos / (sizeof(*bitset) * 8); 23 | bitset->bitset_relative_index = pos % (sizeof(*bitset) * 8); 24 | 25 | return bitset->raw_bits[bitset->bitset_integer_index] & (1ULL << bitset->bitset_relative_index); 26 | } 27 | 28 | void bitset_set_true(bitset_t* const bitset, size_t pos) { 29 | bitset->bitset_integer_index = pos / (sizeof(*bitset) * 8); 30 | bitset->raw_bits[bitset->bitset_integer_index] |= (1ULL << pos); 31 | } 32 | -------------------------------------------------------------------------------- /utils/containers/bitset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_CONTAINERS_BITSET_H__ 9 | #define __UTILS_CONTAINERS_BITSET_H__ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct bitset_s { 20 | uint64_t* raw_bits; 21 | uint32_t bitset_integer_index; 22 | uint32_t bitset_relative_index; 23 | size_t size; 24 | } bitset_t; 25 | 26 | void bitset_reset(bitset_t* const bitset); 27 | bool bitset_is_set(bitset_t* const bitset, size_t pos); 28 | void bitset_set_true(bitset_t* const bitset, size_t pos); 29 | 30 | size_t bistset_required_size(size_t num_elements); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif // __UTILS_CONTAINERS_BITSET_H__ 37 | -------------------------------------------------------------------------------- /utils/containers/hash/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "defs", 3 | hdrs = ["defs.h"], 4 | visibility = ["//visibility:public"], 5 | ) 6 | 7 | cc_test( 8 | name = "test_hash_queue", 9 | timeout = "short", 10 | srcs = ["test_hash_queue.c"], 11 | deps = [ 12 | ":defs", 13 | "//utils/containers/hash:hash243_queue", 14 | "@unity", 15 | ], 16 | ) 17 | 18 | cc_test( 19 | name = "test_hash_stack", 20 | timeout = "short", 21 | srcs = ["test_hash_stack.c"], 22 | deps = [ 23 | ":defs", 24 | "//utils/containers/hash:hash243_stack", 25 | "@unity", 26 | ], 27 | ) 28 | 29 | cc_test( 30 | name = "test_hash_array", 31 | timeout = "short", 32 | srcs = ["test_hash_array.c"], 33 | deps = [ 34 | ":defs", 35 | "//utils/containers/hash:hash_array", 36 | "@unity", 37 | ], 38 | ) 39 | 40 | cc_test( 41 | name = "test_hash_map", 42 | timeout = "short", 43 | srcs = ["test_hash_map.c"], 44 | deps = [ 45 | ":defs", 46 | "//utils/containers/hash:hash_int64_t_map", 47 | "@unity", 48 | ], 49 | ) 50 | -------------------------------------------------------------------------------- /utils/containers/hash/tests/test_hash_map.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "common/errors.h" 9 | #include "utils/containers/hash/hash_int64_t_map.h" 10 | #include "utils/containers/hash/tests/defs.h" 11 | 12 | void test_hash_int64_t_map() { 13 | hash_to_int64_t_map_t map = NULL; 14 | hash_to_int64_t_map_entry_t* e = NULL; 15 | TEST_ASSERT(hash_to_int64_t_map_find(map, hash243_1, &e) == false); 16 | TEST_ASSERT(hash_to_int64_t_map_add(&map, hash243_1, 42) == RC_OK); 17 | TEST_ASSERT(hash_to_int64_t_map_find(map, hash243_1, &e)); 18 | hash_to_int64_t_map_free(&map); 19 | } 20 | 21 | int main(void) { 22 | UNITY_BEGIN(); 23 | 24 | RUN_TEST(test_hash_int64_t_map); 25 | 26 | return UNITY_END(); 27 | } 28 | -------------------------------------------------------------------------------- /utils/containers/person_example.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_CONTAINERS_PERSON_EXAMPLE_H__ 9 | #define __UTILS_CONTAINERS_PERSON_EXAMPLE_H__ 10 | 11 | #include 12 | #include 13 | #include 14 | #include "common/trinary/flex_trit.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef struct person_example_s { 21 | char name[128]; 22 | flex_trit_t hash[FLEX_TRIT_SIZE_243]; 23 | } person_example_t; 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif // __UTILS_CONTAINERS_PERSON_EXAMPLE_H__ 30 | -------------------------------------------------------------------------------- /utils/containers/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_map", 3 | timeout = "short", 4 | srcs = ["test_map.c"], 5 | deps = [ 6 | "//utils/containers:person_example_t_to_int_map", 7 | "//utils/containers/hash/tests:defs", 8 | "@unity", 9 | ], 10 | ) 11 | 12 | cc_test( 13 | name = "test_set", 14 | timeout = "short", 15 | srcs = ["test_set.c"], 16 | deps = [ 17 | "//utils/containers:int_set", 18 | "@unity", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /utils/containers/tests/test_set.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include 9 | #include 10 | #include "utils/containers/int_set.h" 11 | 12 | void test_ints_set() { 13 | int_set_t set = NULL; 14 | for (int i = 0; i < 100; ++i) { 15 | int_set_add(&set, &i); 16 | } 17 | 18 | for (int i = 0; i < 100; ++i) { 19 | int_set_add(&set, &i); 20 | } 21 | 22 | TEST_ASSERT_EQUAL_INT(int_set_size(set), 100); 23 | 24 | for (int i = 0; i < 100; ++i) { 25 | TEST_ASSERT(int_set_contains(set, &i)); 26 | } 27 | 28 | int_set_free(&set); 29 | } 30 | 31 | int main(void) { 32 | UNITY_BEGIN(); 33 | 34 | RUN_TEST(test_ints_set); 35 | 36 | return UNITY_END(); 37 | } 38 | -------------------------------------------------------------------------------- /utils/doxy.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | /** 9 | * @defgroup utils Utils 10 | * @brief utils. 11 | * 12 | * TODO 13 | */ -------------------------------------------------------------------------------- /utils/export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_EXPORT_H_ 9 | #define __UTILS_EXPORT_H_ 10 | 11 | #if defined(_MSC_VER) 12 | #define IOTA_EXPORT __declspec(dllexport) 13 | #elif defined(__GNUC__) 14 | #define IOTA_EXPORT __attribute__((visibility("default"))) 15 | #else 16 | #define IOTA_EXPORT 17 | #warning Unknown dynamic link import / export semantics. 18 | #endif 19 | 20 | #endif // __UTILS_EXPORT_H_ 21 | -------------------------------------------------------------------------------- /utils/forced_inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_FORCED_INLINE_H__ 9 | #define __UTILS_FORCED_INLINE_H__ 10 | 11 | #if defined(_MSC_VER) 12 | #define FORCED_INLINE __forceinline 13 | #elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 14 | #define FORCED_INLINE __attribute__((always_inline)) inline 15 | #else 16 | #define FORCED_INLINE inline 17 | #endif 18 | 19 | #endif // __UTILS_FORCED_INLINE_H__ 20 | -------------------------------------------------------------------------------- /utils/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_MACROS_H__ 9 | #define __UTILS_MACROS_H__ 10 | 11 | #if defined(_WIN32) 12 | #include "utils/windows.h" 13 | #else 14 | #include 15 | #endif 16 | 17 | #include 18 | 19 | #ifndef UNUSED 20 | #define UNUSED(...) (void)(__VA_ARGS__) 21 | #endif 22 | 23 | #ifndef MAX 24 | #define MAX(x, y) (((x) > (y)) ? (x) : (y)) 25 | #endif 26 | 27 | #ifndef MIN 28 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) 29 | #endif 30 | 31 | #ifndef htonll 32 | #if __BIG_ENDIAN__ 33 | #define htonll(x) (x) 34 | #define ntohll(x) (x) 35 | #else 36 | #define htonll(x) (((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32)) 37 | #define ntohll(x) (((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32)) 38 | #endif 39 | #endif 40 | 41 | // max uint64 18446744073709551616 42 | #define MAX_CHARS_UINT64 20 43 | 44 | #endif // __UTILS_MACROS_H__ 45 | -------------------------------------------------------------------------------- /utils/memset_safe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #include "utils/memset_safe.h" 9 | 10 | #define __STDC_WANT_LIB_EXT1__ 1 11 | #include 12 | #include 13 | #include 14 | 15 | int memset_safe(void *dest, size_t destsz, int ch, size_t count) { 16 | #ifdef __STDC_LIB_EXT1__ 17 | return memset_s(dest, destsz, ch, count); 18 | #else 19 | if (dest == NULL) { 20 | return EINVAL; 21 | } else if (destsz > SIZE_MAX || count > SIZE_MAX) { 22 | return E2BIG; 23 | } else if (count > destsz) { 24 | return EOVERFLOW; 25 | } 26 | 27 | volatile unsigned char *ptr = (volatile unsigned char *)dest; 28 | while (destsz-- && count--) { 29 | *ptr++ = ch; 30 | } 31 | 32 | return 0; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /utils/memset_safe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_MEMSET_SAFE_H__ 9 | #define __UTILS_MEMSET_SAFE_H__ 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int memset_safe(void *dest, size_t destsz, int ch, size_t count); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif // __UTILS_MEMSET_SAFE_H__ 24 | -------------------------------------------------------------------------------- /utils/system.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifdef _WIN32 9 | #include "utils/windows.h" 10 | #elif MACOS 11 | #include 12 | #include 13 | #else 14 | #include 15 | #endif 16 | 17 | size_t system_cpu_available() { 18 | #ifdef WIN32 19 | SYSTEM_INFO sysinfo; 20 | GetSystemInfo(&sysinfo); 21 | return sysinfo.dwNumberOfProcessors; 22 | #elif MACOS 23 | int nm[2]; 24 | size_t len = 4; 25 | uint32_t count = 0; 26 | 27 | nm[0] = CTL_HW; 28 | nm[1] = HW_AVAILCPU; 29 | sysctl(nm, 2, &count, &len, NULL, 0); 30 | 31 | if (count < 1) { 32 | nm[1] = HW_NCPU; 33 | sysctl(nm, 2, &count, &len, NULL, 0); 34 | if (count < 1) { 35 | count = 1; 36 | } 37 | } 38 | return count; 39 | #else 40 | long count = sysconf(_SC_NPROCESSORS_ONLN); 41 | return count < 1 ? 1 : count; 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /utils/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_SYSTEM_H 9 | #define __UTILS_SYSTEM_H 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * @return The number of available processor cores 19 | **/ 20 | size_t system_cpu_available(); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif // __UTILS_SYSTEM_H 27 | -------------------------------------------------------------------------------- /utils/tests/BUILD: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test_bundle_miner", 3 | timeout = "long", 4 | srcs = ["test_bundle_miner.c"], 5 | deps = 6 | [ 7 | "//common/crypto/iss:normalize", 8 | "//common/trinary:trit_tryte", 9 | "//common/trinary:trits", 10 | "//common/trinary:tryte", 11 | "//utils:bundle_miner", 12 | "@unity", 13 | ], 14 | ) 15 | 16 | cc_test( 17 | name = "test_merkle", 18 | timeout = "long", 19 | srcs = ["test_merkle.c"], 20 | deps = 21 | [ 22 | "//common/trinary:trit_tryte", 23 | "//utils:merkle", 24 | "@unity", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /utils/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_TIME_H__ 9 | #define __UTILS_TIME_H__ 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | uint64_t current_timestamp_ms(); 18 | void sleep_ms(uint64_t milliseconds); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif // __UTILS_TIME_H__ 25 | -------------------------------------------------------------------------------- /utils/windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 IOTA Stiftung 3 | * https://github.com/iotaledger/entangled 4 | * 5 | * Refer to the LICENSE file for licensing information 6 | */ 7 | 8 | #ifndef __UTILS_WINDOWS_H__ 9 | #define __UTILS_WINDOWS_H__ 10 | 11 | #define _WINSOCKAPI_ // stops windows.h including winsock.h 12 | #include 13 | #include 14 | 15 | #endif // __UTILS_WINDOWS_H__ 16 | --------------------------------------------------------------------------------