{"id":18556800,"url":"https://github.com/urbit/up8-ticket","last_synced_at":"2025-06-27T18:11:11.631Z","repository":{"id":57387049,"uuid":"297799030","full_name":"urbit/up8-ticket","owner":"urbit","description":"Securely generate UP8 master tickets.","archived":false,"fork":false,"pushed_at":"2020-09-25T14:39:09.000Z","size":74,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-09T19:04:29.901Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2020-09-22T23:40:48.000Z","updated_at":"2022-06-20T08:00:18.000Z","dependencies_parsed_at":"2022-08-30T23:10:34.639Z","dependency_job_id":null,"html_url":"https://github.com/urbit/up8-ticket","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/urbit/up8-ticket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fup8-ticket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fup8-ticket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fup8-ticket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fup8-ticket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbit","download_url":"https://codeload.github.com/urbit/up8-ticket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbit%2Fup8-ticket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262308095,"owners_count":23291097,"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":"2024-11-06T21:33:23.465Z","updated_at":"2025-06-27T18:11:11.588Z","avatar_url":"https://github.com/urbit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# up8-ticket\n\n[![Build Status](https://secure.travis-ci.org/urbit/up8-ticket.png)](http://travis-ci.org/urbit/up8-ticket)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![npm](https://img.shields.io/npm/v/up8-ticket.svg)](https://www.npmjs.com/package/up8-ticket)\n\nSecurely generate [UP8][up8p]-compatible, `@q`-encoded master tickets.  Split\nand combine tickets via a k/n Shamir's Secret Sharing scheme.\n\nIf you plan on generating a master ticket for a galaxy wallet, for example, you\nmight want to use `gen_ticket_drbg(384)` to generate the ticket, and then\n`shard(.., 5, 3)` to split it into five shares (any three of which can be used\nto recover it).\n\n## Install\n\nGrab it from npm like so:\n\n```\nnpm install up8-ticket\n```\n\nTo include in your node project, use:\n\n``` javascript\nconst up8 = require('up8-ticket')\n```\n\nTo use in the browser, you can use e.g. [rollup][roll] and the\n[rollup-plugin-node-resolve][rpnr] plugin, and specify the following in your\n`rollup.config.js` or similar:\n\n``` javascript\nplugins: [\n  ..,\n  resolve({\n    browser: true,\n  }),\n  ..\n]\n```\n\n## Examples\n\nBoot a node repl with async/await support and require the library like so:\n\n```\n$ node --experimental-repl-await\nWelcome to Node.js v12.18.3.\nType \".help\" for more information.\n\u003e const up8 = require('up8-ticket')\n```\n\n### gen\\_ticket\\_simple\n\nGenerate a 256-bit master ticket via a simple CSPRNG (`crypto` or\n`window.crypto`):\n\n```\n\u003e up8.gen_ticket_simple(256)\n'~mactug-digbyn-malnyr-tobset-solfyr-dozner-dolpen-barsum-locfur-pagduc-danseb-timlug-savwyn-latmug-disdyr-laddeg'\n```\n\nYou can add your own entropy (generated elsewhere) by passing it in the second\nargument as a Buffer.  It will simply be XOR'd with the random bytes produced\ninternally:\n\n```\n\u003e up8.gen_ticket_simple(256, Buffer.from(\"a very random string\"))\n'~donryd-mallur-wanrex-fidrex-nidwyt-dildul-padryd-talfen-panneb-nocbep-norwep-mispel-ralryc-fiddun-tomsup-toltex'\n```\n\n### gen\\_ticket\\_more\n\nDo the same thing, but also use [more-entropy][ment] to produce additional\nentropy when generating the ticket.  Note that it returns a Promise (and takes\na little longer):\n\n```\n\u003e await up8.gen_ticket_more(256)\n'~morten-davnys-ronpes-hidtyd-pittev-donsug-fonpel-sornet-wacmeb-harbyl-monduc-linmur-racled-namdec-tildul-palmyn'\n```\n\nYou can similarly pass your own entropy in as an additional Buffer here:\n\n```\n\u003e let ticket = await up8.gen_ticket_more(256, Buffer.from('muh entropy'))\n'~rivmer-ticnyd-mirfet-rolbyt-tarlus-ricrun-fitmec-losrul-barhep-misfet-pidfen-foshep-ronrem-natlyx-tarlet-sipdeb'\n```\n\n### gen\\_ticket\\_drbg\n\nDo the same thing, but use a HMAC-DRBG function to combine the entropy produced\nby the underlying CSPRNG and more-entropy.  Like `gen_ticket_more`, it returns\na Promise, and takes longer.\n\nNote that you must use at least 192 bits of entropy for this method.\n\n```\n\u003e await up8.gen_ticket_drbg(256)\n'~morten-davnys-ronpes-hidtyd-pittev-donsug-fonpel-sornet-wacmeb-harbyl-monduc-linmur-racled-namdec-tildul-palmyn'\n```\n\nAs with the other functions, you can pass your own entropy in as an additional\nBuffer:\n\n```\n\u003e let ticket = await up8.gen_ticket_drbg(384, Buffer.from('a personalization string'))\n'~siller-hopryc-ripfyn-laglec-linpur-mogpun-poldux-bicmul-radnum-dapnup-monnub-dilwex-pacrym-samrup-ragryc-samdyt-timdys-hartul-lonrun-posmev-molrum-miclur-doznus-fasnut'\n```\n\n### shard\n\nSplit a ticket into 'shards' using a k/n Shamir's Secret Sharing scheme.\nSpecify the number of shards to create and the number of shards required to\nreassemble the original ticket, along with the ticket itself:\n\n```\n\u003e let ticket = await up8.gen_ticket_drbg(384)\n\u003e let shards = up8.shard(ticket, 3, 2)\n\u003e shards\n[\n  '~fidnec-topmud-pansul-lacbex-pinlet-finset-sonnyl-dovlud-sibdys-firtyd-walbep-ronlex-harmul-ligmeg-firryg-pidruc-masnup-havlud-tiplup-filrys-walsul-wicrum-narsem-mopdux-hilnev-raglun-doztep-picwes-dotten-micnyr-difwyt-donlys-lorref',\n  '~fidbud-rabtel-hapwyn-sander-napwyl-hosnys-savrud-hobsyl-silmev-lonfen-darlup-sopper-mitled-radpeg-diswen-laslun-toglud-sonsun-fopfex-docwyd-botneb-tilfur-rovhes-nollep-hatwer-nimpun-ladmel-borpun-bollep-finluc-noprun-hopmun-dovnul',\n  '~fidwes-witdur-nilbet-dolmug-pitpen-bacpyx-talrut-hanren-soltul-micdev-havneb-mildef-dilnec-bosdes-todsud-dopnex-rittyc-taplur-labrux-mogmun-togpeg-lagnel-tonweb-pidtyd-sablyn-sibsyx-linfex-lapteg-nolber-dovwel-nibteg-molsyd-macpec'\n]\n```\n\n### combine\n\nCombine shards created via `shard`.  Pass in at least the required number of\nshards as an array, with elements in any order:\n\n```\n\u003e up8.combine(shards.slice(0, 2)) === ticket\ntrue\n\u003e up8.combine(shards.slice(1, 3)) === ticket\ntrue\n\u003e up8.combine([shards[0], shards[2]]) === ticket\ntrue\n\u003e up8.combine(shards) === ticket\ntrue\n```\n\n[wgen]: https://github.com/urbit/urbit-wallet-generator\n[up8p]: https://github.com/urbit/proposals/blob/master/008-urbit-hd-wallet.md\n[roll]: https://rollupjs.org/guide/en\n[rpnr]: https://github.com/rollup/rollup-plugin-node-resolve\n[ment]: https://www.npmjs.com/package/more-entropy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbit%2Fup8-ticket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbit%2Fup8-ticket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbit%2Fup8-ticket/lists"}