{"id":42511432,"url":"https://github.com/fluree/crypto-utils","last_synced_at":"2026-01-28T14:12:51.426Z","repository":{"id":40499370,"uuid":"174004243","full_name":"fluree/crypto-utils","owner":"fluree","description":"A collection of Javascript cryptography functions for Fluree","archived":false,"fork":false,"pushed_at":"2024-02-14T23:53:32.000Z","size":111,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-28T03:33:03.822Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/fluree.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-05T19:03:03.000Z","updated_at":"2022-12-05T02:08:14.000Z","dependencies_parsed_at":"2024-06-19T15:35:23.885Z","dependency_job_id":"4e758ebc-0428-46ab-a0c0-3aea6f39de40","html_url":"https://github.com/fluree/crypto-utils","commit_stats":null,"previous_names":["fluree/cryptography"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fluree/crypto-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluree","download_url":"https://codeload.github.com/fluree/crypto-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"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":"2026-01-28T14:12:50.771Z","updated_at":"2026-01-28T14:12:51.416Z","avatar_url":"https://github.com/fluree.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fluree Cryptography \n\nA collection of Javascript cryptography functions for Fluree\n\nNOTE: This library has been deprecated. We recommend using the\nflureedb / flureenjs libraries directly instead. If there is something in here\nthat you'd like to see in those libraries, please let us know by opening a\nGitHub issue here: [https://github.com/fluree/db/issues](https://github.com/fluree/db/issues).\n\n## Installation\n```\nnpm install @fluree/crypto-utils\n```\n\n## Breaking change between version 1.9 \u0026 1.10\nThe `db` parameter has been changed to `ledger` as it should have been named in\nthe first place. This requires Fluree Ledger version 1.0.1 or higher.\n\n## Breaking change between version 1.8 \u0026 1.9\nThe `host` parameter has been dropped from the signQuery function since it is no longer used to create the signing string.\n\n## API\n\n### Generate Keys\n\nReturns a hex string of a public and private key pair. \n\n#### JavaScript version\n```javascript\nimport { generateKeyPair } from '@fluree/crypto-utils';\n\nconst { publicKey, privateKey }  = generateKeyPair();\n```\n\n#### Node.js version\nFor Node.js, you will need to reference the Node.js crypto module.\nThis is because the randomness for Node.js seed generation is \ndetermined differently than the browser.\n\n```javascript\nconst crypto = require(\"crypto\");\nconst {generateKeyPair,getSinFromPublicKey} = require('@fluree/crypto-utils');\n\nconst { publicKey, privateKey }  = generateKeyPair();\n```\n\n### Get Auth ID from Public Key\n\nReturns the `_auth/id` that accompanies a given public key. \n\n```javascript\nimport { generateKeyPair, getSinFromPublicKey } from '@fluree/crypto-utils';\n\nconst { publicKey }  = generateKeyPair();\nconst authId = getSinFromPublicKey(publicKey);\n\n```\n\n### Sign Transaction\n\nsignTransaction returns an object with the keys: sig, cmd, which should then be sent in the body of a request to the `/command` endpoint. \n\n```javascript\nimport { generateKeyPair, getSinFromPublicKey, signTransaction } from '@fluree/crypto-utils';\n\nconst { publicKey, privateKey }  = generateKeyPair();\nconst authId = getSinFromPublicKey(publicKey);\n\nconst ledger = \"test/one\";\nconst expire = Date.now() + 1000;\nconst fuel = 100000;\nconst nonce = 1; \n// Deps is an optional parameter - it is a array of _tx/ids that must have succeeded\n// for the current transaction to be accepted.\nconst deps = null; \n\nconst tx = JSON.stringifiy([{\n    \"_id\": \"_tag\",\n    \"id\": \"tag/test\" }])\n\nlet command = signTransaction(authId, ledger, expire, fuel, nonce, privateKey, tx, deps)\n\n// If you want to receive the verbose results from the transaction, \n// set the txid-only property to false.  By default (true), only the\n// transaction id will be returned.\nObject.assign(command, {\"txid-only\": false});\n\nconst fetchOpts = {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify(command)\n  };\n\nconst fullURI = `https://localhost:8090/fdb/${ledger}/command`;\n\nfetch(fullURI, fetchOpts)\n```\n\n### Sign Query\n\nsignQuery returns an object with the keys: header, method, body, which should then be sent to any of the query endpoints (`/query`, `/multi-query`, `history`, `block`).\n\n```javascript\nimport { generateKeyPair, getSinFromPublicKey, signQuery } from '@fluree/crypto-utils';\n\nconst { publicKey, privateKey }  = generateKeyPair();\nconst authId = getSinFromPublicKey(publicKey);\n\nconst param = JSON.stringify({select: [\"*\"], from: \"_collection\"});\nconst ledger = \"test/one\";\nconst queryType = \"query\";\n\n\nconst fetchOpts = signQuery(privateKey, param, queryType, ledger)\n\nconst fullURI = `https://localhost:8090/fdb/${ledger}/query`;\n\nfetch(fullURI, fetchOpts)\n```\n\n### Sign Request\n\nsignRequest returns an object containing the keys: header, method and body. This object can be used to sign requests that are not related to transactions or queries.\n\n#### Example: Delete Ledger\nThe following example demonstrates how to sign a request to delete a ledger.\n\n```javascript\nimport { generateKeyPair, getSinFromPublicKey, signRequest } from '@fluree/crypto-utils';\n\nconst { publicKey, privateKey }  = generateKeyPair();\nconst authId = getSinFromPublicKey(publicKey);\n\n// The host portion of the URL is required as the signRequest \n// function parses the entire url to build the signing string.\nvar endpoint = 'http://localhost:8090/fdb/delete-db';\n\nvar body = JSON.stringify({\n  \"ledger/id\": 'test/deleteme',\n  \"auth\": authId\n});\n\nvar fetchOpts = signRequest(\"POST\", endpoint, body, privateKey, authId);\n\nfetch(endpoint, fetchOpts)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluree%2Fcrypto-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluree%2Fcrypto-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluree%2Fcrypto-utils/lists"}