{"id":21107480,"url":"https://github.com/cjhdev/ruby_olm","last_synced_at":"2025-07-08T16:31:44.299Z","repository":{"id":56893612,"uuid":"159545621","full_name":"cjhdev/ruby_olm","owner":"cjhdev","description":"Ruby wrapper for olm double ratchet implementation","archived":false,"fork":false,"pushed_at":"2019-07-26T13:18:34.000Z","size":451,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-27T07:55:27.243Z","etag":null,"topics":["double-ratchet-algorithm","olm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjhdev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-28T18:18:36.000Z","updated_at":"2020-05-15T22:11:09.000Z","dependencies_parsed_at":"2022-08-21T01:20:17.780Z","dependency_job_id":null,"html_url":"https://github.com/cjhdev/ruby_olm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cjhdev/ruby_olm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fruby_olm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fruby_olm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fruby_olm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fruby_olm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjhdev","download_url":"https://codeload.github.com/cjhdev/ruby_olm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fruby_olm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264304603,"owners_count":23587991,"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":["double-ratchet-algorithm","olm"],"created_at":"2024-11-20T00:40:09.488Z","updated_at":"2025-07-08T16:31:43.852Z","avatar_url":"https://github.com/cjhdev.png","language":"C","readme":"ruby_olm\n========\n\nA Ruby wrapper for the [olm](https://git.matrix.org/git/olm/) \ndouble ratchet implementation from [matrix](https://matrix.org/blog/home/).\n\nThis wrapper provides classes and methods that line up with\nthe [olm](ext/ruby_olm/ext_lib_olm/olm/include/olm/olm.h) interface, as\nwell as a set of helpers and short aliases.\n\nVery much a work in progress.\n\n[![Build Status](https://travis-ci.org/cjhdev/ruby_olm.svg?branch=master)](https://travis-ci.org/cjhdev/ruby_olm)\n\n## Installation\n\nThe gem name is 'ruby_olm'. The target\nneeds to be able to build native extensions.\n\nOnce installed, require as:\n\n~~~ ruby\nrequire 'ruby_olm'\n~~~\n\nIf using locally (i.e. you check out this repository) you may\nneed to manually compile and clean the extensions like this:\n\n~~~ console\nbundle exec rake compile\nbundle exec rake clean\n~~~\n\n## Characteristics\n\n- Interfaces are not thread safe\n- Olm always encodes binary as base64\n- Account is unlikely to scale for a large number of one-time-keys\n\n## Example\n\nAlice wants to send a message to Bob:\n\n~~~ ruby\nrequire 'ruby_olm'\n\ninclude RubyOlm\n\nalice = Account.new\nbob = Account.new\n\n# Alice wants to send a message to Bob\nalice_msg = \"hi bob\"\n\n# Bob generates a one-time-key\nbob.gen_otk\n\n# Alice must have Bob's identity and one-time-key to make a session\nalice_session = alice.outbound_session(bob.ik['curve25519'], bob.otk['curve25519'].values.first)\n\n# Bob marks all one-time-keys as published\nbob.mark_otk\n\n# Alice can encrypt\nencrypted = alice_session.encrypt(alice_msg)\nassert_instance_of PreKeyMessage, encrypted\n\n# Bob can create a session from this first message\nbob_session = bob.inbound_session(encrypted)\n\n# Bob can now update his list of marked otk (since he knows one has been used)\nbob.update_otk(bob_session)\n\n# Bob can decrypt Alice's message\nbob_msg = bob_session.decrypt(encrypted)\n\nassert_equal alice_msg, bob_msg\n\n# At this point Bob has received but Alice hasn't\nassert bob_session.has_received?\nrefute alice_session.has_received?\n\n# Bob can send messages back to Alice    \nbob_msg = \"hi alice\"\n\nencrypted = bob_session.encrypt(bob_msg)\nassert_instance_of Message, encrypted\n\nalice_msg = alice_session.decrypt(encrypted)\n\nassert_equal alice_msg, bob_msg \n~~~\n\nAccount and Session instances can be serialised and deserialised \nusing the `#to_pickle` and `::from_pickle` methods. This is handy\nfor saving and restoring state: \n\n~~~ ruby\n# save\nalice_saved_account = Alice.to_pickle\nalice_saved_session = alice_session.to_pickle\n\n# restore\nAccount.from_pickle(alice_saved_account)\nSession.from_pickle(alice_saved_session)\n~~~\n\n## Running Tests\n\n~~~ console\nbundle exec rake test\n~~~\n\n## Todo\n\n- documentation\n- more testing\n- add support for megolm\n- replace built-in olm crypto with Ruby openssl\n\n## What is an Olm?\n\n[https://en.wikipedia.org/wiki/Olm](https://en.wikipedia.org/wiki/Olm).\n\n## License\n\nApache 2.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjhdev%2Fruby_olm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjhdev%2Fruby_olm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjhdev%2Fruby_olm/lists"}