{"_id":"@bluesky-social/crypto","name":"@bluesky-social/crypto","dist-tags":{"latest":"0.4.4"},"versions":{"0.4.4":{"name":"@bluesky-social/crypto","version":"0.4.4","license":"MIT","description":"Library for cryptographic keys and signing in atproto","keywords":["atproto","cryptography"],"homepage":"https://atproto.com","repository":{"type":"git","url":"git+https://github.com/bluesky-social/atproto.git","directory":"packages/crypto"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.7.0"},"dependencies":{"@noble/curves":"^1.7.0","@noble/hashes":"^1.6.1","uint8arrays":"3.0.0"},"devDependencies":{"jest":"^28.1.2","typescript":"^5.6.3","@bluesky-social/common":"^0.4.11"},"scripts":{"test":"jest ","build":"tsc --build tsconfig.build.json"},"_id":"@bluesky-social/crypto@0.4.4","bugs":{"url":"https://github.com/bluesky-social/atproto/issues"},"_integrity":"sha512-di2419X3eoofNACGUQYHNlVdb5guaC7m0HtXbJU5ihjfGfLV3IGrClR3wcim1lDK+5J3qZMYm1fDDbClOzoGmA==","_resolved":"/private/var/folders/cb/7sst87dj7jd40nc7b7q7h76r0000gn/T/061fd9689343b969d15ab1323953def1/bluesky-social-crypto-0.4.4.tgz","_from":"file:bluesky-social-crypto-0.4.4.tgz","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-di2419X3eoofNACGUQYHNlVdb5guaC7m0HtXbJU5ihjfGfLV3IGrClR3wcim1lDK+5J3qZMYm1fDDbClOzoGmA==","shasum":"4f33c55bccfe1f40a520043ab394295b5206f751","tarball":"https://registry.npmjs.org/@bluesky-social/crypto/-/crypto-0.4.4.tgz","fileCount":105,"unpackedSize":102240,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE+5Grl8yVMarG4sSXvP/972Kh+TGclgnhZLtnd2bIr9AiEA5TPR96ahdKj4tb0x+KWcicxnxFk74v0rzkB2A1N2mes="}]},"_npmUser":{"name":"web3km","email":"web3km@proton.me"},"directories":{},"maintainers":[{"name":"openweb3.io","email":"mtsocialdao@gmail.com"},{"name":"web3km","email":"web3km@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/crypto_0.4.4_1753545364350_0.7720526063921778"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-26T15:56:03.972Z","0.4.4":"2025-07-26T15:56:04.533Z","modified":"2025-07-26T15:56:04.834Z"},"maintainers":[{"name":"openweb3.io","email":"mtsocialdao@gmail.com"},{"name":"web3km","email":"web3km@proton.me"}],"description":"Library for cryptographic keys and signing in atproto","homepage":"https://atproto.com","keywords":["atproto","cryptography"],"repository":{"type":"git","url":"git+https://github.com/bluesky-social/atproto.git","directory":"packages/crypto"},"bugs":{"url":"https://github.com/bluesky-social/atproto/issues"},"license":"MIT","readme":"# @bluesky-social/crypto\n\nTypeScript library providing basic cryptographic helpers as needed in [atproto](https://atproto.com).\n\n[![NPM](https://img.shields.io/npm/v/@bluesky-social/crypto)](https://www.npmjs.com/package/@bluesky-social/crypto)\n[![Github CI Status](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml/badge.svg)](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)\n\nThis package implements the two currently supported cryptographic systems:\n\n- P-256 elliptic curve: aka \"NIST P-256\", aka secp256r1 (note the r), aka prime256v1\n- K-256 elliptic curve: aka \"NIST K-256\", aka secp256k1 (note the k)\n\nThe details of cryptography in atproto are described in [the specification](https://atproto.com/specs/cryptography). This includes string encodings, validity of \"low-S\" signatures, byte representation \"compression\", hashing, and more.\n\n## Usage\n\n```typescript\nimport { verifySignature, Secp256k1Keypair, P256Keypair } from '@bluesky-social/crypto'\n\n// generate a new random K-256 private key\nconst keypair = await Secp256k1Keypair.create({ exportable: true })\n\n// sign binary data, resulting signature bytes.\n// SHA-256 hash of data is what actually gets signed.\n// signature output is often base64-encoded.\nconst data = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])\nconst sig = await keypair.sign(data)\n\n// serialize the public key as a did:key string, which includes key type metadata\nconst pubDidKey = keypair.did()\nconsole.log(pubDidKey)\n\n// output would look something like: 'did:key:zQ3shVRtgqTRHC7Lj4DYScoDgReNpsDp3HBnuKBKt1FSXKQ38'\n\n// verify signature using public key\nconst ok = verifySignature(pubDidKey, data, sig)\nif (!ok) {\n  throw new Error('Uh oh, something is fishy')\n} else {\n  console.log('Success')\n}\n```\n\n## License\n\nThis project is dual-licensed under MIT and Apache 2.0 terms:\n\n- MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)\n- Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)\n\nDownstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.\n","readmeFilename":"README.md","_rev":"1-8fe30abe1850dd34db62e2841d11362b"}