{"id":13509277,"url":"https://github.com/agro1986/caustic","last_synced_at":"2026-02-18T21:02:19.305Z","repository":{"id":57482404,"uuid":"155047459","full_name":"agro1986/caustic","owner":"agro1986","description":"Caustic Elixir Cryptocurrency Library (Bitcoin, Ethereum, etc.) with extensive cryptography and number theory library","archived":false,"fork":false,"pushed_at":"2023-06-06T16:34:33.000Z","size":823,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-31T22:15:36.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/agro1986.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2018-10-28T07:51:13.000Z","updated_at":"2025-08-07T03:05:45.000Z","dependencies_parsed_at":"2024-01-31T07:53:43.652Z","dependency_job_id":null,"html_url":"https://github.com/agro1986/caustic","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"20f22f56b78efb3478466e22f429ffa793fcfb72"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/agro1986/caustic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agro1986%2Fcaustic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agro1986%2Fcaustic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agro1986%2Fcaustic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agro1986%2Fcaustic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agro1986","download_url":"https://codeload.github.com/agro1986/caustic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agro1986%2Fcaustic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-08-01T02:01:05.573Z","updated_at":"2026-02-18T21:02:19.269Z","avatar_url":"https://github.com/agro1986.png","language":"Elixir","funding_links":[],"categories":["Text and Numbers"],"sub_categories":[],"readme":"# Caustic Cryptocurrency Library\n\nCaustic is an Elixir cryptocurrency library which contains\nalgorithms used in Bitcoin, Ethereum, and other blockchains.\nIt also includes a rich cryptography, number theory,\nand general mathematics class library.\nYou can use Caustic to quickly implement your own crypto wallet\nor client. With the low-level math library, you can have fun with\nexploratory mathematics.\n\nWarning: This library is developed for learning purposes. Please do not\nuse for production.\n\n# Documentation\n\n\u003chttps://hexdocs.pm/caustic/\u003e\n\n# Installation\n\nAdd to `mix.exs` of your Elixir project:\n\n```elixir\ndefp deps do\n  [\n    {:caustic, \"~\u003e 0.1.22\"}\n  ]\nend\n```\n\nAnd then run:\n\n```bash\nmix deps.get\n```\n\n# Usage\n\n## Cryptocurrency\n\nYou can generate Bitcoin private keys.\n\n```elixir\nprivkey = Caustic.Secp256k1.generate_private_key()\n# 55129182198667841522063226112743062531539377180872956850932941251085402073984\n\nprivkey_base58check = Caustic.Utils.base58check_encode(\u003c\u003cprivkey::size(256)\u003e\u003e, :private_key_wif, convert_from_hex: false)\n# 5Jjxv41cLxb3hBZRr5voBB7zj77MDo7QVVLf3XgK2tpdAoTNq9n\n```\n\nYou can then digitally sign a message.\n\n```elixir\npubkey = Caustic.Secp256k1.public_key(privkey)\n# {6316467786437337873577388437635743649101330733943708346103893494005928771381, 36516277665018688612645564779200795235396005730419130160033716279021320193545}\n\nmessage = \"Hello, world!!!\"\nhash = Caustic.Utils.hash256(message)\nsignature = Caustic.Secp256k1.ecdsa_sign(hash, privkey)\nCaustic.Secp256k1.ecdsa_verify?(pubkey, hash, signature) # true\n```\n\n## Number theory\n\nCaustic has many functions to deal with integers and their properties.\nFor example you can do primality testing.\n\n```elixir\nfirst_primes = 1..20 |\u003e Enum.filter(\u0026Caustic.Utils.prime?/1)\n# [2, 3, 5, 7, 11, 13, 17, 19]\n```\n\nSo 7 is supposed to be a prime. Let's confirm by finding its divisors:\n\n```elixir\nCaustic.Utils.divisors 7\n# [1, 7]\n```\n\nThis is in contrast to 6 for example, which has divisors other than 1\nand itself:\n\n```elixir\nCaustic.Utils.divisors 6\n# [1, 2, 3, 6]\n```\n\nThe sum of 6's divisors other than itself (its proper divisors) equals to 6 again. Those kinds of numbers\nare called perfect numbers.\n\n```elixir\nCaustic.Utils.proper_divisors 6    \n# [1, 2, 3]\nCaustic.Utils.proper_divisors_sum 6                               \n# 6\nCaustic.Utils.perfect? 6\n# true\n```\n\nWe can easily find other perfect numbers.\n\n```elixir\n1..10000 |\u003e Enum.filter(\u0026Caustic.Utils.perfect?/1)\n# [6, 28, 496, 8128]\n```\n\nThere aren't that many of them, it seems...\n\nNow back to our list of first primes. You can find the primitive roots of those primes:\n\n```elixir\nfirst_primes |\u003e Enum.map(\u0026{\u00261, Caustic.Utils.primitive_roots(\u00261)})\n# [\n#   {2, [1]},\n#   {3, [2]},\n#   {5, [2, 3]},\n#   {7, [3, 5]},\n#   {11, [2, 6, 7, 8]},\n#   {13, [2, 6, 7, 11]},\n#   {17, [3, 5, 6, 7, 10, 11, 12, 14]},\n#   {19, [2, 3, 10, 13, 14, 15]}\n# ]\n```\n\nWe can see that 5 is a primitive root of 7. It means that repeated\nexponentiation of 5 modulo 7 will generate all numbers relatively\nprime to 7. Let's confirm it:\n\n```elixir\nCaustic.Utils.order_multiplicative 5, 7\n# 6\n1..6 |\u003e Enum.map(\u0026Caustic.Utils.pow_mod(5, \u00261, 7))\n# [5, 4, 6, 2, 3, 1]\n```\n\nFirst we check the order of 5 modulo 7. It is 6, which means that\n5^6 = 1 (mod 7), so further repeated multiplication (5^7 etc.) will\njust repeat previous values.\n\nThen we calculate 5^1 to 5^6 (mod 7), and as expected it cycles\nthrough all numbers relatively prime to 7 because 5 is a primitive\nroot of 7.\n\nFor more examples, please see the documentation of `Caustic.Utils`.\n\n# Contribute\n\nPlease send pull requests to \u003chttps://github.com/agro1986/caustic\u003e\n\n# Contact\n\n[@agro1986](https://twitter.com/agro1986) on Twitter\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagro1986%2Fcaustic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagro1986%2Fcaustic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagro1986%2Fcaustic/lists"}