{"_id":"@brynjarrr/xchain-crypto","_rev":"1-53d5693a56cd628becb108098cc27b2d","name":"@brynjarrr/xchain-crypto","dist-tags":{"latest":"0.2.6"},"versions":{"0.2.6":{"name":"@brynjarrr/xchain-crypto","version":"0.2.6","description":"XChain Crypto is a crypto module needed by all XChain clients.","main":"lib/index.js","module":"lib/index.es.js","jsnext:main":"lib/index.es.js","types":"lib/index.d.ts","scripts":{"clean":"rimraf lib/**","build":"yarn clean && rollup -c","lint":"eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0","test":"jest --coverage","prepublishOnly":"yarn build"},"repository":{"type":"git","url":"git+ssh://git@github.com/xchainjs/xchainjs-lib.git"},"jest":{"preset":"ts-jest","testEnvironment":"node","testPathIgnorePatterns":["<rootDir>/lib","<rootDir>/node_modules/"]},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.{js,ts}":["eslint --fix","git add"]},"keywords":[],"author":{"name":"Thorchain"},"license":"MIT","devDependencies":{"@types/bech32":"^1.1.2","@types/bip39":"^3.0.0","@types/crypto-js":"^4.0.2","@types/hdkey":"^2.0.0","@types/node":"^14.14.31","@types/uuid":"^8.3.1"},"dependencies":{"bech32":"^2.0.0","bip39":"^3.0.4","crypto-js":"^4.1.1","foundry-primitives":"^0.2.1","hdkey":"^2.0.1","uuid":"^8.3.2"},"gitHead":"515ef43a4f0e3aa11644c69f7025caf0f0a0c1db","bugs":{"url":"https://github.com/xchainjs/xchainjs-lib/issues"},"homepage":"https://github.com/xchainjs/xchainjs-lib#readme","_id":"@brynjarrr/xchain-crypto@0.2.6","_nodeVersion":"16.5.0","_npmVersion":"lerna/3.22.1/node@v16.5.0+arm64 (darwin)","dist":{"integrity":"sha512-5GPoxSBB6VZUCK5Xt7WeexOcGhCdA5TKxf/TK69fARKFEqWhrEMs2Jv7GAgsP9AlmtO1LJRNmRXpx0FXxNX2jw==","shasum":"fcfd540e2c8338f3d097e349e9817b095c67198e","tarball":"https://registry.npmjs.org/@brynjarrr/xchain-crypto/-/xchain-crypto-0.2.6.tgz","fileCount":12,"unpackedSize":7999922,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiPbUCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrqhBAAi/R0cPul8iRhswPBEpBzaFSXPnesvAxiij7Zu/xEi7c+l8zf\r\neb8AFjvM0qlqnL0g/FQR2l6s+HwagWy3XK209kQcMqCJzqRgvFcZkh1IWc7i\r\nmhM4OZ71docmNqzA3FH0ksVrhu1smSaN9k9ZxaeY3nbz2TTbe5cJJMlJg3Yd\r\nARhr/mSI1AsEaQmpcFVaMp9rnUbEnD4WU32UVuclVAabBOs6prjAc/61CGVL\r\nvVRK8yKtFY+Ldi5CPLQRQwOKjkm99xoiynrfiWVzvY/hgvUZpMSuhJu6SF7q\r\nRgG4HWzoEbq+NCY4U2bT4LzJWV3hkXoQsgnUzk5/VK2EbWEEMjQTCi/c+ThI\r\niYTbvQNUOiLQGRy0IfqUezeY8GwzlL7zMj+GFJX0/Yiv2LCl3fWmKO2WNilR\r\nOYM3RwQ2rPb16LruOtpX1PyEZZdi/68N2Va/pFsNhD0glAkFUloWZWZD68on\r\nH0oPFYXabYdERs7V5/FQYUUqRnHwEjr38h/eCV7s7Jk87yjrDCcucTxBFVMd\r\nxL95yLjiDXSirPlLljHZ0iFglTMWTWcbYem+3f3B4oFltH7flVzefk/BGK19\r\nX2Rx9Ip3JEPT4h4fEXLMqhs2XpS/k8MHpmjCJdQY2BmwqE7YXZ+D8OeEoyRv\r\n1AT0lKfB1carfBhYxNMJsZDRluXAfUTD7hI=\r\n=xbeC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDOlu9bd6QqutemdTEUpq1ZdZgkLGSfnlsO4W/tq7YXaAiAlPjmL5taTT583EXVjozaRsG3WgTA316Znu8I7quqnmQ=="}]},"_npmUser":{"name":"brynjarrr","email":"coinage_trinity_0a@icloud.com"},"directories":{},"maintainers":[{"name":"brynjarrr","email":"coinage_trinity_0a@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xchain-crypto_0.2.6_1648211202548_0.01592633704414359"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-25T12:26:42.491Z","0.2.6":"2022-03-25T12:26:42.803Z","modified":"2022-04-04T20:50:14.624Z"},"maintainers":[{"name":"brynjarrr","email":"coinage_trinity_0a@icloud.com"}],"description":"XChain Crypto is a crypto module needed by all XChain clients.","homepage":"https://github.com/xchainjs/xchainjs-lib#readme","keywords":[],"repository":{"type":"git","url":"git+ssh://git@github.com/xchainjs/xchainjs-lib.git"},"author":{"name":"Thorchain"},"bugs":{"url":"https://github.com/xchainjs/xchainjs-lib/issues"},"license":"MIT","readme":"# XCHAIN-CRYPTO\n\nThe XCHAIN CRYPTO package is a crypto package used by all `XCHAIN` clients.\n\nXCHAIN-CRYPTO encrypts a master phrase to a keystore. This keystore can then be exported to other XCHAIN wallets or stored securely.\n\nUsers can export their phrase and import them into other wallets since it is a BIP39 compatible phrase.\n\n## Design\n\nTypically keystore files encrypt a `seed` to a file, however this is not appropriate or UX friendly, since the phrase cannot be recovered after the fact.\n\nCrypto design:\n\n[entropy] -> [phrase] -> [seed] -> [privateKey] -> [publicKey] -> [address]\n\nInstead, XCHAIN-CRYPTO stores the phrase in a keystore file, then decrypts and passes this phrase to other clients:\n\n[keystore] -> XCHAIN-CRYPTO -> [phrase] -> ChainClient\n\nThe ChainClients can then convert this into their respective key-pairs and addresses.\nUsers can also export their phrases after the fact, ensuring they have saved it securely. This could enhance UX onboarding since users aren't forced to write their phrases down immediately for empty or test wallets.\n\n```js\n// Crypto Constants for xchain\nconst cipher = 'aes-128-ctr'\nconst kdf = 'pbkdf2'\nconst prf = 'hmac-sha256'\nconst dklen = 32\nconst c = 262144\nconst hashFunction = 'sha256'\nconst meta = 'xchain-keystore'\n```\n\n## Installation\n\n- Install `@xchainjs/xchain-crypto` from `npm`\n\n```bash\nyarn add @xchainjs/xchain-crypto\n```\n\n## Usage\n\n### Basic usage\n\n```js\nimport { generatePhrase, validatePhrase, encryptToKeyStore, decryptFromKeystore } from '../src/crypto'\n\nconst phrase = generatePhrase()\nconst isCorrect = validatePhrase(phrase)\nconst password = 'thorchain'\nconst keystore = await encryptToKeyStore(phrase, password)\nconst phraseDecrypted = await decryptFromKeystore(keystore, password)\n```\n\nKeystore Type\n\n```js\nexport type Keystore = {\n  address: string\n  crypto: {\n    cipher: string\n    ciphertext: string\n    cipherparams: {\n      iv: string\n    }\n    kdf: string\n    kdfparams: {\n      prf: string\n      dklen: number\n      salt: string\n      c: number\n    }\n    mac: string\n  }\n  id: string\n  version: number\n  meta: string\n}\n```\n\n### Error handling\n\n## Development\n\n### Build\n\n```bash\nyarn build\n```\n\n### Tests\n\n```bash\nyarn test\n```\n","readmeFilename":"README.md"}