{"_id":"@brandonblack/musig","_rev":"1-97c5a5794d0afff711da0aa75dab7922","name":"@brandonblack/musig","dist-tags":{"latest":"0.0.1-alpha.1"},"versions":{"0.0.1-alpha.0":{"name":"@brandonblack/musig","version":"0.0.1-alpha.0","description":"JS implementation of MuSig. 1-dependency MuSig key aggregation, tweaking, and signing.","main":"lib/index.js","module":"lib/esm/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc -d && tsc -p tsconfig.esm.json && npm run prettierout -- --write","build:release":"rollup -c rollup.config.js","lint":"tslint -p tsconfig.json -c tslint.json","format":"npm run prettier -- --write","format:ci":"npm run prettier -- --check && npm run prettierout -- --check","prettier":"prettier --print-width 100 --single-quote \"*.ts\" \"test/**/*.ts\"","prettierout":"prettier --print-width 100 --single-quote \"lib/**/*.js\"","test":"npm run prettier -- --check && npm run lint && npm run build && npm run coverage","nobuild:test":"jest","coverage":"jest --coverage","bench":"ts-node test/benchmark.ts"},"author":{"name":"Brandon Black"},"homepage":"https://github.com/brandonblack/musig-js","repository":{"type":"git","url":"git+https://github.com/brandonblack/musig-js.git"},"license":"MIT","browser":{"crypto":false},"devDependencies":{"@noble/secp256k1":"^1.7.0","@rollup/plugin-commonjs":"21.0.1","@rollup/plugin-node-resolve":"13.1.3","@types/create-hash":"^1.2.2","@types/create-hmac":"^1.1.0","@types/jest":"27.4.0","@types/node":"17.0.18","create-hash":"^1.2.0","create-hmac":"^1.1.7","jest":"27.4.5","micro-bmark":"0.1.3","prettier":"2.5.1","rollup":"2.67.2","tiny-secp256k1":"^2.2.1","ts-jest":"27.1.3","ts-node":"^10.9.1","tslint":"^6.1.3","typescript":"4.5.4"},"keywords":["musig","musig2","multisignature","multi-signature","tweak","secp256k1","secp","secp256","elliptic","elliptic curve","curve","signature","ecc","schnorr","sig","cryptography","security"],"exports":{".":{"import":"./lib/esm/index.js","default":"./lib/index.js"},"./index.d.ts":"./lib/index.d.ts","./base_crypto":{"import":"./lib/esm/base_crypto.js","default":"./lib/base_crypto.js"}},"jest":{"testRegex":"/test/(?!utils|benchmark).*?\\.ts","transform":{"^.+\\.ts$":"ts-jest"},"collectCoverageFrom":["*.ts"]},"dependencies":{},"gitHead":"5816c653367a64d219ec00c46f8ec0ff1f7e7028","bugs":{"url":"https://github.com/brandonblack/musig-js/issues"},"_id":"@brandonblack/musig@0.0.1-alpha.0","_nodeVersion":"14.19.1","_npmVersion":"6.14.16","_npmUser":{"name":"brandonblack","email":"brandon.aurelius.black@gmail.com"},"dist":{"integrity":"sha512-lgM+9UD4fpMTDCczx7V1csY+cQ8WXag8qRz/hwxrPATwzszfKb9IwnCggWJj7o7Ou/t2CFVqfiErmayLf3AW7g==","shasum":"7b65c9646545705fee60fdc064e2dc65dec4d7e0","tarball":"https://registry.npmjs.org/@brandonblack/musig/-/musig-0.0.1-alpha.0.tgz","fileCount":10,"unpackedSize":55253,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGDlm2Vd3bV9gARkJxr5R7nJTOgpWtEFHxn0EWZ4V0r1AiEAhIBIdc859DeLPTefdiXdWtmCBzwZ5iNjozsCU9kmNJE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj3ZIBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqt/hAAhIC8grp0gLkYeDfUIhDxWoCr4cjGvu84XjfUg9bang/TWQzp\r\n5lyUn9FBn1wM6vTM0m1++WsihM50hftJ1PwWm+e9M09yWM2N1dUNsbwTbTHq\r\nkdQIfMUdWXrLevABIMmIKyClbHlGHmLDCPn99djnqQPbwe0tBtJpVhz6+O3e\r\n8IX0LuhQCiYmUfkwS4zMBBuO6MmqYSwSwJpZiXbE1b1gOwsCeLi0ZvWktnA0\r\nKzFYfpN0DwT/Yyz6pIEBgWgkvgB6vtp/JVMc0d1lb4cLpf3RGkVbly2usiLS\r\nhb1fXqAZLXwdSC9j8cYvOZqPD5d6H81G+RgnWszi9YMzfBss6PtQk+nP6VSq\r\nOGrNPkoNjX3oun37RMhDNwRTPms5ntU29rS9ahgwbKtDeXBhZyncOwjrLEOq\r\nNJIu2Me8+io+Wl+uzNuI0GVf0zXj0rFbiMjD4L9NB3VT54dbZFMxJJy5MIwo\r\nm7XlMkmTBoj2phCMsM6WlTVB6AuSXxpTtWihWQDWHaOXbl17nRT/gMsdfmax\r\nPrpA9u5SMPjqQDK6BIP1K1h0Q7CFxGhf+00k4l/QoNFO4QRg0XjpG6EHSWQA\r\nou+0BwrE9qMGomKsJidi6GRBe4kcy8BGHqqZDgV1GLggiJW1ci3p8t7iDf6W\r\n3tqos/x6rt/r0bgvLXv72RDrlpmqG6eX1AQ=\r\n=eFK3\r\n-----END PGP SIGNATURE-----\r\n"},"directories":{},"maintainers":[{"name":"brandonblack","email":"brandon.aurelius.black@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/musig_0.0.1-alpha.0_1675465217445_0.6051527888629449"},"_hasShrinkwrap":false},"0.0.1-alpha.1":{"name":"@brandonblack/musig","version":"0.0.1-alpha.1","description":"JS implementation of MuSig. 1-dependency MuSig key aggregation, tweaking, and signing.","main":"lib/index.js","module":"lib/esm/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc -d && tsc -p tsconfig.esm.json && npm run prettierout -- --write","build:release":"rollup -c rollup.config.js","lint":"tslint -p tsconfig.json -c tslint.json","format":"npm run prettier -- --write","format:ci":"npm run prettier -- --check && npm run prettierout -- --check","prettier":"prettier --print-width 100 --single-quote \"*.ts\" \"test/**/*.ts\"","prettierout":"prettier --print-width 100 --single-quote \"lib/**/*.js\"","test":"npm run prettier -- --check && npm run lint && npm run build && npm run coverage","nobuild:test":"jest","coverage":"jest --coverage","bench":"ts-node test/benchmark.ts"},"author":{"name":"Brandon Black"},"homepage":"https://github.com/brandonblack/musig-js","repository":{"type":"git","url":"git+https://github.com/brandonblack/musig-js.git"},"license":"MIT","browser":{"crypto":false},"devDependencies":{"@noble/curves":"^0.9.0","@rollup/plugin-commonjs":"^24.0.1","@rollup/plugin-node-resolve":"^15.0.1","@types/create-hash":"^1.2.2","@types/create-hmac":"^1.1.0","@types/jest":"^29.5.0","@types/node":"^18.15.10","create-hash":"^1.2.0","create-hmac":"^1.1.7","jest":"^29.5.0","micro-bmark":"^0.3.1","prettier":"^2.8.7","rollup":"^3.20.2","tiny-secp256k1":"^2.2.1","ts-jest":"^29.0.5","ts-node":"^10.9.1","tslint":"^6.1.3","typescript":"^5.0.2"},"keywords":["musig","musig2","multisignature","multi-signature","tweak","secp256k1","secp","secp256","elliptic","elliptic curve","curve","signature","ecc","schnorr","sig","cryptography","security"],"exports":{".":{"import":"./lib/esm/index.js","default":"./lib/index.js"},"./index.d.ts":"./lib/index.d.ts","./base_crypto":{"import":"./lib/esm/base_crypto.js","default":"./lib/base_crypto.js"}},"jest":{"testRegex":"/test/(?!utils|benchmark).*?\\.ts","transform":{"^.+\\.ts$":"ts-jest"},"collectCoverageFrom":["*.ts"]},"gitHead":"488ad09fccdee5cd4b91d1a17baeb96b2af69135","bugs":{"url":"https://github.com/brandonblack/musig-js/issues"},"_id":"@brandonblack/musig@0.0.1-alpha.1","_nodeVersion":"14.21.3","_npmVersion":"6.14.18","_npmUser":{"name":"brandonblack","email":"brandon.aurelius.black@gmail.com"},"dist":{"integrity":"sha512-00RbByQG85lSzrkDjCblzrUc2n1LJAPPrEMHS4oMg+QckE0kzjd26JytT6yx6tNU2+aOXfK7O4kGW/sKVL67cw==","shasum":"0895f59977bedf519099ff6e2fcbcbced30bc761","tarball":"https://registry.npmjs.org/@brandonblack/musig/-/musig-0.0.1-alpha.1.tgz","fileCount":10,"unpackedSize":55231,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICeL1uVcjBdvpyfVf3+d5jyJsVKz2RnN0HCHU8D93MeCAiEA0guv7FD/VrCu01XRJ2MHGmKdChpfbJCrVL77nU+RN9A="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkImGHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqqnhAAjdQTheUJYZKldXqIdW/M7oUlRQCaOIqKCJBOuwhROR/fCHOh\r\nlnj5ZKEvih3NT3T6WAuuyFWtqrFE6Ksrck2kmg55TiOKedS6JaVvsb3/eelY\r\n8sEyAnD+4m7DbLBkuxNvgFC8W+2m9t2TkAFJrd7x2pe6QeHRe+bkotN27ppT\r\n/YW8lsHtJUgjgEZvhhEITj4cJYUX3sHcZ6ItdNFVNS57yg+loW+p3/EW0MuA\r\nkI2986gMBsB1pOLCQcefM6vFVHLqrH4TMVprplCRpP6J6iHAUed3Ktd9FqqB\r\neb+TvDuAsxf1fItC/q7U23XD+wt48csYbBj+JhjeyhC/zbXlhbbaFF441cdJ\r\n9njIsdbI9oJvz07LSIP7QpNipDILP/xph1p/fQpI5RyFo2iVNJqErzuPPEPG\r\nhFXcWZu/vYPfph3VmAiWo3jLh+GUB9aY4lDzXaNtTMJROAqklkofy+u/97LK\r\nVUqO8bu8bwQTTWnbg80LgC9M4Cp1OmaiO66uUYTnlpS0M26x7kTMTt2EtSkU\r\nW7FlH+ZXs3yBgJgwARnG69hZcaYgh7AyOYhxdEPL6RcfPGSn1EOyO8NwTBfw\r\nwP7E+iH1h6kBy9MN2j3iWdFbfDBHIPfHODg7MUg1TWNpAEZWpxYUf/Vxr2U3\r\nXcx7icYx019V4auH7amJlOqmULy7FSHwPq4=\r\n=fyge\r\n-----END PGP SIGNATURE-----\r\n"},"directories":{},"maintainers":[{"name":"brandonblack","email":"brandon.aurelius.black@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/musig_0.0.1-alpha.1_1679974791432_0.5497526579595804"},"_hasShrinkwrap":false}},"time":{"created":"2023-02-03T23:00:17.388Z","0.0.1-alpha.0":"2023-02-03T23:00:17.642Z","modified":"2023-03-28T03:39:51.699Z","0.0.1-alpha.1":"2023-03-28T03:39:51.595Z"},"maintainers":[{"name":"brandonblack","email":"brandon.aurelius.black@gmail.com"}],"description":"JS implementation of MuSig. 1-dependency MuSig key aggregation, tweaking, and signing.","homepage":"https://github.com/brandonblack/musig-js","keywords":["musig","musig2","multisignature","multi-signature","tweak","secp256k1","secp","secp256","elliptic","elliptic curve","curve","signature","ecc","schnorr","sig","cryptography","security"],"repository":{"type":"git","url":"git+https://github.com/brandonblack/musig-js.git"},"author":{"name":"Brandon Black"},"bugs":{"url":"https://github.com/brandonblack/musig-js/issues"},"license":"MIT","readme":"# MuSig in TypeScript\n\nZero dependency implementation of the [MuSig Spec](https://github.com/ElementsProject/secp256k1-zkp/blob/master/doc/musig-spec.mediawiki).\n\nSimilar to [bitcoinjs/BIP32](https://github.com/bitcoinjs/bip32), requires a\nuser injected secp256k1 implementation. Two examples provided in\n`test/utils.ts`.\n\nWorks with ECMAScript 2019 if you provide a complete implementation of the\nCrypto interface. If you want to use `base_crypto` as `test/utils.ts` does,\nthen requires ECMAScript 2020 BigInt.\n\n# Usage\n\n```shell\nnpm i\nnpm run test # runs build\nnpm run bench\n```\n\nThis example uses `Buffer` for convenience, but it is not required, any\n`Uint8Array` will do.\n\n```typescript\nimport { MuSigFactory, Nonce } from '.';\nimport { tinyCrypto } from './test/utils';\nimport * as tiny from 'tiny-secp256k1';\n\nconst musig = MuSigFactory(tinyCrypto);\n\nconst fromHex = (hex: string): Uint8Array => Buffer.from(hex, 'hex');\nconst toHex = (bytes: Uint8Array): string => Buffer.from(bytes).toString('hex');\nconst secretKey1 = fromHex('be01d8dcf3879a0fec05130ca95d35bf7823833e3cdf91e310408606717055d9');\nconst pubKey1 = fromHex('648c0c80c8520875c22a1cf31cd718b72a50e381731bc7f8efec9944074cb21b');\nconst secretKey2 = fromHex('644b07a5cb70f68316cd9a51cabdc61c4d0b1f38b189d0c92370a3844fd0241f');\nconst pubKey2 = fromHex('8c9444613a1bb8b442b81cc7fbf81a186a34d7c4e596362543e17dde3efdc4b3');\nconst tweak = fromHex('8df63a82e5e71884bb16e2896e12ba2b7fe0e670d466be03b578fc435d5c9876');\n\nconst { publicKey, keyAggSession } = musig.keyAgg(\n  [pubKey1, pubKey2],\n  { tweaks: [tweak], tweaksXOnly: [true] }\n);\n\nconst msg = fromHex('f1d1d6ef2d97319149aaed92c69ebb21d6c54c0fc4e908f4f4ee42a1e5b8b854');\n\n// Signing round 1 - generate nonces, share public nonces\n\nconst nonce1: { secretNonce?: Uint8Array, publicNonce: Uint8Array } = musig.nonceGen({\n  sessionId: fromHex('0000000000000000000000000000000000000000000000000000000000000001'),\n  secretKey: secretKey1,\n  msg,\n  publicKey,\n});\n\nconst nonce2: { secretNonce?: Uint8Array, publicNonce: Uint8Array } = musig.nonceGen({\n  sessionId: fromHex('0000000000000000000000000000000000000000000000000000000000000001'),\n  secretKey: secretKey2,\n  msg,\n  publicKey,\n});\n\nconst sharedPublicNonces = [nonce1.publicNonce, nonce2.publicNonce];\n\nconst aggNonce = musig.nonceAgg(sharedPublicNonces);\n\n// Signing round 2 - generate and share partial sigs, verify and aggregate\n\nconst { sig: sig1, signingSession: signingSession1 } = musig.partialSign({\n  msg,\n  secretKey: secretKey1,\n  nonce: nonce1 as Nonce,\n  aggNonce,\n  keyAggSession\n});\ndelete nonce1.secretNonce;\n\nconst { sig: sig2, signingSession: signingSession2 } = musig.partialSign({\n  msg,\n  secretKey: secretKey2,\n  nonce: nonce2 as Nonce,\n  aggNonce,\n  keyAggSession\n});\ndelete nonce2.secretNonce;\n\nconst sharedSigs = [sig1, sig2];\n\nconst check2By1 = musig.partialVerify({\n  sig: sharedSigs[1],\n  msg,\n  publicKey: pubKey2,\n  publicNonce: sharedPublicNonces[1],\n  aggNonce,\n  keyAggSession,\n  signingSession: signingSession1 // Optional\n});\n\nconst check1By2 = musig.partialVerify({\n  sig: sharedSigs[0],\n  msg,\n  publicKey: pubKey1,\n  publicNonce: sharedPublicNonces[0],\n  aggNonce,\n  keyAggSession,\n  signingSession: signingSession2 // Optional\n});\n\nconsole.log(`check2By1: ${!!check2By1}, check1By2: ${!!check1By2}`);\n\nconst signingSession = musig.createSigningSession(aggNonce, msg, keyAggSession);\n// All of the signing sessions are interchangeable, and derived from public information\nconst sig = musig.signAgg(sharedSigs, signingSession);\n\nconsole.log(toHex(sig));\n// 13a8d88bb5727fe945293f81f0f1000eecb8ded5ca950bcfb74d6536d456372b9ae00ccb9cbacc00a3bca07129920b88d4df4f5c24ece1f7159ff94c1dde1bba\n\nconst valid = tiny.verifySchnorr(msg, publicKey, sig);\nconsole.log(`final sig valid: ${valid}`);\n```\n","readmeFilename":"README.md"}