{"_id":"@0xdoublesharp/sloth-vdf","_rev":"1-638b12c30c1fb7038eebdcd61e69105e","name":"@0xdoublesharp/sloth-vdf","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@0xdoublesharp/sloth-vdf","version":"0.0.1","description":"Sloth Verifiable Delay Function for Javascript and Solidity 0.8","scripts":{"build":"tsc && npx hardhat export-abi","compile":"npx hardhat compile","prepare":"npm run build"},"keywords":["solidity","vdf","verifiable delay function","sloth","sloth vdf","randomness","random","crypto","web3","EVM"],"author":{"name":"@0xDoubleSharp"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"@0xdoublesharp/unsafe-math":"^0.0.8","@nomicfoundation/hardhat-chai-matchers":"^1.0.6","@nomicfoundation/hardhat-network-helpers":"^1.0.8","@nomiclabs/hardhat-ethers":"2.2.2","@nomiclabs/hardhat-etherscan":"3.1.7","@nomiclabs/hardhat-solhint":"^3.0.0","@typechain/ethers-v5":"^10.2.0","@typechain/hardhat":"^6.1.5","@types/chai":"^4.3.4","@types/mocha":"^10.0.1","@types/node":"^18.15.3","@typescript-eslint/eslint-plugin":"^5.55.0","@typescript-eslint/parser":"^5.55.0","chai":"4.3.7","dotenv":"16.0.3","eslint":"8.36.0","eslint-config-prettier":"8.7.0","hardhat":"^2.13.0","hardhat-abi-exporter":"^2.10.1","hardhat-contract-sizer":"^2.8.0","hardhat-deploy":"^0.11.25","hardhat-deploy-ethers":"^0.3.0-beta.13","hardhat-gas-reporter":"^1.0.9","hardhat-spdx-license-identifier":"^2.1.0","hardhat-storage-layout":"^0.1.7","hardhat-tracer":"^2.1.2","hardhat-watcher":"^2.5.0","prettier":"2.8.4","prettier-plugin-solidity":"1.1.3","solhint":"3.4.1","solhint-plugin-prettier":"^0.0.5","solidity-coverage":"0.8.2","ts-generator":"^0.1.1","ts-node":"~10.9.1","tslint":"~6.1.3","typechain":"^8.1.1","typescript":"4.9"},"engines":{"node":">=16.0.0"},"gitHead":"1357d525f83a3f3e8e6ddc349b61647e16c860c2","_id":"@0xdoublesharp/sloth-vdf@0.0.1","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-n60yMFpSrVccEvQVbS6mNUCHtHpKF9vTwY2O2xe+lSbu+IoCkJh0OcSvXS/fdcJgdVMsEqEUMZEC6uXwSbe7qQ==","shasum":"c074de29684bea89e20295ff84df469a2624c5c9","tarball":"https://registry.npmjs.org/@0xdoublesharp/sloth-vdf/-/sloth-vdf-0.0.1.tgz","fileCount":39,"unpackedSize":43408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCgUu190F8a6LOe76LOEmRQUWjVGcOepqCdgXfQaiYmNgIhAKwsNrXxDj/SRLzp1f3qc4WdsjgXW5ychX+/FLHmNN+L"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkEhx2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr8zA//T1jFCUC6R8DShyLBX7MhcJ/qgPS9VLSZk72XDf3PAMLhrBB9\r\nb3xieem7KejffvuojfQ2ltZ3B6FBq6EobNEl0HIewqCp6zi1tWs43w9nf/xr\r\nr1F1RmotbxcgTcVY7xjDCHffW46gSkO2sxdfRuAvIwwOVJqaP1WgU32bT5F4\r\ncaHqOSSYE2+dtzLejNKwTdJSjaJjOXIVSmYKmX6DpVKTjrQ04ExgVr6ZrqJX\r\nnr6wDu1HcEHfQCmYgAlvdS9nUAc0iATmIlspJAGmlKG/gCO3txUleRJOl7+G\r\n45yEfIYBbgv8OE2ZLeJdY+nOGB/a8QZVvdI8DIFf99/SKbAh7DbkSi0HdbI5\r\nSWSADi4L1E6hMTgTLU7S4FQju2MUZFCpF38XO8QU7lkRXwGGLKEXEpAPu2CD\r\nI1L0J1OeXzkDWLzjO4Yf4jP0ddwDOZAcLLUcU/aSA+n8OuaCXGo9ro/Ftt0B\r\nxoUCWPP2rt2exiwRglOkSruATJC14lZnuzkQFLdDd6QIWWnoUwAyo0JHugKb\r\njN5M6TRI0feEixQULSD4F7OT7TuU6qALloqx4kGhAAPdvb9G+4oxTGOStHiH\r\nBCJpUVOH+UdvLofculgtAPUw1nY+lP9kSmwa8iKp5FIFXTc8vt8wmAB5mcwq\r\n+C7TncdMePkv1gP2fXfBVbKc8quZm/kagqg=\r\n=I5Qg\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"doublesharp","email":"jsilver@doublesharp.com"},"directories":{},"maintainers":[{"name":"doublesharp","email":"jsilver@doublesharp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sloth-vdf_0.0.1_1678908533832_0.38031009237294655"},"_hasShrinkwrap":false},"0.0.2":{"name":"@0xdoublesharp/sloth-vdf","version":"0.0.2","description":"Sloth Verifiable Delay Function for Javascript and Solidity 0.8","repository":{"type":"git","url":"git+https://github.com/doublesharp/sloth-vdf.git"},"scripts":{"build":"tsc && npx hardhat export-abi","compile":"npx hardhat compile","prepare":"npm run build"},"keywords":["solidity","vdf","verifiable delay function","sloth","sloth vdf","randomness","random","crypto","web3","EVM"],"author":{"name":"@0xDoubleSharp"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"@0xdoublesharp/unsafe-math":"^0.0.12","@nomicfoundation/hardhat-chai-matchers":"^1.0.6","@nomicfoundation/hardhat-network-helpers":"^1.0.8","@nomiclabs/hardhat-ethers":"2.2.2","@nomiclabs/hardhat-etherscan":"3.1.7","@nomiclabs/hardhat-solhint":"^3.0.0","@typechain/ethers-v5":"^10.2.0","@typechain/hardhat":"^6.1.5","@types/chai":"^4.3.4","@types/mocha":"^10.0.1","@types/node":"^18.15.6","@typescript-eslint/eslint-plugin":"^5.56.0","@typescript-eslint/parser":"^5.56.0","chai":"4.3.7","dotenv":"16.0.3","eslint":"8.36.0","eslint-config-prettier":"8.8.0","hardhat":"^2.13.0","hardhat-abi-exporter":"^2.10.1","hardhat-contract-sizer":"^2.8.0","hardhat-deploy":"^0.11.25","hardhat-deploy-ethers":"^0.3.0-beta.13","hardhat-gas-reporter":"^1.0.9","hardhat-spdx-license-identifier":"^2.1.0","hardhat-storage-layout":"^0.1.7","hardhat-tracer":"^2.1.2","hardhat-watcher":"^2.5.0","prettier":"2.8.6","prettier-plugin-solidity":"1.1.3","solhint":"3.4.1","solhint-plugin-prettier":"^0.0.5","solidity-coverage":"0.8.2","ts-generator":"^0.1.1","ts-node":"~10.9.1","tslint":"~6.1.3","typechain":"^8.1.1","typescript":"5.0.2"},"gitHead":"85ebed76d19a506c36bb624365ee88daef5adabf","bugs":{"url":"https://github.com/doublesharp/sloth-vdf/issues"},"homepage":"https://github.com/doublesharp/sloth-vdf#readme","_id":"@0xdoublesharp/sloth-vdf@0.0.2","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-Qy6V7vfHhHjI4XboUKBFcOf4r4XQ9PWQCu3HmbIbiBlLpwqRCr8EJnSYq7vsqi6rKbj9OnTIbhPEfOOe6e1dmQ==","shasum":"a23286bd816e3efa002fea022aa33cda78083149","tarball":"https://registry.npmjs.org/@0xdoublesharp/sloth-vdf/-/sloth-vdf-0.0.2.tgz","fileCount":39,"unpackedSize":43428,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGe5nq/AinYB+MEVyya3tSQhWfATnxFmZXNfddD9nJowAiEAw3HNYf6hydUWsFULd0atglEpT10NjazPnVgPCmSvh0A="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkHRZGACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoWBw//cnaRI6ltCJf48bSW6UU22n4sjntjyQU1TklsLQWXNKb/bHPi\r\nETOhrk/oEiKUpEueJBwEZh1f3zCayih3Xw4fNVzcRxg4DrQQ10qAnwXBp6RM\r\ncqKRONQp7D+Hsr5Z+wJA11LsGNgFxT2vvdZxghVNIMWsReBgHuYNPtoInPxt\r\nS49XKpHwPPW0wqfju4356fn7Ht6CBNhallRqfsdKn86V1sQsgDXwWK7bcmGG\r\nhvQMynx6c+hgfelvy8yyRItbT8x85qYz6/Znj2n0kNrQ4r8JQQe7WDz6JRA/\r\nttr5J5rtS3nGV0J82KuEognrL+7qla1jnM87c88UUUdjE1QeM5fR3Z0GnXJF\r\nJE3jEHQ0zLYAK3nogvtFRSst/lcmUE370u9rSHRe9cdrASsnwpD4TcV1hzE8\r\ngh2pXu3lS5mQN4JLpqEMsLJzRsY4Q26xniotLTN1jPC50IwpOKO2fL+oX2Ji\r\nd/RDl3te2PA5bQS8rUGXpNjrzHK6LjVheiZFeoFMnML9FnNEuixWOCrnHMxG\r\n/DoXPKr63xQsIHjEVAVct2CSXsXRtK3k8+UH4Cc0bHtvm70KkwUqqZQPsp+I\r\nHXDhwSG5IOTPMxLtksf1PW2t5YLImZgzLY1QPC3ilkg/jgFZNfOVT//gqrrq\r\nBitztii7m76v5dviJlLTbfNyHihxn0Hz8aE=\r\n=0CHD\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"doublesharp","email":"jsilver@doublesharp.com"},"directories":{},"maintainers":[{"name":"doublesharp","email":"jsilver@doublesharp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sloth-vdf_0.0.2_1679627845875_0.8153995623603092"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-15T19:28:53.732Z","0.0.1":"2023-03-15T19:28:54.031Z","modified":"2023-03-24T03:17:26.204Z","0.0.2":"2023-03-24T03:17:26.076Z"},"maintainers":[{"name":"doublesharp","email":"jsilver@doublesharp.com"}],"description":"Sloth Verifiable Delay Function for Javascript and Solidity 0.8","keywords":["solidity","vdf","verifiable delay function","sloth","sloth vdf","randomness","random","crypto","web3","EVM"],"author":{"name":"@0xDoubleSharp"},"license":"MIT","readme":"# Sloth Verifiable Delay Function\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/doublesharp/sloth-vdf/main/sloth.svg\" height=\"50\"/>\n</p>\n\nThis module implements the Sloth VDF algorithm in JavaScript, TypeScript, and Soldity 0.8 for generating provable random numbers.\n\n## Install\n\n```shell\nnpm install -D @0xdoublesharp/sloth-vdf\n```\n\n```shell\nyarn add -D @0xdoublesharp/sloth-vdf\n```\n\n## Solidity\n\n```ts\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { SlothVDF } from '@0xdoublesharp/sloth-vdf/contracts/SlothVDF.sol';\n\ncontract RandomVDFv1 {\n  // large prime\n  uint256 public prime = 432211379112113246928842014508850435796007;\n  // adjust for block finality\n  uint256 public iterations = 1000;\n  // increment nonce to increase entropy\n  uint256 private nonce;\n  // address -> vdf seed\n  mapping(address => uint256) public seeds;\n\n  uint256 public proof;\n\n  error InvalidProof();\n  error AlreadyProven();\n\n  function createSeed() external payable {\n    // commit funds/tokens/etc here\n    // create a pseudo random seed as the input\n    uint256 _nonce = nonce++;\n    seeds[msg.sender] = uint256(\n      keccak256(abi.encodePacked(msg.sender, _nonce, block.timestamp, blockhash(block.number - 1)))\n    );\n  }\n\n  function prove(uint256 _proof) external {\n    if (proof != 0) revert AlreadyProven();\n    if (!SlothVDF.verify(_proof, seeds[msg.sender], prime, iterations)) revert InvalidProof();\n\n    // use the proof as a provable random number\n    proof = _proof;\n  }\n}\n```\n\n### JavaScript / TypeScript\n\n```ts\ndescribe('Sloth VDF', () => {\n  it('Prove', async () => {\n    const { sender, randomVDFv1 } = await loadFixture(fixtures);\n\n    const prime = BigInt((await randomVDFv1.prime()).toString());\n    const iterations = BigInt((await randomVDFv1.iterations()).toNumber());\n    console.log('prime', prime.toString());\n    console.log('iterations', iterations.toString());\n\n    const tx = await randomVDFv1.createSeed();\n    await tx.wait();\n\n    const seed = BigInt((await randomVDFv1.seeds(sender.address)).toString());\n    console.log('seed', seed.toString());\n\n    let start = Date.now();\n    const badproof = sloth.computeBeacon(seed, prime, BigInt(1));\n    console.log('compute time', Date.now() - start, 'ms', 'bad proof', badproof);\n    start = Date.now();\n    const proof = sloth.computeBeacon(seed, prime, iterations);\n    console.log('compute time', Date.now() - start, 'ms', 'vdf proof', proof);\n\n    await expect(randomVDFv1.prove(badproof)).to.be.revertedWithCustomError(randomVDFv1, 'InvalidProof');\n    await expect(randomVDFv1.prove(proof)).to.not.be.reverted;\n    await expect(randomVDFv1.prove(proof)).to.be.revertedWithCustomError(randomVDFv1, 'AlreadyProven');\n  });\n});\n```\n","readmeFilename":"README.md","homepage":"https://github.com/doublesharp/sloth-vdf#readme","repository":{"type":"git","url":"git+https://github.com/doublesharp/sloth-vdf.git"},"bugs":{"url":"https://github.com/doublesharp/sloth-vdf/issues"}}