{"id":20796628,"url":"https://github.com/gotocva/nilajs-digital-signature","last_synced_at":"2026-01-28T11:02:33.463Z","repository":{"id":245054821,"uuid":"817213832","full_name":"gotocva/nilajs-digital-signature","owner":"gotocva","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-19T09:12:31.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T22:58:06.303Z","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/gotocva.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":"2024-06-19T08:47:24.000Z","updated_at":"2024-06-19T08:53:28.000Z","dependencies_parsed_at":"2024-06-19T12:04:37.709Z","dependency_job_id":"8d70080f-659e-46d8-b932-4be3e94a831c","html_url":"https://github.com/gotocva/nilajs-digital-signature","commit_stats":null,"previous_names":["gotocva/nilajs-digital-signature"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gotocva/nilajs-digital-signature","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-digital-signature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-digital-signature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-digital-signature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-digital-signature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotocva","download_url":"https://codeload.github.com/gotocva/nilajs-digital-signature/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-digital-signature/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28844432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T10:53:21.605Z","status":"ssl_error","status_checked_at":"2026-01-28T10:53:20.789Z","response_time":57,"last_error":"SSL_read: 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-11-17T16:28:25.139Z","updated_at":"2026-01-28T11:02:33.437Z","avatar_url":"https://github.com/gotocva.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nilajs-digital-signature\n\nA digital signature is a cryptographic mechanism used to verify the authenticity and integrity of digital messages or documents. It provides assurances that the message was indeed created by a particular entity (authentication) and that the message has not been altered or tampered with since it was signed (integrity).\n\nA simple library for generating elliptic curve (secp256k1) key pairs, signing data, verifying signatures, and validating public keys. \n\n## Installation\n\nYou can install the package via npm:\n\n```sh\nnpm install nilajs-digital-signature\n```\n\n## Usage\n\n### Import the Library\n\n```javascript\nconst {\n  generateWallet,\n  checkPublicKeyValid,\n  signData,\n  verifySignature\n} = require('nilajs-digital-signature');\n```\n\n### Generate Wallet\n\nGenerate a new wallet (elliptic curve (secp256k1) key pair) :\n\n```javascript\nconst { publicKey, privateKey } = generateWallet();\nconsole.log(`Public Key: ${publicKey}`);\nconsole.log(`Private Key: ${privateKey}`);\n```\n\n### Validate Public Key\n\nCheck if a given public key is valid:\n\n```javascript\nconst publicKey = 'YOUR_PUBLIC_KEY';\nconst result = checkPublicKeyValid(publicKey);\nconsole.log(result); // { valid: true/false, public_key: 'YOUR_PUBLIC_KEY' }\n```\n\n### Sign Data\n\nSign a piece of data with a private key:\n\n```javascript\nconst privateKey = 'YOUR_PRIVATE_KEY';\nconst data = 'This is the data to be signed';\nconst signatureObject = signData(privateKey, data);\nconsole.log(signatureObject);\n/*\n{\n  data: 'This is the data to be signed',\n  signature: {\n    r: 'SIGNATURE_R',\n    s: 'SIGNATURE_S'\n  }\n}\n*/\n```\n\n### Verify Signature\n\nVerify the signature of the data with a public key:\n\n```javascript\nconst publicKey = 'YOUR_PUBLIC_KEY';\nconst data = 'This is the data to be signed';\nconst signature = {\n  r: 'SIGNATURE_R',\n  s: 'SIGNATURE_S'\n};\nconst verificationResult = verifySignature(publicKey, data, signature);\nconsole.log(verificationResult);\n/*\n{\n  data: 'This is the data to be signed',\n  signature: {\n    r: 'SIGNATURE_R',\n    s: 'SIGNATURE_S'\n  },\n  is_verified: true/false\n}\n*/\n```\n\n## API Reference\n\n### `generateWallet()`\n\nGenerates a new elliptic curve (secp256k1) key pair.\n\n**Returns:**\n- `Object`: An object containing the `publicKey` and `privateKey` as hexadecimal strings.\n\n### `checkPublicKeyValid(publicKey)`\n\nChecks if a given public key is valid.\n\n**Parameters:**\n- `publicKey` (`string`): The public key to validate.\n\n**Returns:**\n- `Object`: An object containing:\n  - `valid` (`boolean`): Whether the public key is valid.\n  - `public_key` (`string`): The provided public key.\n\n### `signData(privateKey, data)`\n\nSigns a piece of data with a private key.\n\n**Parameters:**\n- `privateKey` (`string`): The private key to sign with.\n- `data` (`string`): The data to sign.\n\n**Returns:**\n- `Object`: An object containing the signed `data` and `signature` (with `r` and `s` as hexadecimal strings).\n\n### `verifySignature(publicKey, data, signature)`\n\nVerifies the signature of the data with a public key.\n\n**Parameters:**\n- `publicKey` (`string`): The public key to verify with.\n- `data` (`string`): The signed data.\n- `signature` (`Object`): The signature object containing `r` and `s` as hexadecimal strings.\n\n**Returns:**\n- `Object`: An object containing:\n  - `data` (`string`): The signed data.\n  - `signature` (`Object`): The signature object.\n  - `is_verified` (`boolean`): Whether the signature is valid.\n\n## License\n\nMIT\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotocva%2Fnilajs-digital-signature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotocva%2Fnilajs-digital-signature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotocva%2Fnilajs-digital-signature/lists"}