{"_id":"@0xver/crypto","name":"@0xver/crypto","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"@0xver/crypto","version":"1.0.2","license":"MIT","author":{"name":"Sam Larsen"},"description":"Crypto library for deriving mnemonics and keypairs, signing and verifying messages, and authentication","repository":{"type":"git","url":"git+https://github.com/0xver/crypto.git"},"main":"index.js","scripts":{"test":"mocha","lint":"prettier --use-tabs --trailing-comma 'none' --check .","format":"prettier --use-tabs --trailing-comma 'none' --write ."},"dependencies":{"bip39":"^3.1.0","secp256k1":"^5.0.0","tweetnacl":"^1.0.3","tweetnacl-util":"^0.15.1"},"devDependencies":{"bs58":"^6.0.0","chai":"^4.5.0","mocha":"^10.7.0","prettier":"^3.2.5"},"gitHead":"f8703c971391a045ccee6450dbfd2256d883f4a6","_id":"@0xver/crypto@1.0.2","bugs":{"url":"https://github.com/0xver/crypto/issues"},"homepage":"https://github.com/0xver/crypto#readme","_nodeVersion":"22.22.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-3gIgw4iHHm0jy2ZfZMb3ChpAtEmni+8kCmopQjY/85y0OUMJV0PXgrXhy43vNpbBnTwX/1nOQcZ9vzkWLLmiRA==","shasum":"f16c92a5f01b4141584a03a6f9b318fddbada72c","tarball":"https://registry.npmjs.org/@0xver/crypto/-/crypto-1.0.2.tgz","fileCount":17,"unpackedSize":29337,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD5za65M+h/Z7rv9+Vz+Et/E+H1Jy8X6EUOY3DlN60/oQIhAIMiXw26GppilMTYSutTMZdUPE+sLmE1ObbzLkqp+JZs"}]},"_npmUser":{"name":"0xver","email":"sam@slarsen.io"},"directories":{},"maintainers":[{"name":"0xver","email":"sam@slarsen.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/crypto_1.0.2_1783629569055_0.013239502191897845"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-09T20:39:28.933Z","1.0.2":"2026-07-09T20:39:29.228Z","modified":"2026-07-09T20:39:29.405Z"},"maintainers":[{"name":"0xver","email":"sam@slarsen.io"}],"description":"Crypto library for deriving mnemonics and keypairs, signing and verifying messages, and authentication","homepage":"https://github.com/0xver/crypto#readme","repository":{"type":"git","url":"git+https://github.com/0xver/crypto.git"},"author":{"name":"Sam Larsen"},"bugs":{"url":"https://github.com/0xver/crypto/issues"},"license":"MIT","readme":"# Crypto\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/0xver/crypto/blob/master/LICENSE.md)\n\n### Crypto library for deriving mnemonics and keypairs, signing and verifying messages, and authentication\n\n## Installation\n\nInstall @0xver/crypto with npm:\n\n```\nnpm install @0xver/crypto\n```\n\n## Generate Mnemonic and Keypair\n\nImport:\n\n```\nimport Keys from \"@0xver/crypto\";\n```\n\n### Generate Mnemonic\n\nGenerate 12-word English mnemonic:\n\n```\nconst mnemonic = Keys.mnemonic({ words: 12, language: \"english\" });\n```\n\nGenerate 18-word English mnemonic:\n\n```\nconst mnemonic = Keys.mnemonic({ words: 18, language: \"english\" });\n```\n\nGenerate 24-word English mnemonic:\n\n```\nconst mnemonic = Keys.mnemonic({ words: 24, language: \"english\" });\n```\n\n### Define Curve Type\n\nDefine curve type for keypair generation:\n\n```\nconst type = \"ed25519\" || \"secp256k1\";\n```\n\n### Generate Keypair\n\nGenerate keypair:\n\n```\nKeys.keypair({ type });\n```\n\n### Generate Keypair from Mnemonic\n\n**CAUTION**: The `keypairFromMnemonic` function derives a single keypair directly from the seed (private key) without adhering to HD wallet standards typically used by most wallets. As a result, importing the same mnemonic into other wallets will likely generate different keypairs due to those wallets’ use of hierarchical deterministic paths. While the keypair generated by this function is secure, it is important to understand that it is not compatible with HD wallet-compatible systems, limiting its interoperability with standard wallets. This approach is intended to keep the package lightweight.\n\nGenerate keypair from mnemonic:\n\n```\nKeys.keypairFromMnemonic({ mnemonic, type });\n```\n\nGenerate keypair from mnemonic and passphrase:\n\n```\nKeys.keypairFromMnemonic({ mnemonic, passphrase: \"passphrase123\", type });\n```\n\n## Sign and Verify Message\n\nImport:\n\n```\nimport Signature from \"@0xver/crypto\";\n```\n\nDefine ed25519 or secp256k1 type:\n\n```\nconst type = \"ed25519\" || \"secp256k1\";\n```\n\nOptionally create keypair:\n\n```\nimport Keys from \"@0xver/crypto\";\n\nconst keypair = Keys.keypair({ type });\n```\n\nCreate message:\n\n```\nconst message = \"Hello, world!\";\n```\n\nSign ed25519 message with secret key:\n\n```\nconst signedMessage = Signature.sign({ message, secretKey: keypair.secretKey, type });\n```\n\nSign secp256k1 message with private key:\n\n```\nconst signedMessage = Signature.sign({ message, privateKey: keypair.privateKey, type });\n```\n\nVerify message:\n\n```\nSignature.verify({ message, publicKey: keypair.publicKey, signature: signedMessage.signature, type });\n```\n\n## Authentication\n\nImport:\n\n```\nimport Auth from \"@0xver/crypto\";\n```\n\nDefine token params:\n\n```\nimport { keypair } from \"@0xver/crypto\";\n\nconst type = \"ed25519\" || \"secp256k1\";\nconst domain = \"example.com\";\nconst keys = keypair({ type });\nconst statement = Auth.prepare({ domain, publicKey: keys.publicKey });\n```\n\nSign ed25519 message with secret key:\n\n```\nimport { sign } from \"@0xver/crypto\";\n\nconst signature = sign({ message, secretKey: keys.secretKey, type });\n```\n\nSign secp256k1 message with private key:\n\n```\nimport { sign } from \"@0xver/crypto\";\n\nconst signature = sign({ message, privateKey: keys.privateKey, type });\n```\n\nGenerate token that never expires:\n\n```\nconst token = Auth.token({ domain, publicKey: keypair.publicKey, statement, signature });\n```\n\nGenerate token that expires in 24 hours:\n\n```\nconst token = Auth.token({ domain, publicKey: keypair.publicKey, statement, signature, expires: 86400000 });\n```\n\nCreate certificate:\n\n```\nAuth.certificate({ token, type });\n```\n\n## Utilities\n\n### Number to Mnemonic Word\n\nImport:\n\n```\nimport { wordFromNumber } from \"@0xver/crypto\";\n```\n\nEnglish word from number:\n\n```\nconst word = wordFromNumber({ number: 42, language: \"english\" });\n```\n\n### Mnemonic Word to Number\n\nImport:\n\n```\nimport { numberFromWord } from \"@0xver/crypto\";\n```\n\nNumber from English word:\n\n```\nconst number = numberFromWord({ word: \"aim\", language: \"english\" });\n```\n\n### HTTP Response Status Codes\n\nImport:\n\n```\nimport Auth, { response } from \"@0xver/crypto\";\n```\n\nUsage on certificate:\n\n```\nconst certificate = Auth.certificate({ token, type });\n\nreturn new Response(response({ data: certificate }), {\n\theaders: { \"Content-Type\": \"application/json\" }\n});\n```\n","readmeFilename":"README.md","_rev":"1-58c383cca3cd49da1609455cdedcdf63"}