{"id":29671691,"url":"https://github.com/azuchi/oblivious-transfer","last_synced_at":"2025-08-07T18:38:26.038Z","repository":{"id":301275641,"uuid":"1008694140","full_name":"azuchi/oblivious-transfer","owner":"azuchi","description":"Ruby binding for libOTe.","archived":false,"fork":false,"pushed_at":"2025-06-26T04:26:18.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-26T05:27:15.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/azuchi.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,"zenodo":null},"funding":{"github":"azuchi"}},"created_at":"2025-06-26T00:34:08.000Z","updated_at":"2025-06-26T04:26:22.000Z","dependencies_parsed_at":"2025-06-26T05:37:30.806Z","dependency_job_id":null,"html_url":"https://github.com/azuchi/oblivious-transfer","commit_stats":null,"previous_names":["azuchi/libote-ruby","azuchi/oblivious-transfer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/azuchi/oblivious-transfer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azuchi%2Foblivious-transfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azuchi%2Foblivious-transfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azuchi%2Foblivious-transfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azuchi%2Foblivious-transfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azuchi","download_url":"https://codeload.github.com/azuchi/oblivious-transfer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azuchi%2Foblivious-transfer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266567158,"owners_count":23949297,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-07-22T20:30:57.245Z","updated_at":"2025-07-22T20:32:51.894Z","avatar_url":"https://github.com/azuchi.png","language":"Ruby","funding_links":["https://github.com/sponsors/azuchi"],"categories":[],"sub_categories":[],"readme":"# OT\n\nPure Ruby implementation of Oblivious Transfer (OT) protocols. This library provides both basic 1-out-of-2 Oblivious Transfer and OT Extension implementations for efficient batch operations.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'oblivious-transfer', require: 'ot'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install oblivious-transfer\n\n## Usage\n\n### Simple 1-out-of-2 Oblivious Transfer\n\nThe simplest way to use the library is with the `simple_ot` method:\n\n```ruby\nrequire 'ot'\n\n# Messages for the OT protocol\nmessage0 = \"Secret message 0\"\nmessage1 = \"Secret message 1\"\n\n# Receiver chooses which message to receive (0 or 1)\nchoice = 1\n\n# Perform the OT protocol\nchosen_message = OT.simple_ot(message0, message1, choice)\nputs chosen_message  # =\u003e \"Secret message 1\"\n```\n\n### RSA-based OT (Recommended)\n\nFor more control, you can use the RSA-based implementation directly:\n\n```ruby\nrequire 'ot'\n\n# Create sender and receiver\nsender = OT.simple_sender\nreceiver = OT.simple_receiver(1)  # choice = 1\n\n# Sender sets the two messages\nsender.set_messages(\"First option\", \"Second option\")\n\n# Protocol execution\nsender_public_key = sender.public_key\nblinding_values = receiver.generate_blinding_values(sender_public_key)\nsender_response = sender.encrypt_messages(blinding_values[:x0], blinding_values[:x1])\nchosen_message = receiver.decrypt_message(sender_response)\n\nputs chosen_message  # =\u003e \"Second option\"\n```\n\n### Elliptic Curve-based OT\n\nThe library also includes an elliptic curve implementation:\n\n```ruby\nrequire 'ot'\n\n# Create sender and receiver\nsender = OT.sender\nreceiver = OT.receiver(0)  # choice = 0\n\n# Sender sets the two messages\nsender.set_messages(\"Option A\", \"Option B\")\n\n# Protocol execution\nsender_params = sender.generate_parameters\nreceiver_public_key = receiver.generate_public_key(sender_params)\nsender_response = sender.process_choice(receiver_public_key, {})\nchosen_message = receiver.decrypt_message(sender_response)\n\nputs chosen_message  # =\u003e \"Option A\"\n```\n\n### OT Extension (Batch OT)\n\nFor efficient batch operations, use OT Extension which allows performing many OTs with the cost of only a few base OTs:\n\n```ruby\nrequire 'ot'\n\n# Prepare multiple message pairs\nmessage_pairs = [\n  [\"Database record 1A\", \"Database record 1B\"],\n  [\"Database record 2A\", \"Database record 2B\"],\n  [\"Database record 3A\", \"Database record 3B\"],\n  [\"Database record 4A\", \"Database record 4B\"]\n]\n\n# Receiver's choices for each pair\nchoices = [0, 1, 0, 1]\n\n# Perform batch OT extension\nresults = OT.extension(message_pairs, choices)\n\nputs results[0]  # =\u003e \"Database record 1A\" (choice 0)\nputs results[1]  # =\u003e \"Database record 2B\" (choice 1)\nputs results[2]  # =\u003e \"Database record 3A\" (choice 0)\nputs results[3]  # =\u003e \"Database record 4B\" (choice 1)\n```\n\n#### Advanced OT Extension Usage\n\n```ruby\nrequire 'ot'\n\n# Create sender and receiver for manual control\nsender = OT.extension_sender\nreceiver = OT.extension_receiver([0, 1, 0])\n\n# Set up the message pairs\nmessage_pairs = [\n  [\"Option 1A\", \"Option 1B\"],\n  [\"Option 2A\", \"Option 2B\"], \n  [\"Option 3A\", \"Option 3B\"]\n]\nsender.set_message_pairs(message_pairs)\n\n# Execute the extension protocol\nreceiver_choices = receiver.get_choices\nsender_response = sender.extend_ots(receiver_choices)\nresults = receiver.receive_extended_ots(sender_response)\n\nputs results  # =\u003e [\"Option 1A\", \"Option 2B\", \"Option 3A\"]\n```\n\n## How Oblivious Transfer Works\n\n1-out-of-2 Oblivious Transfer allows a receiver to obtain one of two messages from a sender, without the sender learning which message was chosen, and without the receiver learning anything about the other message.\n\n### Security Properties\n\n- **Receiver Privacy**: The sender doesn't learn which message (0 or 1) the receiver chose\n- **Sender Privacy**: The receiver only learns the chosen message, nothing about the other message\n- **Correctness**: The receiver always gets the correct message for their choice\n\n## Implementation Details\n\nThis library provides multiple OT implementations:\n\n### Basic OT Implementations\n\n#### RSA-based Implementation (`SimpleOT`)\n- Uses RSA encryption with 2048-bit keys\n- Based on the classic RSA-based OT protocol\n- Default implementation used by `OT.simple_ot()`\n- More straightforward and reliable\n\n#### Elliptic Curve Implementation (`ObliviousTransfer`)\n- Uses Curve25519 elliptic curve cryptography\n- Custom elliptic curve point and scalar arithmetic\n- Alternative implementation for educational purposes\n\n### OT Extension Implementation (`Extension`)\n\nThe OT extension allows performing many OTs efficiently:\n\n- **Based on**: IKNP (Ishai-Kilian-Nissim-Petrank) OT extension\n- **Security Parameter**: 128 base OTs for security\n- **Correlation-Robust Hash**: SHA256-based hash function\n- **Efficiency**: O(n) communication for n OTs vs O(n·k) for n independent base OTs\n\n#### Key Features:\n- **Batch Processing**: Handle thousands of OTs efficiently\n- **Scalability**: Linear cost in the number of OTs\n- **Security**: Maintains the same security properties as base OT\n- **Flexibility**: Works with any secure base OT implementation\n\n#### Use Cases:\n- Private Set Intersection (PSI)\n- Multi-Party Computation (MPC)  \n- Private Information Retrieval (PIR)\n- Secure Database Queries\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Testing\n\nRun the test suite with:\n\n```bash\nbundle exec rspec\n```\n\n## Security Notice\n\nThis implementation is for educational and research purposes. For production use, please ensure proper security review and consider using established cryptographic libraries.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazuchi%2Foblivious-transfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazuchi%2Foblivious-transfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazuchi%2Foblivious-transfer/lists"}