{"id":17939413,"url":"https://github.com/libitx/univrse","last_synced_at":"2025-08-29T03:42:41.143Z","repository":{"id":62430652,"uuid":"357303422","full_name":"libitx/univrse","owner":"libitx","description":"Universal schema for data serialisation, signing and encryption.","archived":false,"fork":false,"pushed_at":"2021-11-23T14:57:24.000Z","size":95,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-16T04:18:59.962Z","etag":null,"topics":["bitcoin","bsv","cbor","cryptography","encryption","signatures"],"latest_commit_sha":null,"homepage":"https://univrse.network","language":"Elixir","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/libitx.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":"2021-04-12T18:45:39.000Z","updated_at":"2022-03-08T12:30:50.000Z","dependencies_parsed_at":"2022-11-01T20:22:26.905Z","dependency_job_id":null,"html_url":"https://github.com/libitx/univrse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/libitx/univrse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libitx%2Funivrse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libitx%2Funivrse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libitx%2Funivrse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libitx%2Funivrse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libitx","download_url":"https://codeload.github.com/libitx/univrse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libitx%2Funivrse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272620226,"owners_count":24965503,"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-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["bitcoin","bsv","cbor","cryptography","encryption","signatures"],"created_at":"2024-10-29T00:07:15.822Z","updated_at":"2025-08-29T03:42:41.101Z","avatar_url":"https://github.com/libitx.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Univrse\n\n![Univrse](https://github.com/libitx/univrse/raw/master/media/poster.png)\n\n![Hex.pm](https://img.shields.io/hexpm/v/univrse?color=informational)\n![License](https://img.shields.io/github/license/libitx/univrse?color=informational)\n![Build Status](https://img.shields.io/github/workflow/status/libitx/univrse/Elixir%20CI)\n\nA universal schema for serializing data objects, secured with signatures and\nencryption.\n\n* **Serialising data** - Simple, binary-friendly data exchange using the Concise Binary Object Representation (CBOR) data format.\n* **Authenticating data** - Protect integrity of data with digital signatures or message authentication code (MAC) algorithms.\n* **Securing data** - Ensure confidentiality and integrity of data for one or multiple recipients, using standardised authenticated encryption algorithms.\n\n## Sponsors\n\n\u003cp align=\"center\"\u003eSupported by:\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://coingeek.com\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n    \u003cimg src=\"https://www.chronoslabs.net/img/badges/coingeek.png\" width=\"180\" alt=\"Coingeek\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nYour sponsorship will help us continue to release and maintain software that Bitcoin businesses and developers depend on.\n\n#### 👉 [Sponsor Chronos Labs' open source work](https://www.chronoslabs.net/sponsor/)\n\n## Installation\n\nThe package can be installed by adding `univrse` to your list of dependencies\nin `mix.exs`.\n\n```elixir\ndef deps do\n  [\n    {:univrse, \"~\u003e 0.2\"}\n  ]\nend\n```\n\n## Usage\n\nFor full documentation, please refer to:\n\n* [univrse.network docs](https://univrse.network/docs)\n* [univrse API docs](https://hexdocs.pm/univrse)\n\n### 1. Serialising data\n\nAny arbitrary payload can be wrapped in a `t:Univrse.Envelope.t/0` structure,\nand then encoded in one of three serialisation formats, using\n`Univrse.Envelope.encode/2` and `Univrse.Envelope.to_script/2`\n\n* `:cbor` - Concise CBOR-encoded binary value\n* `:base64` - Compact Base64-url encoded string value\n* `:script` - Encoded in a Bitcoin `OP_RETURN` script\n\n```elixir\n# Wrap any arbitrary data payload in an Envelope structure\niex\u003e payload = \"Hello world!\"\niex\u003e env = Univrse.wrap(payload, %{proto: \"univrse.demo\"})\n\n# Encode the data in one of three serialisation formats\niex\u003e env_cbor = Univrse.encode(env, :cbor)\niex\u003e env_base64 = Univrse.encode(env, :base64)\niex\u003e env_script = Univrse.Envelope.to_script(env)\n\n# Decode the serialised data back into an Envelope structure\niex\u003e {:ok, env2} = Univrse.decode(env_cbor)\niex\u003e {:ok, env3} = Univrse.decode(env_base64)\niex\u003e {:ok, env4} = Univrse.Envelope.parse_script(env_script)\n\n# Compare payload\niex\u003e env2.payload == payload and env3.payload == payload and env4.payload == payload\ntrue\n```\n\n### 2. Using signatures\n\nDigital signatures or message authentication code (MAC) algorithms can be used\nto protect the integrity of an Envelope's data payload.\n\n```elixir\n# Generate keys\niex\u003e alice_key = Univrse.Key.generate_key({:ec, :secp256k1})\niex\u003e alice_pubkey = Univrse.Key.to_public(alice_key)\niex\u003e app_secret = Univrse.Key.generate_key({:oct, 256})\n\n# Sign and verify using a single key\niex\u003e {:ok, env1} = \"Hello world!\"\n...\u003e |\u003e Univrse.wrap(%{proto: \"univrse.demo\"})\n...\u003e |\u003e Univrse.sign(alice_key, %{\"alg\" =\u003e \"ES256K\", \"kid\" =\u003e \"alice\"})\n\niex\u003e Univrse.verify(env1, alice_pubkey)\ntrue\n\n# Sign and verify using multiple keys and algorithms\niex\u003e {:ok, env2} = \"Hello world!\"\n...\u003e |\u003e Univrse.wrap(%{proto: \"univrse.demo\"})\n...\u003e |\u003e Univrse.sign([\n...\u003e      {alice_key, %{\"alg\" =\u003e \"ES256K\", \"kid\" =\u003e \"alice\"}},\n...\u003e      {app_secret, %{\"alg\" =\u003e \"HS256\", \"kid\" =\u003e \"app\"}}\n...\u003e ])\n\niex\u003e Univrse.verify(env2, [alice_pubkey, app_secret])\ntrue\n```\n\n### 3. Using encryption\n\nAuthenticated encryption algorithms may be used to ensure the confidentiality\nof an Envelope's data payload for one or multiple recipients.\n\n```elixir\n# Generate keys\niex\u003e bob_key = Univrse.Key.generate_key({:ec, :secp256k1})\niex\u003e bob_pubkey = Univrse.Key.to_public(bob_key)\niex\u003e charlie_key = Univrse.Key.generate_key({:ec, :secp256k1})\niex\u003e charlie_pubkey = Univrse.Key.to_public(charlie_key)\niex\u003e app_secret = Univrse.Key.generate_key({:oct, 256})\n\n# Encrypt and decrypt data for a single recipient\niex\u003e {:ok, env1} = \"Hello world!\"\n...\u003e |\u003e Univrse.wrap(%{proto: \"univrse.demo\"})\n...\u003e |\u003e Univrse.encrypt(bob_pubkey, %{\"alg\" =\u003e \"ECDH-ES+A128GCM\", \"kid\" =\u003e \"bob\"})\n\niex\u003e {:ok, env1} = Univrse.decrypt(env1, bob_key)\niex\u003e env1.payload\n\"Hello world!\"\n\n# Encrypt and decrypt data for multiple recipients using multiple algorithms\niex\u003e {:ok, env2} = \"Hello world!\"\n...\u003e |\u003e Univrse.wrap(%{proto: \"univrse.demo\"})\n...\u003e |\u003e Univrse.encrypt([\n...\u003e      {app_secret, %{\"alg\" =\u003e \"A256GCM\"}},\n...\u003e      {bob_pubkey, %{\"alg\" =\u003e \"ECDH-ES+A128GCM\", \"kid\" =\u003e \"bob\"}},\n...\u003e      {charlie_pubkey, %{\"alg\" =\u003e \"ECDH-ES+A128GCM\", \"kid\" =\u003e \"charlie\"}}\n...\u003e ])\n\niex\u003e {:ok, bob_env} = Univrse.Envelope.decrypt_at(env2, 1, bob_key)\niex\u003e bob_env.payload\n\"Hello world!\"\n\niex\u003e {:ok, charlie_env} = Univrse.Envelope.decrypt_at(env2, 2, charlie_key)\niex\u003e charlie_env.payload\n\"Hello world!\"\n```\n\n## License\n\nUnivrse is open source and released under the [Apache-2 License](https://github.com/libitx/univrse/blob/master/LICENSE).\n\nCopyright (c) 2021 Chronos Labs Ltd.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibitx%2Funivrse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibitx%2Funivrse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibitx%2Funivrse/lists"}