{"id":26665310,"url":"https://github.com/elsehow/garage-door-opener","last_synced_at":"2025-04-11T21:42:58.294Z","repository":{"id":57244409,"uuid":"42826383","full_name":"elsehow/garage-door-opener","owner":"elsehow","description":"implementing a rolling code in javascript","archived":false,"fork":false,"pushed_at":"2015-09-21T22:01:04.000Z","size":152,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T22:36:47.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/elsehow.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}},"created_at":"2015-09-20T19:31:16.000Z","updated_at":"2023-09-03T16:11:39.000Z","dependencies_parsed_at":"2022-09-01T06:30:27.934Z","dependency_job_id":null,"html_url":"https://github.com/elsehow/garage-door-opener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fgarage-door-opener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fgarage-door-opener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fgarage-door-opener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elsehow%2Fgarage-door-opener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elsehow","download_url":"https://codeload.github.com/elsehow/garage-door-opener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248486873,"owners_count":21112183,"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":[],"created_at":"2025-03-25T17:36:47.683Z","updated_at":"2025-04-11T21:42:58.271Z","avatar_url":"https://github.com/elsehow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# garage door opener\n\nexperiments in building a [rolling code](https://en.wikipedia.org/wiki/Rolling_code) in javascript\n\nhave you ever thought about how garage door openers work? or keyless entries into cars? if someone's standing by you while you unlock your lexus, couldn't an eavesdropper record the signal coming out of your key, and replay this signal later to unlock your car?\n\nwith the magic of rolling codes, we can send differnet messages (or messages over different frequencies) with each press of the button - and coordinate which key to send/listen for without trading keys often.\n\nby transmitting a single, shared key one time, a sender can identify herself to a receiver a number of times over a potentially public channel.\n\nrolling codes are amazingly simple. by relying on the fact that two, identical pseudorandom number generators will spit out the same numbers given the same seed, you and i can use a seed as our shared secret, then build a list of identical numbers independently. we can use these numbers to identify ourselves to one another. to an eavesdropper (someone who doesn't know our seed), the numbers we use will look perfectly random.*\n\n*assuming a [cryptographically secure PRNG](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator). we use the [Mersenne Twister](https://en.wikipedia.org/wiki/Mersenne_Twister) implemented in [random-js](https://www.npmjs.com/package/random-js).\n\n# usage\n\nuse garage-door-opener to create a sender or a receiver:\n\n```javascript\nvar garagedoor = require('garage-door-opener')\nvar my_seed    = 59823\n\ns = garagedoor.sender(my_seed, 43)\nr = garagedoor.receiver(my_seed, 43)\n\n// sender generates the next random key\ncode_to_send = s.next()\n// receiver makes sure this key looks good\nr.check(code_to_send)\n// \u003e True\n\n// works even if receiver misses a few messages from sender (up to 255)\ns.next()\ns.next()\nr.check(s.next())\n// \u003e True\n\n// good luck guessing codes if you don't know the seed!\nr.check(5326294)\n// \u003e False\n```\n\nSee examples/dnode_example.js for a more complete simulation.\n\n# API\n\n### sender\n\n`sender(seed, start_i)`\n\nTakes a seed (a 32-bit integer) and a code index to start at (0 by default).\n\nReturns an object with the method `next()`, which returns the next key in its buffer.\n\n### receiver\n\n`receiver(seed, start_i)`\n\nTakes a seed (a 32-bit integer) and a code index to start at (0 by default).\n\nReturns an object with the method `check(code)`, which returns True or False depending on whether the code matches authentication criteria.\n\n# installation\n\nwith npm do:\n\n`npm install garage-door-opener`\n\n# developing\n \nfirst, `npm install`\n\nthen, `npm test`\n\n# license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsehow%2Fgarage-door-opener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felsehow%2Fgarage-door-opener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felsehow%2Fgarage-door-opener/lists"}