{"_id":"@blocksoft-ltd/cryptomate","_rev":"1-48db4118054ef37ad70e6c0d86195ee6","name":"@blocksoft-ltd/cryptomate","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@blocksoft-ltd/cryptomate","version":"1.0.0","description":"NodeJS crypto module wrapper for humans","main":"index.js","homepage":"https://github.com/PlamenHristov/cryptomate#readme","directories":{"test":"test"},"scripts":{"test":"jest --coverage","clean":"rm -rf ./dist","build":"npm run clean && npm run build:esm && npm run build:cjs","build:esm":"tsc -p ./configs/tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs","build:cjs":"tsc -p ./configs/tsconfig.cjs.json","semantic-release":"semantic-release","prepack":"npm run build","prepublishOnly":"npm run build","lint":"eslint src/**/*.ts test/**/*.ts","lint-fix":"eslint --fix src/**/*.ts test/**/*.ts"},"devDependencies":{"@types/jest":"^29.5.1","@typescript-eslint/eslint-plugin":"^5.59.5","@typescript-eslint/parser":"^5.59.5","eslint":"^8.40.0","jest":"^29.5.0","semantic-release":"^21.0.2","ts-jest":"^29.1.0","ts-node":"^10.9.1","typescript":"^5.0.4"},"repository":{"type":"git","url":"git+https://github.com/PlamenHristov/cryptomate.git"},"engines":{"node":">=16.0.0","npm":">=7.0.0"},"keywords":["nodejs","crypto","mate","easy","wrapper"],"jest":{"preset":"ts-jest","testEnvironment":"node"},"eslintConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":12,"sourceType":"module"},"plugins":["@typescript-eslint"],"extends":["eslint:recommended","plugin:@typescript-eslint/recommended"],"rules":{"semi":["error","never"],"indent":["error",2],"quotes":["error","double"],"no-multiple-empty-lines":[2,{"max":99999,"maxEOF":0}]},"env":{"browser":true,"es2021":true}},"author":{"name":"PlamenHristov"},"license":"MIT","bugs":{"url":"https://github.com/PlamenHristov/cryptomate/issues"},"volta":{"node":"20.2.0"},"gitHead":"8aedc37c1b461f4500ddc240cd4940fac9b178a5","_id":"@blocksoft-ltd/cryptomate@1.0.0","_nodeVersion":"20.2.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-d2SMG6lvf3o9QeQnNDoMeMRSm/51vOtF+LwUQS4fnBQ8BHDs99UubIbrI+Q9gGIUnIwfEQnfEqWEnymALC/mRQ==","shasum":"c701ab51f7287af1166c69d9ce503e3f47b76295","tarball":"https://registry.npmjs.org/@blocksoft-ltd/cryptomate/-/cryptomate-1.0.0.tgz","fileCount":57,"unpackedSize":146276,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEt1tGarTY7/x8VFflEdlD5s8oMmv3s1rXmao+03SqBLAiEAwgNVS/NAsIk2aNuJQjr3/dsEad49sgN6RQgWC/WUPe0="}]},"_npmUser":{"name":"phr1stov","email":"phristov@blocksoft.ltd"},"maintainers":[{"name":"phr1stov","email":"phristov@blocksoft.ltd"},{"name":"blockphr","email":"info@blocksoft.ltd"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cryptomate_1.0.0_1684705286390_0.031881613091955474"},"_hasShrinkwrap":false},"1.1.0":{"name":"@blocksoft-ltd/cryptomate","version":"1.1.0","description":"NodeJS crypto module wrapper for humans","main":"index.js","homepage":"https://github.com/PlamenHristov/cryptomate#readme","directories":{"test":"test"},"scripts":{"test":"jest --coverage","clean":"rm -rf ./dist","build":"npm run clean && npm run build:esm && npm run build:cjs","build:esm":"tsc -p ./configs/tsconfig.esm.json && mv dist/esm/index.js dist/esm/index.mjs","build:cjs":"tsc -p ./configs/tsconfig.cjs.json","semantic-release":"semantic-release","prepack":"npm run build","prepublishOnly":"npm run build","lint":"eslint src/**/*.ts test/**/*.ts","lint-fix":"eslint --fix src/**/*.ts test/**/*.ts"},"devDependencies":{"@types/jest":"^29.5.1","@typescript-eslint/eslint-plugin":"^5.59.5","@typescript-eslint/parser":"^5.59.5","benchmark":"^2.1.4","eccjs":"^0.3.1","elliptic":"^6.5.4","eslint":"^8.40.0","jest":"^29.5.0","semantic-release":"^21.0.2","ts-jest":"^29.1.0","ts-node":"^10.9.1","typescript":"^5.0.4"},"repository":{"type":"git","url":"git+https://github.com/PlamenHristov/cryptomate.git"},"engines":{"node":">=16.0.0","npm":">=7.0.0"},"keywords":["nodejs","crypto","mate","easy","wrapper"],"jest":{"preset":"ts-jest","testEnvironment":"node"},"eslintConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":12,"sourceType":"module"},"plugins":["@typescript-eslint"],"extends":["eslint:recommended","plugin:@typescript-eslint/recommended"],"rules":{"semi":["error","never"],"indent":["error",2],"quotes":["error","double"],"no-multiple-empty-lines":[2,{"max":99999,"maxEOF":0}]},"env":{"browser":true,"es2021":true}},"author":{"name":"PlamenHristov"},"license":"MIT","bugs":{"url":"https://github.com/PlamenHristov/cryptomate/issues"},"volta":{"node":"20.2.0"},"gitHead":"d95f81dfa8794cc956f5649747588702e7d68ce9","_id":"@blocksoft-ltd/cryptomate@1.1.0","_nodeVersion":"20.2.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-boBBc99Vbz13b7GOq2tIBrj1F0X8AnqM0I8VTSa/JHxaNm50tgq5pCnBmr7LuPQ0L6oam00f+uOUp6Jgwn3F5g==","shasum":"e245eb3f560b1124f06524673d1acbef9cbf6b33","tarball":"https://registry.npmjs.org/@blocksoft-ltd/cryptomate/-/cryptomate-1.1.0.tgz","fileCount":61,"unpackedSize":159421,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGv/4e74NDuSKUGvspKTayclLFlbNg2CmmVS6qCGj1xiAiEAi1jkNJo+NuYtVXAM+lI4Mscob2HIxzac9YvYRKipciU="}]},"_npmUser":{"name":"phr1stov","email":"phristov@blocksoft.ltd"},"maintainers":[{"name":"phr1stov","email":"phristov@blocksoft.ltd"},{"name":"blockphr","email":"info@blocksoft.ltd"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cryptomate_1.1.0_1685879326963_0.09605152884365076"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-21T21:41:26.314Z","1.0.0":"2023-05-21T21:41:26.567Z","modified":"2023-06-04T11:48:47.379Z","1.1.0":"2023-06-04T11:48:47.251Z"},"maintainers":[{"name":"phr1stov","email":"phristov@blocksoft.ltd"},{"name":"blockphr","email":"info@blocksoft.ltd"}],"description":"NodeJS crypto module wrapper for humans","homepage":"https://github.com/PlamenHristov/cryptomate#readme","keywords":["nodejs","crypto","mate","easy","wrapper"],"repository":{"type":"git","url":"git+https://github.com/PlamenHristov/cryptomate.git"},"author":{"name":"PlamenHristov"},"bugs":{"url":"https://github.com/PlamenHristov/cryptomate/issues"},"license":"MIT","readme":"# cryptomate\n\nErgonomic, zero-dependency crypto module wrapper for ECDSA and EdDSA signatures.\n\n[![Pull Request Checks](https://github.com/PlamenHristov/cryptomate/actions/workflows/pr.yml/badge.svg?branch=main&event=release)](https://github.com/PlamenHristov/cryptomate/actions/workflows/pr.yml)\n[![Coverage Status](https://coveralls.io/repos/github/PlamenHristov/cryptomate/badge.svg?branch=main)](https://coveralls.io/github/PlamenHristov/cryptomate?branch=main)\n[![Known Vulnerabilities](https://snyk.io/test/github/PlamenHristov/cryptomate/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PlamenHristov/cryptomate?targetFile=package.json)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nKey features of the module include:\n\n- Generation of ECDSA and EdDSA key pairs.\n- Conversion between PEM (Privacy-Enhanced Mail) and DER (Distinguished Encoding Rules) formats.\n- Extraction of public key from a given private key.\n- Message signing and verification using ECDSA and EdDSA algorithms.\n\n## Installation\n\nTo install `cryptomate`, use the following npm command:\n\n```bash\nnpm i --save cryptomate\n```\n\n## Quick Start\n\nHere is an example demonstrating the use of the ECDSA functionality provided by this module:\n\n```javascript\nconst {ECDSA, EC_CURVE, Key, SignatureEncoding} = require('cryptomate');\n\n// Generate an ECDSA key pair.\nconst ecdsa = ECDSA.withCurve(EC_CURVE.secp256k1).genKeyPair();\n\n// Sign a message.\nlet message = \"Hello, World!\";\nlet signature = ecdsa.sign(message, SignatureEncoding.HEX);\n\n// Verify the signature.\nconsole.log(ecdsa.verify(message, signature)); // Outputs: true\n\n// Export keys in PEM format.\nlet privateKeyPEM = ecdsa.toPEM(Key.privateKey);\nlet publicKeyPEM = ecdsa.toPEM(Key.publicKey);\n\n// Import keys from PEM format.\nlet importedECDSA = ECDSA.withCurve(EC_CURVE.secp256k1).fromPEM(privateKeyPEM, Key.privateKey);\n\n```\n\n## API Reference\n\n### ECDSA\n\n#### ECDSA.withCurve(curve)\n\nA factory method to construct an ECDSA object with a given elliptic curve.\n\n##### Parameters\n\n- `curve` - The elliptic curve to use. This can be one of the following values:\n    - `EC_CURVE.P_256` - NIST P-256 curve.\n    - `EC_CURVE.P_384` - NIST P-384 curve.\n    - `EC_CURVE.P_521` - NIST P-521 curve.\n    - `EC_CURVE.SECP256K1` - SECP256K1 curve.\n    - `EC_CURVE.SECP256R1` - SECP256R1 curve.\n    - `EC_CURVE.SECP384R1` - SECP384R1 curve.\n    - `EC_CURVE.SECP521R1` - SECP521R1 curve.\n    - ...\n\n##### Returns\n\nAn ECDSA object with the given elliptic curve.\n\n#### ECDSA.genKeyPair()\n\nGenerates a new ECDSA key pair.\n\n##### Returns\n\nAn ECDSA object with a newly generated key pair.\n\n#### ECDSA.fromPEM(pem, keyType)\n\nConstructs an ECDSA object from a given PEM string.\n\n##### Parameters\n\n- `pem` - The PEM string to construct the ECDSA object from.\n- `keyType` - The type of key to construct. This can be one of the following values:\n    - `Key.privateKey` - Private key.\n    - `Key.publicKey` - Public key.\n\n##### Returns\n\nAn ECDSA object with the given PEM string.\n\n#### ECDSA.toPEM(keyType)\n\nConverts the ECDSA object to a PEM string.\n\n##### Parameters\n\n- `keyType` - The type of key to convert. This can be one of the following values:\n    - `Key.privateKey` - Private key.\n    - `Key.publicKey` - Public key.\n\n##### Returns\n\nA PEM string representing the ECDSA object.\n\n#### ECDSA.getPublicKey()\n\nExtracts the public key from the ECDSA object.\n\n##### Returns\n\nA Buffer object containing the public key.\n\n#### ECDSA.sign(message, encoding)\n\nSigns a message using the ECDSA object.\n\n##### Parameters\n\n- `message` - The message to sign.\n- `encoding` - The encoding of the message. This can be one of the following values:\n    - `SignatureEncoding.HEX` - The message is encoded in hexadecimal format.\n    - `SignatureEncoding.BASE64` - The message is encoded in Base64 format.\n    - `SignatureEncoding.UTF8` - The message is encoded in UTF-8 format.\n    - ...\n\n##### Returns\n\nA Buffer object containing the signature.\n\n#### ECDSA.verify(message, signature, encoding)\n\nVerifies a signature using the ECDSA object.\n\n##### Parameters\n\n- `message` - The message to verify.\n- `signature` - The signature to verify.\n- `encoding` - The encoding of the message. This can be one of the following values:\n    - `SignatureEncoding.HEX` - The message is encoded in hexadecimal format.\n    - `SignatureEncoding.BASE64` - The message is encoded in Base64 format.\n    - `SignatureEncoding.UTF8` - The message is encoded in UTF-8 format.\n    - ...\n\n##### Returns\n\nA boolean value indicating whether the signature is valid.\n\n### EdDSA\n\nPlease note that the EdDSA class shares similar method names and functionalities to the ECDSA class for key pair\ngeneration,\nsigning and verifying messages, and importing/exporting keys in various formats.\nRefer to the ECDSA API documentation provided above for further details.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.md"}