{"id":16863780,"url":"https://github.com/nazar-pc/ronion","last_synced_at":"2025-03-18T16:39:26.864Z","repository":{"id":143798653,"uuid":"104220716","full_name":"nazar-pc/ronion","owner":"nazar-pc","description":"Generic anonymous routing protocol framework agnostic to encryption algorithm and transport layer","archived":false,"fork":false,"pushed_at":"2018-06-16T00:42:55.000Z","size":180,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T15:18:07.217Z","etag":null,"topics":["anonymous","mix-network","onion","p2p","routing","tor"],"latest_commit_sha":null,"homepage":"","language":"LiveScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nazar-pc.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-20T13:43:04.000Z","updated_at":"2024-12-13T15:01:08.000Z","dependencies_parsed_at":"2023-05-18T00:45:56.632Z","dependency_job_id":null,"html_url":"https://github.com/nazar-pc/ronion","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fronion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fronion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fronion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fronion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nazar-pc","download_url":"https://codeload.github.com/nazar-pc/ronion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244261483,"owners_count":20424946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anonymous","mix-network","onion","p2p","routing","tor"],"created_at":"2024-10-13T14:39:42.620Z","updated_at":"2025-03-18T16:39:26.841Z","avatar_url":"https://github.com/nazar-pc.png","language":"LiveScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ronion [![Travis CI](https://img.shields.io/travis/nazar-pc/ronion/master.svg?label=Travis%20CI)](https://travis-ci.org/nazar-pc/ronion)\nGeneric anonymous routing protocol framework agnostic to encryption algorithm and transport layer.\n\nThis repository contains high level design overview (design.md), specification for implementors (spec.md) and reference implementation.\n\nWARNING: INSECURE UNTIL PROVEN THE OPPOSITE!!!\n\nThis protocol and reference implementation are intended to be secure, but until proper independent audit is conducted you shouldn't consider it to actually be secure and shouldn't use in production applications.\n\n## Current status\nSpecification and design are not finalized yet, but seem good already.\n\nImplementation API should be near stable and unlikely to change unless major spec changes are needed.\n\nStill considered unstable, so be careful and make sure to report any issues you encounter. Project is covered with tests though to ensure it works as intended (see `tests` directory).\n\n## How to install\n```\nnpm install ronion\n```\n\n## How to use\nNode.js:\n```javascript\nvar ronion = require('ronion')\n\n// Do stuff\n```\nBrowser:\n```javascript\nrequirejs(['ronion'], function (ronion) {\n    // Do stuff\n})\n```\n\n## Implementation API\nBelow if the list of public interfaces (constructors, methods and events) that are available.\nTests in `tests` directory can be used as an additional source of usage examples (not necessarily secure though!).\n\n#### Ronion(version : number, packet_size : number, address_length : number, mac_length : number, max_pending_segments = 10 : number) : Ronion\nConstructor used to create Ronion instance.\n\nWill only process packets with specified version of specified size (will ignore others), expects fixed-size address and MAC length.\n\n* `version` - Application-specific version `0..255`\n* `packet_size` - Packets will always have exactly this size\n* `address_length` - Length of the node address\n* `mac_length` - Length of the MAC that is added to ciphertext during encryption\n* `max_pending_segments` - How much segments can be in pending state per one address (defaults to 10)\n\n#### Ronion.process_packet(address : Uint8Array, packet : Uint8Array)\nProcesses incoming packet.\n\n* `address` - Address of the node where packet comes from\n* `packet` - Packet itself\n\n#### Ronion.create_request(address : Uint8Array, command_data : Uint8Array) : Uint8Array\nGenerates packet with `CREATE_REQUEST` command in order to create the first segment in routing path.\n\nThis method can be called multiple times, in case of Noise NK handshake `command_data` will contain handshake message.\n\n* `address` - Address of the first node in the routing path\n* `command_data` - Data that are needed to be exchanged with `address` node in order to establish a segment\n\nMethod returns `segment_id` that together with `address` is used to identify the routing path.\n\n#### Ronion.confirm_outgoing_segment_established(address : Uint8Array, segment_id : Uint8Array)\nConfirms that the first segment of routing path was established after sending `CREATE_REQUEST` and receiving `CREATE_RESPONSE`.\n\n* `address` - Address used in `Ronion.create_request` method\n* `segment_id` - Segment ID returned by `Ronion.create_request` method\n\n#### Ronion.create_response(address : Uint8Array, segment_id : Uint8Array, command_data : Uint8Array) : Uint8Array\nGenerates packet with `CREATE_RESPONSE` command as an answer to `CREATE_REQUEST` command.\n\nThis method is called exactly once in response to each `CREATE_REQUEST`.\n\n* `address` - Address of the node where `CREATE_REQUEST` come from\n* `segment_id` - Segment ID sent with `CREATE_REQUEST`\n* `command_data` - Data that are needed to be exchanged with `address` node in order to establish a segment\n\n#### Ronion.confirm_incoming_segment_established(address : Uint8Array, segment_id : Uint8Array)\nConfirms that the segment of routing path with `address` was established after receiving `CREATE_REQUEST` and sending `CREATE_RESPONSE`.\n\n* `address` - Address used in `Ronion.create_response` method\n* `segment_id` - Segment ID used in `Ronion.create_response` method\n\n#### Ronion.extend_request(address : Uint8Array, segment_id : Uint8Array, next_node_address : Uint8Array, command_data : Uint8Array)\nExtends routing path by one more segment to `next_node_address` (generates packet with `EXTEND_REQUEST` command to the last node in routing path).\n\nThis method can be called multiple times, in case of Noise NK handshake `command_data` will contain handshake message.\n\n* `address` - Address used in `Ronion.create_request` method\n* `segment_id` - Segment ID returned by `Ronion.create_request` method\n* `next_node_address` - Address of the node where routing path should be extended\n* `command_data` - Data that are needed to be exchanged with `next_node_address` node in order to establish a segment (subtract address length from max command data length, since `next_node_address` will be prepended)\n\n#### Ronion.confirm_extended_path(address : Uint8Array, segment_id : Uint8Array)\nConfirms that the routing path was extended by one more segment successfully.\n\n* `address` - Address used in `Ronion.create_request` method\n* `segment_id` - Segment ID returned by `Ronion.create_request` method\n\n#### Ronion.destroy(address : Uint8Array, segment_id : Uint8Array)\nRemoves any mapping that uses specified address and segment ID, considers connection to be destroyed.\n\n* `address` - Address used in `Ronion.create_request` method\n* `segment_id` - Segment ID returned by `Ronion.create_request` method\n\n#### Ronion.data(address : Uint8Array, segment_id : Uint8Array, target_address : Uint8Array, command : number, command_data : Uint8Array)\nSend `command_data` data to the `target_address` node on routing path.\n\n* `address` - Address used in `Ronion.create_request` method\n* `segment_id` - Segment ID returned by `Ronion.create_request` method\n* `target_address` - Address of the node in routing path which should receive data\n* `command` - Command that can be later interpreted by application layer (from range `0..245`)\n* `command_data` - Data being sent\n\n#### Ronion.get_max_command_data_length() : number\nReturns maximum number of bytes that `command_data` in other methods might contain.\n\n#### Ronion.on(event: string, callback: Function) : Ronion\nRegister event handler.\n\n#### Ronion.once(event: string, callback: Function) : Ronion\nRegister one-time event handler (just `on()` + `off()` under the hood).\n\n#### Ronion.off(event: string[, callback: Function]) : Ronion\nUnregister event handler.\n\n#### Event: activity\nPayload consists of two `Uint8Array` arguments: `address` and `segment_id`.\n\nEvent is fired when packet is sent/received from/to `address` with segment ID `segment_id`.\n\nThis event can be used to track when packets are flowing on certain `address` and `segment_id` and decide when to consider routing path as inactive and destroy it.\n\n#### Event: send\nPayload consists of two `Uint8Array` arguments: `address` and `packet`.\n\nEvent is fired when `packet` needs to be sent to `address` node.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure.\n\n#### Event: create_request\nPayload consists of three `Uint8Array` arguments: `address`, `segment_id` and `command_data`.\n\nEvent is fired when `CREATE_REQUEST` command was received from `address` with segment ID `segment_id`. `command_data` contains the data that were specified during `Ronion.create_request` method call on `address`.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure.\n\n#### Event: create_response\nPayload consists of three `Uint8Array` arguments: `address`, `segment_id` and `command_data`.\n\nEvent is fired when `CREATE_RESPONSE` command was received from `address` with segment ID `segment_id`. `command_data` contains the data that were specified during `Ronion.create_response` method call on `address`.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure.\n\n#### Event: extend_response\nPayload consists of three `Uint8Array` arguments: `address`, `segment_id` and `command_data`.\n\nEvent is fired when `EXTEND_RESPONSE` command was received from `address` with segment ID `segment_id` as an answer to `Ronion.extend_request` method call. `command_data` contains the data that were specified by the node `next_node_address` from `Ronion.extend_request` method call.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure.\n\n#### Event: data\nPayload consists of five arguments, all of which except `command` are `Uint8Array`: `address`, `segment_id`, `target_address`, `command` and `command_data`.\n\nEvent is fired when `DATA` command was received from `address` with segment ID `segment_id`. `command` is application-defined command and `command_data` contains data being sent to this node. `target_address` shows where data came from (useful on initiator side).\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure.\n\n#### Event: encrypt\nPayload object (all properties are `Uint8Array`):\n```javascript\n{address, segment_id, target_address, plaintext, ciphertext : null}\n```\nEvent is fired when `plaintext` from payload needs to be encrypted for node `target_address` on the routing path that starts with `address` and segment ID `segment_id`.\n\nCiphertext upon successful encryption should be placed into `ciphertext` property of the payload.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure. Any errors thrown in even handler will be silently ignored.\n\n#### Event: decrypt\nPayload object (all properties are `Uint8Array`):\n```javascript\n{address, segment_id, target_address, ciphertext, plaintext : null}\n```\nEvent is fired when `ciphertext` from payload needs to be decrypted as if it comes from node `target_address` on the routing path that starts with `address` and segment ID `segment_id`.\n\nPlaintext upon successful decryption should be placed into `plaintext` property of the payload.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure. Any errors thrown in even handler will be silently ignored.\n\n#### Event: wrap\nPayload object (all properties are `Uint8Array`):\n```javascript\n{address, segment_id, target_address, unwrapped, wrapped : null}\n```\nEvent is fired when `unwrapped` from payload needs to be wrapped (encrypted without authentication) for node `target_address` on the routing path that starts with `address` and segment ID `segment_id`.\n\nWrapped ciphertext upon successful wrapping should be placed into `wrapped` property of the payload.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure. Any errors thrown in even handler will be silently ignored.\n\n#### Event: unwrap\nPayload object (all properties are `Uint8Array`):\n```javascript\n{address, segment_id, target_address, wrapped, unwrapped : null}\n```\nEvent is fired when `wrapped` from payload needs to be unwrapped (decrypted without authentication) as if it comes from node `target_address` on the routing path that starts with `address` and segment ID `segment_id`.\n\nUnwrapped ciphertext upon successful unwrapping should be placed into `unwrapped` property of the payload.\n\n`false` or `Promise.reject()` can be returned from event handler in order to indicate non-fatal failure. Any errors thrown in even handler will be silently ignored.\n\n## Contribution\nFeel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!\n\nWhen reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.\n\n## License\nImplementation: Free Public License 1.0.0 / Zero Clause BSD License\n\nhttps://opensource.org/licenses/FPL-1.0.0\n\nhttps://tldrlegal.com/license/bsd-0-clause-license\n\nSpecification and design: public domain\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazar-pc%2Fronion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnazar-pc%2Fronion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazar-pc%2Fronion/lists"}