├── public ├── assets │ ├── js │ │ ├── app.js │ │ ├── .DS_Store │ │ ├── jquery │ │ │ └── .DS_Store │ │ ├── particles │ │ │ ├── .DS_Store │ │ │ ├── particles.json │ │ │ └── particles.min.js │ │ └── wallet │ │ │ ├── asciihex.js │ │ │ ├── crypto-min.js │ │ │ ├── crypto-sha256.js │ │ │ ├── crypto-sha256-hmac.js │ │ │ ├── ripemd160.js │ │ │ ├── sha512.js │ │ │ ├── aes.js │ │ │ ├── ellipticcurve.js │ │ │ └── qrcode.js │ ├── .DS_Store │ ├── css │ │ ├── .DS_Store │ │ ├── normalize.min.css │ │ └── styles.css │ ├── img │ │ ├── .DS_Store │ │ ├── btc-eth-bg.png │ │ ├── footer-logo.png │ │ ├── bithereum-top.png │ │ ├── favicon │ │ │ ├── .DS_Store │ │ │ ├── favicon.ico │ │ │ ├── apple-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon-96x96.png │ │ │ ├── ms-icon-70x70.png │ │ │ ├── ms-icon-144x144.png │ │ │ ├── ms-icon-150x150.png │ │ │ ├── ms-icon-310x310.png │ │ │ ├── android-icon-36x36.png │ │ │ ├── android-icon-48x48.png │ │ │ ├── android-icon-72x72.png │ │ │ ├── android-icon-96x96.png │ │ │ ├── apple-icon-114x114.png │ │ │ ├── apple-icon-120x120.png │ │ │ ├── apple-icon-144x144.png │ │ │ ├── apple-icon-152x152.png │ │ │ ├── apple-icon-180x180.png │ │ │ ├── apple-icon-57x57.png │ │ │ ├── apple-icon-60x60.png │ │ │ ├── apple-icon-72x72.png │ │ │ ├── apple-icon-76x76.png │ │ │ ├── android-icon-144x144.png │ │ │ ├── android-icon-192x192.png │ │ │ ├── apple-icon-precomposed.png │ │ │ ├── browserconfig.xml │ │ │ └── manifest.json │ │ ├── nodes-bottom.png │ │ └── wallets │ │ │ ├── .DS_Store │ │ │ ├── wallet-mew.png │ │ │ ├── wallet-jaxx.png │ │ │ ├── wallet-ledger.jpg │ │ │ ├── wallet-trezor.png │ │ │ ├── wallet-imtoken.jpg │ │ │ └── wallet-metamask.png │ └── fonts │ │ ├── .DS_Store │ │ ├── aquatico │ │ ├── .DS_Store │ │ └── Aquatico-Regular.otf │ │ └── hk-grotesk │ │ ├── HKGrotesk-Bold.otf │ │ ├── HKGrotesk-Light.otf │ │ ├── HKGrotesk-Italic.otf │ │ ├── HKGrotesk-Medium.otf │ │ ├── HKGrotesk-Regular.otf │ │ ├── HKGrotesk-SemiBold.otf │ │ ├── HKGrotesk-BoldItalic.otf │ │ ├── HKGrotesk-LightItalic.otf │ │ ├── HKGrotesk-MediumItalic.otf │ │ ├── HKGrotesk-SemiBoldItalic.otf │ │ └── SIL Open Font License.txt ├── views │ ├── page-ethredeem.html │ ├── .DS_Store │ └── partials │ │ ├── .DS_Store │ │ ├── partial-footer.html │ │ ├── partial-header.html │ │ ├── partial-header-condensed.html │ │ ├── partial-ethredeem.html │ │ └── layout-base.html └── .DS_Store ├── .gitignore ├── .DS_Store ├── sass ├── .DS_Store └── styles.scss ├── .sass-cache ├── 29a37499c8e55df94962afc59d3975f5da105a80 │ └── styles.scssc ├── 642469386cb4ca8cc232c217207382b59264e9ea │ └── styles.scssc └── a299dec5700977e8d72060fd4ea120e60f532e02 │ └── styles.scssc ├── config.rb ├── README.md ├── package.json └── server.js /public/assets/js/app.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /public/views/page-ethredeem.html: -------------------------------------------------------------------------------- 1 | {{#embed "partial-ethredeem"}}{{/embed}} 2 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/.DS_Store -------------------------------------------------------------------------------- /sass/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/sass/.DS_Store -------------------------------------------------------------------------------- /public/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/.DS_Store -------------------------------------------------------------------------------- /public/assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/.DS_Store -------------------------------------------------------------------------------- /public/views/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/views/.DS_Store -------------------------------------------------------------------------------- /public/assets/css/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/css/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/.DS_Store -------------------------------------------------------------------------------- /public/assets/js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/js/.DS_Store -------------------------------------------------------------------------------- /public/assets/fonts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/btc-eth-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/btc-eth-bg.png -------------------------------------------------------------------------------- /public/assets/img/footer-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/footer-logo.png -------------------------------------------------------------------------------- /public/assets/js/jquery/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/js/jquery/.DS_Store -------------------------------------------------------------------------------- /public/views/partials/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/views/partials/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/bithereum-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/bithereum-top.png -------------------------------------------------------------------------------- /public/assets/img/favicon/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/nodes-bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/nodes-bottom.png -------------------------------------------------------------------------------- /public/assets/img/wallets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/.DS_Store -------------------------------------------------------------------------------- /public/assets/fonts/aquatico/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/aquatico/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/favicon.ico -------------------------------------------------------------------------------- /public/assets/js/particles/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/js/particles/.DS_Store -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon.png -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-mew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-mew.png -------------------------------------------------------------------------------- /public/assets/img/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /public/assets/img/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /public/assets/img/favicon/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/favicon-96x96.png -------------------------------------------------------------------------------- /public/assets/img/favicon/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/ms-icon-70x70.png -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-jaxx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-jaxx.png -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-ledger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-ledger.jpg -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-trezor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-trezor.png -------------------------------------------------------------------------------- /public/assets/img/favicon/ms-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/ms-icon-144x144.png -------------------------------------------------------------------------------- /public/assets/img/favicon/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/ms-icon-150x150.png -------------------------------------------------------------------------------- /public/assets/img/favicon/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/ms-icon-310x310.png -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-imtoken.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-imtoken.jpg -------------------------------------------------------------------------------- /public/assets/img/wallets/wallet-metamask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/wallets/wallet-metamask.png -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-36x36.png -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-48x48.png -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-72x72.png -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-96x96.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-114x114.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-120x120.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-144x144.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-152x152.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-180x180.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-57x57.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-60x60.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-72x72.png -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-76x76.png -------------------------------------------------------------------------------- /public/views/partials/partial-footer.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /public/assets/fonts/aquatico/Aquatico-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/aquatico/Aquatico-Regular.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-Bold.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-Light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-Light.otf -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-144x144.png -------------------------------------------------------------------------------- /public/assets/img/favicon/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/android-icon-192x192.png -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-Italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-Italic.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-Medium.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-Medium.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-Regular.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-SemiBold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-SemiBold.otf -------------------------------------------------------------------------------- /public/assets/img/favicon/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/img/favicon/apple-icon-precomposed.png -------------------------------------------------------------------------------- /public/views/partials/partial-header.html: -------------------------------------------------------------------------------- 1 |
2 | 6 |
7 | -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-BoldItalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-BoldItalic.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-LightItalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-LightItalic.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-MediumItalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-MediumItalic.otf -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/HKGrotesk-SemiBoldItalic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/public/assets/fonts/hk-grotesk/HKGrotesk-SemiBoldItalic.otf -------------------------------------------------------------------------------- /.sass-cache/29a37499c8e55df94962afc59d3975f5da105a80/styles.scssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/.sass-cache/29a37499c8e55df94962afc59d3975f5da105a80/styles.scssc -------------------------------------------------------------------------------- /.sass-cache/642469386cb4ca8cc232c217207382b59264e9ea/styles.scssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/.sass-cache/642469386cb4ca8cc232c217207382b59264e9ea/styles.scssc -------------------------------------------------------------------------------- /.sass-cache/a299dec5700977e8d72060fd4ea120e60f532e02/styles.scssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BTHPOS/wallet-generator-website/HEAD/.sass-cache/a299dec5700977e8d72060fd4ea120e60f532e02/styles.scssc -------------------------------------------------------------------------------- /public/views/partials/partial-header-condensed.html: -------------------------------------------------------------------------------- 1 |
2 | 6 |
7 | -------------------------------------------------------------------------------- /public/assets/img/favicon/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | #ffffff -------------------------------------------------------------------------------- /config.rb: -------------------------------------------------------------------------------- 1 | #require 'compass/import-once/activate' 2 | # Require any additional compass plugins here. 3 | 4 | # Set this to the root of your project when deployed: 5 | http_path = "/" 6 | css_dir = "public/assets/css" 7 | sass_dir = "sass" 8 | images_dir = "public/assets/images" 9 | javascripts_dir = "public/assets/js" 10 | fonts_dir = "public/assets/fonts" 11 | 12 | output_style = :nested 13 | 14 | # To enable relative paths to assets via compass helper functions. Uncomment: 15 | # relative_assets = true 16 | 17 | line_comments = false 18 | color_output = false 19 | 20 | preferred_syntax = :scss 21 | -------------------------------------------------------------------------------- /public/assets/js/wallet/asciihex.js: -------------------------------------------------------------------------------- 1 | var ASCIIHEX = {}; 2 | 3 | // ASCII to HEX 4 | ASCIIHEX.asciitohex = function(str) { 5 | var arr1 = []; 6 | for (var n = 0, l = str.length; n < l; n ++) { 7 | var hex = Number(str.charCodeAt(n)).toString(16); 8 | arr1.push(hex); 9 | } 10 | return arr1.join(''); 11 | }; 12 | 13 | // Converts ascii to hex 14 | ASCIIHEX.hextoascii = function(hexValue) { 15 | var hex = hexValue.toString();//force conversion 16 | var str = ''; 17 | for (var i = 0; (i < hex.length && hex.substr(i, 2) !== '00'); i += 2) 18 | str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); 19 | return str; 20 | }; 21 | -------------------------------------------------------------------------------- /public/assets/img/favicon/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "App", 3 | "icons": [ 4 | { 5 | "src": "\/android-icon-36x36.png", 6 | "sizes": "36x36", 7 | "type": "image\/png", 8 | "density": "0.75" 9 | }, 10 | { 11 | "src": "\/android-icon-48x48.png", 12 | "sizes": "48x48", 13 | "type": "image\/png", 14 | "density": "1.0" 15 | }, 16 | { 17 | "src": "\/android-icon-72x72.png", 18 | "sizes": "72x72", 19 | "type": "image\/png", 20 | "density": "1.5" 21 | }, 22 | { 23 | "src": "\/android-icon-96x96.png", 24 | "sizes": "96x96", 25 | "type": "image\/png", 26 | "density": "2.0" 27 | }, 28 | { 29 | "src": "\/android-icon-144x144.png", 30 | "sizes": "144x144", 31 | "type": "image\/png", 32 | "density": "3.0" 33 | }, 34 | { 35 | "src": "\/android-icon-192x192.png", 36 | "sizes": "192x192", 37 | "type": "image\/png", 38 | "density": "4.0" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bithereum 2 | THE HARMONIZATION OF BITCOIN AND ETHEREUM 3 | 4 | Bithereum aims to do what no other hard fork has done, by fusing the visions of both Bitcoin and Ethereum, ultimately revolutionizing mining, improving scalability, and increasing network consensus. 5 | 6 | ## Create a Bithereum Wallet Address 7 | To create a Bithereum Wallet address install the address generator page. To run the wallet generator, make sure that you have installed [Node.js](https://nodejs.org/en/) on your machine. The wallet generator has been tested using version 9.3, however older versions of NodeJS above 7 should work. 8 | 9 | If you would like to follow a more detailed setup guide be sure to check out our [setup guide on medium](https://medium.com/@dondrey.taylor/generate-a-bithereum-wallet-address-3d4b32e27d27). 10 | 11 | ### Setting up wallet 12 | Download the repository locally 13 | ```sh 14 | $ git clone https://github.com/BTHPOS/WalletGenerator.git 15 | $ cd WalletGenerator 16 | ``` 17 | Install node_modules 18 | ```sh 19 | $ npm install 20 | ``` 21 | Run the wallet generator server 22 | ```sh 23 | $ node server.js 24 | ``` 25 | 26 | To view and interact with the wallet, open your web browser to 27 | ```sh 28 | http://localhost:8000/ 29 | ``` 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bithereum_walletgenerator", 3 | "version": "1.0.0", 4 | "description": "Generates a BTH wallet", 5 | "main": "server.js", 6 | "dependencies": { 7 | "boom": "^2.9.0", 8 | "dateformat": "^1.0.11", 9 | "handlebars": "^4.0.3", 10 | "handlebars-layouts": "^3.1.2", 11 | "hapi": "^10.1.0", 12 | "hashids": "^1.0.2", 13 | "hat": "^0.0.3", 14 | "hoek": "^2.16.3", 15 | "inert": "^3.0.2", 16 | "joi": "^6.7.1", 17 | "md5": "^2.0.0", 18 | "mongojs": "^2.4.0", 19 | "moment": "^2.10.6", 20 | "mysql": "^2.9.0", 21 | "nanotimer": "^0.3.10", 22 | "path": "^0.12.7", 23 | "redbird": "^0.6.15", 24 | "request": "^2.64.0", 25 | "voice.js": "^0.1.5", 26 | "vision": "^3.0.0" 27 | }, 28 | "devDependencies": {}, 29 | "scripts": { 30 | "test": "echo \"Error: no test specified\" && exit 1", 31 | "start": "node server.js" 32 | }, 33 | "repository": { 34 | "type": "git", 35 | "url": "git+https://github.com/BTHPOS/WalletGenerator.git" 36 | }, 37 | "keywords": [ 38 | "bithereum", 39 | "wallet", 40 | "bitcoin", 41 | "spork", 42 | "ethereum" 43 | ], 44 | "author": "Dondrey Taylor", 45 | "license": "ISC", 46 | "bugs": { 47 | "url": "https://github.com/BTHPOS/WalletGenerator/issues" 48 | }, 49 | "homepage": "https://github.com/BTHPOS/WalletGenerator#readme" 50 | } 51 | -------------------------------------------------------------------------------- /public/assets/js/wallet/crypto-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.5.4 3 | * http://code.google.com/p/crypto-js/ 4 | * (c) 2009-2012 by Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (typeof Crypto=="undefined"||!Crypto.util)&&function(){var e=window.Crypto={},f=e.util={rotl:function(a,b){return a<>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return f.rotl(a,8)&16711935|f.rotl(a,24)&4278255360;for(var b=0;b0;a--)b.push(Math.floor(Math.random()*256));return b},bytesToWords:function(a){for(var b=[],c=0,d=0;c>>5]|=(a[c]&255)<< 8 | 24-d%32;return b},wordsToBytes:function(a){for(var b=[],c=0;c>>5]>>>24-c%32&255);return b},bytesToHex:function(a){for(var b=[],c=0;c>>4).toString(16)),b.push((a[c]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],c=0;c>> 9 | 6*(3-e)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){for(var a=a.replace(/[^A-Z0-9+\/]/ig,""),b=[],c=0,d=0;c>>6-d*2);return b}},e=e.charenc={};e.UTF8={stringToBytes:function(a){return g.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(g.bytesToString(a)))}}; 10 | var g=e.Binary={stringToBytes:function(a){for(var b=[],c=0;c 5 |
6 |
7 |

Generate Bithereum Address

8 |
9 |
10 |
1
11 |

Create a BTH address

12 | Generate Address 13 |
14 |
15 |
2
16 |

Save BTH private key and public key

17 |

Make sure to note down your newly created BTH public key and private key. NEVER share your private key with anyone!

18 |
19 |
20 | SHARE 21 |
22 | Bithereum Address 23 |
24 |
25 | KEEP SECRET 26 |
27 | Private Key 28 |
29 |
30 | Bithereum Address 31 | 32 |
33 |
34 | Private Key 35 | 36 |
37 |
38 | Print Address 39 |
40 |
41 |
42 |
43 | 44 | {{#embed "partial-footer"}}{{/embed}} 45 | {{/content}} 46 | 47 | {{#content "scripts"}} 48 | 77 | {{/content}} 78 | {{/extend}} 79 | -------------------------------------------------------------------------------- /public/assets/css/normalize.min.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */ 2 | html { 3 | font-family: sans-serif; 4 | -ms-text-size-adjust: 100%; 5 | -webkit-text-size-adjust: 100% 6 | } 7 | html, 8 | body { 9 | overflow-x: hidden; 10 | width: 100%; 11 | } 12 | body { 13 | margin: 0 14 | } 15 | 16 | article, 17 | aside, 18 | details, 19 | figcaption, 20 | figure, 21 | footer, 22 | header, 23 | hgroup, 24 | main, 25 | menu, 26 | nav, 27 | section, 28 | summary { 29 | display: block 30 | } 31 | 32 | audio, 33 | canvas, 34 | progress, 35 | video { 36 | display: inline-block; 37 | vertical-align: baseline 38 | } 39 | 40 | audio:not([controls]) { 41 | display: none; 42 | height: 0 43 | } 44 | 45 | [hidden], 46 | template { 47 | display: none 48 | } 49 | 50 | a { 51 | background-color: transparent 52 | } 53 | 54 | a:active, 55 | a:hover { 56 | outline: 0 57 | } 58 | 59 | abbr[title] { 60 | border-bottom: 1px dotted 61 | } 62 | 63 | b, 64 | strong { 65 | font-weight: 700 66 | } 67 | 68 | dfn { 69 | font-style: italic 70 | } 71 | 72 | h1 { 73 | font-size: 2em; 74 | margin: .67em 0 75 | } 76 | 77 | mark { 78 | background: #ff0; 79 | color: #000 80 | } 81 | 82 | small { 83 | font-size: 80% 84 | } 85 | 86 | sub, 87 | sup { 88 | font-size: 75%; 89 | line-height: 0; 90 | position: relative; 91 | vertical-align: baseline 92 | } 93 | 94 | sup { 95 | top: -.5em 96 | } 97 | 98 | sub { 99 | bottom: -.25em 100 | } 101 | 102 | img { 103 | border: 0 104 | } 105 | 106 | svg:not(:root) { 107 | overflow: hidden 108 | } 109 | 110 | figure { 111 | margin: 1em 40px 112 | } 113 | 114 | hr { 115 | -moz-box-sizing: content-box; 116 | box-sizing: content-box; 117 | height: 0 118 | } 119 | 120 | pre { 121 | overflow: auto 122 | } 123 | 124 | code, 125 | kbd, 126 | pre, 127 | samp { 128 | font-family: monospace, monospace; 129 | font-size: 1em 130 | } 131 | 132 | button, 133 | input, 134 | optgroup, 135 | select, 136 | textarea { 137 | color: inherit; 138 | font: inherit; 139 | margin: 0 140 | } 141 | 142 | button { 143 | overflow: visible 144 | } 145 | 146 | button, 147 | select { 148 | text-transform: none 149 | } 150 | 151 | button, 152 | html input[type=button], 153 | input[type=reset], 154 | input[type=submit] { 155 | -webkit-appearance: button; 156 | cursor: pointer 157 | } 158 | 159 | button[disabled], 160 | html input[disabled] { 161 | cursor: default 162 | } 163 | 164 | button::-moz-focus-inner, 165 | input::-moz-focus-inner { 166 | border: 0; 167 | padding: 0 168 | } 169 | 170 | input { 171 | line-height: normal 172 | } 173 | 174 | input[type=checkbox], 175 | input[type=radio] { 176 | box-sizing: border-box; 177 | padding: 0 178 | } 179 | 180 | input[type=number]::-webkit-inner-spin-button, 181 | input[type=number]::-webkit-outer-spin-button { 182 | height: auto 183 | } 184 | 185 | input[type=search] { 186 | -webkit-appearance: textfield; 187 | -moz-box-sizing: content-box; 188 | -webkit-box-sizing: content-box; 189 | box-sizing: content-box 190 | } 191 | 192 | input[type=search]::-webkit-search-cancel-button, 193 | input[type=search]::-webkit-search-decoration { 194 | -webkit-appearance: none 195 | } 196 | 197 | fieldset { 198 | border: 1px solid silver; 199 | margin: 0 2px; 200 | padding: .35em .625em .75em 201 | } 202 | 203 | legend { 204 | border: 0; 205 | padding: 0 206 | } 207 | 208 | textarea { 209 | overflow: auto 210 | } 211 | 212 | optgroup { 213 | font-weight: 700 214 | } 215 | 216 | table { 217 | border-collapse: collapse; 218 | border-spacing: 0 219 | } 220 | 221 | td, 222 | th { 223 | padding: 0 224 | } -------------------------------------------------------------------------------- /public/assets/js/wallet/crypto-sha256.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.5.4 3 | * http://code.google.com/p/crypto-js/ 4 | * (c) 2009-2012 by Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (typeof Crypto=="undefined"||!Crypto.util)&&function(){var f=window.Crypto={},l=f.util={rotl:function(b,a){return b<>>32-a},rotr:function(b,a){return b<<32-a|b>>>a},endian:function(b){if(b.constructor==Number)return l.rotl(b,8)&16711935|l.rotl(b,24)&4278255360;for(var a=0;a0;b--)a.push(Math.floor(Math.random()*256));return a},bytesToWords:function(b){for(var a=[],c=0,d=0;c>>5]|=(b[c]&255)<< 8 | 24-d%32;return a},wordsToBytes:function(b){for(var a=[],c=0;c>>5]>>>24-c%32&255);return a},bytesToHex:function(b){for(var a=[],c=0;c>>4).toString(16)),a.push((b[c]&15).toString(16));return a.join("")},hexToBytes:function(b){for(var a=[],c=0;c>> 9 | 6*(3-q)&63)):a.push("=");return a.join("")},base64ToBytes:function(b){for(var b=b.replace(/[^A-Z0-9+\/]/ig,""),a=[],c=0,d=0;c>>6-d*2);return a}},f=f.charenc={};f.UTF8={stringToBytes:function(b){return i.stringToBytes(unescape(encodeURIComponent(b)))},bytesToString:function(b){return decodeURIComponent(escape(i.bytesToString(b)))}}; 10 | var i=f.Binary={stringToBytes:function(b){for(var a=[],c=0;c>5]|=128<<24-e%32;d[(e+64>>9<<4)+15]=e;for(s=0;s>>7)^(k<<14|k>>>18)^k>>>3)+(f[g-7]>>>0)+((j<<15|j>>>17)^(j<<13|j>>>19)^j>>>10)+(f[g-16]>>>0));j=e&m^e&n^m&n;var t=(e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22);k=(r>>>0)+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+ 14 | (h&o^~h&p)+c[g]+(f[g]>>>0);j=t+j;r=p;p=o;o=h;h=i+k>>>0;i=n;n=m;m=e;e=k+j>>>0}a[0]+=e;a[1]+=m;a[2]+=n;a[3]+=i;a[4]+=h;a[5]+=o;a[6]+=p;a[7]+=r}return a};d._blocksize=16;d._digestsize=32})(); 15 | -------------------------------------------------------------------------------- /public/assets/js/wallet/crypto-sha256-hmac.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto-JS v2.5.4 3 | * http://code.google.com/p/crypto-js/ 4 | * (c) 2009-2012 by Jeff Mott. All rights reserved. 5 | * http://code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (typeof Crypto=="undefined"||!Crypto.util)&&function(){var d=window.Crypto={},k=d.util={rotl:function(b,a){return b<>>32-a},rotr:function(b,a){return b<<32-a|b>>>a},endian:function(b){if(b.constructor==Number)return k.rotl(b,8)&16711935|k.rotl(b,24)&4278255360;for(var a=0;a0;b--)a.push(Math.floor(Math.random()*256));return a},bytesToWords:function(b){for(var a=[],c=0,e=0;c>>5]|=(b[c]&255)<< 8 | 24-e%32;return a},wordsToBytes:function(b){for(var a=[],c=0;c>>5]>>>24-c%32&255);return a},bytesToHex:function(b){for(var a=[],c=0;c>>4).toString(16)),a.push((b[c]&15).toString(16));return a.join("")},hexToBytes:function(b){for(var a=[],c=0;c>> 9 | 6*(3-p)&63)):a.push("=");return a.join("")},base64ToBytes:function(b){for(var b=b.replace(/[^A-Z0-9+\/]/ig,""),a=[],c=0,e=0;c>>6-e*2);return a}},d=d.charenc={};d.UTF8={stringToBytes:function(b){return g.stringToBytes(unescape(encodeURIComponent(b)))},bytesToString:function(b){return decodeURIComponent(escape(g.bytesToString(b)))}}; 10 | var g=d.Binary={stringToBytes:function(b){for(var a=[],c=0;c>5]|=128<<24-f%32;e[(f+64>>9<<4)+15]=f;for(t=0;t>>7)^(l<<14|l>>>18)^l>>>3)+(d[h-7]>>>0)+((j<<15|j>>>17)^(j<<13|j>>>19)^j>>>10)+(d[h-16]>>>0));j=f&g^f&m^g&m;var u=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22);l=(s>>>0)+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+ 14 | (i&n^~i&o)+c[h]+(d[h]>>>0);j=u+j;s=o;o=n;n=i;i=r+l>>>0;r=m;m=g;g=f;f=l+j>>>0}a[0]+=f;a[1]+=g;a[2]+=m;a[3]+=r;a[4]+=i;a[5]+=n;a[6]+=o;a[7]+=s}return a};e._blocksize=16;e._digestsize=32})(); 15 | (function(){var d=Crypto,k=d.util,g=d.charenc,b=g.UTF8,a=g.Binary;d.HMAC=function(c,e,d,g){e.constructor==String&&(e=b.stringToBytes(e));d.constructor==String&&(d=b.stringToBytes(d));d.length>c._blocksize*4&&(d=c(d,{asBytes:!0}));for(var f=d.slice(0),d=d.slice(0),q=0;q 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Bithereum - Two Chains. One Coin. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | {{#block "body"}}{{/block}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | {{#block "scripts"}}{{/block}} 58 | 59 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /public/assets/fonts/hk-grotesk/SIL Open Font License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Alfredo Marco Pradil (hello@hanken.co) and HK Grotesk Cyrillic by Stefan Peev (http://www.contextbg.net/), with Reserved Font Name HK Grotesk. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 5 | 6 | ----------------------------------------------------------- 7 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 8 | ----------------------------------------------------------- 9 | 10 | PREAMBLE 11 | The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. 12 | 13 | The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. 14 | 15 | DEFINITIONS 16 | "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. 17 | 18 | "Reserved Font Name" refers to any names specified as such after the copyright statement(s). 19 | 20 | "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). 21 | 22 | "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. 23 | 24 | "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. 25 | 26 | PERMISSION & CONDITIONS 27 | Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 28 | 29 | 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 30 | 31 | 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 32 | 33 | 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 34 | 35 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 36 | 37 | 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. 38 | 39 | TERMINATION 40 | This license becomes null and void if any of the above conditions are not met. 41 | 42 | DISCLAIMER 43 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | /* 2 | |-------------------------------------------------------------------------- 3 | | HapiJS Boom 4 | |-------------------------------------------------------------------------- 5 | | 6 | | Boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error 7 | | response object (instance of Error) which includes the following properties: 8 | | 9 | */ 10 | var Boom = require('boom'); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | HapiJS Joi 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Object schema description language and validator for JavaScript objects. 18 | | 19 | */ 20 | var Path = require('path'); 21 | 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Initialize Server 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Configure Hapi Server 29 | | 30 | */ 31 | var Hapi = require('hapi'); 32 | var server = new Hapi.Server(); 33 | server.connection({ 34 | port: 8000, 35 | routes: { cors: { credentials: true } } 36 | }); 37 | 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Template Engine 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Template Engine 45 | | 46 | */ 47 | var Handlerbars = require('handlebars'); 48 | var HandlebarsLayouts = require('handlebars-layouts'); 49 | HandlebarsLayouts.register(Handlerbars); 50 | 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | HAT 55 | |-------------------------------------------------------------------------- 56 | | 57 | | HAT Module 58 | | 59 | */ 60 | var hat = require('hat'); 61 | 62 | 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | View 67 | |-------------------------------------------------------------------------- 68 | | 69 | | View Configuration 70 | | 71 | */ 72 | server.register([require('vision'), require("inert")], function (err) { 73 | 74 | 75 | // WEBSITES 76 | /* ==================================================== */ 77 | /* ==================================================== */ 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Views 82 | |-------------------------------------------------------------------------- 83 | | 84 | | Configured views 85 | | 86 | */ 87 | server.views({ 88 | engines: { 89 | html: { 90 | module: Handlerbars 91 | } 92 | }, 93 | relativeTo: Path.join(__dirname, 'public'), 94 | path: './views', 95 | partialsPath: './views/partials' 96 | }); 97 | 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Handle HTTP Status 404 102 | |-------------------------------------------------------------------------- 103 | | 104 | | 404 Response Handler 105 | | 106 | */ 107 | server.ext('onPreResponse', function (request, reply) 108 | { 109 | if (request.response.isBoom) 110 | { 111 | return reply.redirect('/'); 112 | } 113 | 114 | return reply.continue(); 115 | }); 116 | 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Server Events 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Catch-all server events 124 | | 125 | */ 126 | server.on('internalError', function (request, err) 127 | { 128 | }); 129 | 130 | 131 | 132 | /* 133 | |-------------------------------------------------------------------------- 134 | | WEB Route: 135 | |-------------------------------------------------------------------------- 136 | | 137 | | All routes pertaining to web pages 138 | | 139 | */ 140 | server.route({ 141 | method: 'GET', 142 | path: '/', 143 | handler: function(request, reply) 144 | { 145 | reply.view('page-ethredeem', {}); 146 | } 147 | }); 148 | 149 | server.route({ 150 | method: 'GET', 151 | path: '/redeem/mew', 152 | handler: function(request, reply) 153 | { 154 | reply.redirect("https://medium.com/@dondrey.taylor/how-to-redeem-your-bth-using-myetherwallet-97b6e0a0d250"); 155 | } 156 | }); 157 | 158 | server.route({ 159 | method: 'GET', 160 | path: '/redeem/metamask', 161 | handler: function(request, reply) 162 | { 163 | reply.redirect("https://medium.com/@dondrey.taylor/eth-holders-how-to-redeem-your-bth-using-metamask-849c381da87b"); 164 | } 165 | }); 166 | 167 | server.route({ 168 | method: 'GET', 169 | path: '/redeem/jaxx', 170 | handler: function(request, reply) 171 | { 172 | reply.redirect("https://medium.com/@dondrey.taylor/eth-holders-how-to-redeem-your-bth-using-jaxx-2dc9e9fec6de"); 173 | } 174 | }); 175 | 176 | server.route({ 177 | method: 'GET', 178 | path: '/redeem/ledger', 179 | handler: function(request, reply) 180 | { 181 | reply.redirect("https://medium.com/@dondrey.taylor/eth-holders-how-to-redeem-your-bth-using-ledger-wallet-fb9d706485dd"); 182 | } 183 | }); 184 | 185 | server.route({ 186 | method: 'GET', 187 | path: '/redeem/imtoken', 188 | handler: function(request, reply) 189 | { 190 | reply.redirect("https://medium.com/@dondrey.taylor/eth-holders-how-to-redeem-your-bth-using-imtoken-47b984f2cbe"); 191 | } 192 | }); 193 | 194 | server.route({ 195 | method: 'GET', 196 | path: '/redeem/trezor', 197 | handler: function(request, reply) 198 | { 199 | reply.redirect("https://medium.com/@dondrey.taylor/eth-holders-how-to-redeem-your-bth-using-trezor-8de9ec362e82"); 200 | } 201 | }); 202 | 203 | 204 | 205 | /* 206 | |-------------------------------------------------------------------------- 207 | | API Route: Static Files 208 | |-------------------------------------------------------------------------- 209 | | 210 | | Static files 211 | | 212 | */ 213 | server.route({ 214 | method: 'GET', 215 | path: '/{path*}', 216 | handler: 217 | { 218 | directory: 219 | { 220 | path: Path.join(__dirname, 'public'), 221 | listing: false, 222 | index: true 223 | } 224 | } 225 | }); 226 | 227 | 228 | /* 229 | |-------------------------------------------------------------------------- 230 | | API Route: Starts Server 231 | |-------------------------------------------------------------------------- 232 | | 233 | | Starts server 234 | | 235 | */ 236 | server.start(function() 237 | { 238 | console.log("### SERVER STARTED ###"); 239 | }); 240 | 241 | }); 242 | -------------------------------------------------------------------------------- /public/assets/js/wallet/ripemd160.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | /** @preserve 8 | (c) 2012 by Cédric Mesnil. All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 11 | 12 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 13 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | // Constants table 19 | var zl = [ 20 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21 | 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 22 | 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 23 | 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 24 | 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; 25 | var zr = [ 26 | 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 27 | 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 28 | 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 29 | 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 30 | 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; 31 | var sl = [ 32 | 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 33 | 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 34 | 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 35 | 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 36 | 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]; 37 | var sr = [ 38 | 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 39 | 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 40 | 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 41 | 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 42 | 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; 43 | 44 | var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]; 45 | var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]; 46 | 47 | var bytesToWords = function (bytes) { 48 | var words = []; 49 | for (var i = 0, b = 0; i < bytes.length; i++, b += 8) { 50 | words[b >>> 5] |= bytes[i] << (24 - b % 32); 51 | } 52 | return words; 53 | }; 54 | 55 | var wordsToBytes = function (words) { 56 | var bytes = []; 57 | for (var b = 0; b < words.length * 32; b += 8) { 58 | bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF); 59 | } 60 | return bytes; 61 | }; 62 | 63 | var processBlock = function (H, M, offset) { 64 | 65 | // Swap endian 66 | for (var i = 0; i < 16; i++) { 67 | var offset_i = offset + i; 68 | var M_offset_i = M[offset_i]; 69 | 70 | // Swap 71 | M[offset_i] = ( 72 | (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | 73 | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) 74 | ); 75 | } 76 | 77 | // Working variables 78 | var al, bl, cl, dl, el; 79 | var ar, br, cr, dr, er; 80 | 81 | ar = al = H[0]; 82 | br = bl = H[1]; 83 | cr = cl = H[2]; 84 | dr = dl = H[3]; 85 | er = el = H[4]; 86 | // Computation 87 | var t; 88 | for (var i = 0; i < 80; i += 1) { 89 | t = (al + M[offset+zl[i]])|0; 90 | if (i<16){ 91 | t += f1(bl,cl,dl) + hl[0]; 92 | } else if (i<32) { 93 | t += f2(bl,cl,dl) + hl[1]; 94 | } else if (i<48) { 95 | t += f3(bl,cl,dl) + hl[2]; 96 | } else if (i<64) { 97 | t += f4(bl,cl,dl) + hl[3]; 98 | } else {// if (i<80) { 99 | t += f5(bl,cl,dl) + hl[4]; 100 | } 101 | t = t|0; 102 | t = rotl(t,sl[i]); 103 | t = (t+el)|0; 104 | al = el; 105 | el = dl; 106 | dl = rotl(cl, 10); 107 | cl = bl; 108 | bl = t; 109 | 110 | t = (ar + M[offset+zr[i]])|0; 111 | if (i<16){ 112 | t += f5(br,cr,dr) + hr[0]; 113 | } else if (i<32) { 114 | t += f4(br,cr,dr) + hr[1]; 115 | } else if (i<48) { 116 | t += f3(br,cr,dr) + hr[2]; 117 | } else if (i<64) { 118 | t += f2(br,cr,dr) + hr[3]; 119 | } else {// if (i<80) { 120 | t += f1(br,cr,dr) + hr[4]; 121 | } 122 | t = t|0; 123 | t = rotl(t,sr[i]) ; 124 | t = (t+er)|0; 125 | ar = er; 126 | er = dr; 127 | dr = rotl(cr, 10); 128 | cr = br; 129 | br = t; 130 | } 131 | // Intermediate hash value 132 | t = (H[1] + cl + dr)|0; 133 | H[1] = (H[2] + dl + er)|0; 134 | H[2] = (H[3] + el + ar)|0; 135 | H[3] = (H[4] + al + br)|0; 136 | H[4] = (H[0] + bl + cr)|0; 137 | H[0] = t; 138 | }; 139 | 140 | function f1(x, y, z) { 141 | return ((x) ^ (y) ^ (z)); 142 | } 143 | 144 | function f2(x, y, z) { 145 | return (((x)&(y)) | ((~x)&(z))); 146 | } 147 | 148 | function f3(x, y, z) { 149 | return (((x) | (~(y))) ^ (z)); 150 | } 151 | 152 | function f4(x, y, z) { 153 | return (((x) & (z)) | ((y)&(~(z)))); 154 | } 155 | 156 | function f5(x, y, z) { 157 | return ((x) ^ ((y) |(~(z)))); 158 | } 159 | 160 | function rotl(x,n) { 161 | return (x<>>(32-n)); 162 | } 163 | 164 | function ripemd160(message) { 165 | var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]; 166 | 167 | var m = bytesToWords(message); 168 | 169 | var nBitsLeft = message.length * 8; 170 | var nBitsTotal = message.length * 8; 171 | 172 | // Add padding 173 | m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); 174 | m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( 175 | (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | 176 | (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) 177 | ); 178 | 179 | for (var i=0 ; i>> 24)) & 0x00ff00ff) | 190 | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); 191 | } 192 | 193 | var digestbytes = wordsToBytes(H); 194 | return digestbytes; 195 | } 196 | -------------------------------------------------------------------------------- /public/assets/js/wallet/sha512.js: -------------------------------------------------------------------------------- 1 | (function() {/* 2 | A JavaScript implementation of the SHA family of hashes, as defined in FIPS 3 | PUB 180-2 as well as the corresponding HMAC implementation as defined in 4 | FIPS PUB 198a 5 | 6 | Copyright Brian Turek 2008-2012 7 | Distributed under the BSD License 8 | See http://caligatio.github.com/jsSHA/ for more information 9 | 10 | Several functions taken from Paul Johnson 11 | */ 12 | function n(a){throw a;}var q=null;function s(a,b){this.a=a;this.b=b}function u(a,b){var d=[],h=(1<>>5]|=(a.charCodeAt(g/b)&h)<<32-b-g%32;return{value:d,binLen:f}}function x(a){var b=[],d=a.length,h,f;0!==d%2&&n("String of HEX type must be in byte increments");for(h=0;h>>3]|=f<<24-4*(h%8);return{value:b,binLen:4*d}} 13 | function B(a){var b=[],d=0,h,f,g,k,m;-1===a.search(/^[a-zA-Z0-9=+\/]+$/)&&n("Invalid character in base-64 string");h=a.indexOf("=");a=a.replace(/\=/g,"");-1!==h&&h= 0) error 22 | this.q = q; 23 | }; 24 | 25 | ec.FieldElementFp.prototype.equals = function (other) { 26 | if (other == this) return true; 27 | return (this.q.equals(other.q) && this.x.equals(other.x)); 28 | }; 29 | 30 | ec.FieldElementFp.prototype.toBigInteger = function () { 31 | return this.x; 32 | }; 33 | 34 | ec.FieldElementFp.prototype.negate = function () { 35 | return new ec.FieldElementFp(this.q, this.x.negate().mod(this.q)); 36 | }; 37 | 38 | ec.FieldElementFp.prototype.add = function (b) { 39 | return new ec.FieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q)); 40 | }; 41 | 42 | ec.FieldElementFp.prototype.subtract = function (b) { 43 | return new ec.FieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q)); 44 | }; 45 | 46 | ec.FieldElementFp.prototype.multiply = function (b) { 47 | return new ec.FieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q)); 48 | }; 49 | 50 | ec.FieldElementFp.prototype.square = function () { 51 | return new ec.FieldElementFp(this.q, this.x.square().mod(this.q)); 52 | }; 53 | 54 | ec.FieldElementFp.prototype.divide = function (b) { 55 | return new ec.FieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q)); 56 | }; 57 | 58 | ec.FieldElementFp.prototype.getByteLength = function () { 59 | return Math.floor((this.toBigInteger().bitLength() + 7) / 8); 60 | }; 61 | 62 | // D.1.4 91 63 | /** 64 | * return a sqrt root - the routine verifies that the calculation 65 | * returns the right value - if none exists it returns null. 66 | * 67 | * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org) 68 | * Ported to JavaScript by bitaddress.org 69 | */ 70 | ec.FieldElementFp.prototype.sqrt = function () { 71 | if (!this.q.testBit(0)) throw new Error("even value of q"); 72 | 73 | // p mod 4 == 3 74 | if (this.q.testBit(1)) { 75 | // z = g^(u+1) + p, p = 4u + 3 76 | var z = new ec.FieldElementFp(this.q, this.x.modPow(this.q.shiftRight(2).add(BigInteger.ONE), this.q)); 77 | return z.square().equals(this) ? z : null; 78 | } 79 | 80 | // p mod 4 == 1 81 | var qMinusOne = this.q.subtract(BigInteger.ONE); 82 | var legendreExponent = qMinusOne.shiftRight(1); 83 | if (!(this.x.modPow(legendreExponent, this.q).equals(BigInteger.ONE))) return null; 84 | var u = qMinusOne.shiftRight(2); 85 | var k = u.shiftLeft(1).add(BigInteger.ONE); 86 | var Q = this.x; 87 | var fourQ = Q.shiftLeft(2).mod(this.q); 88 | var U, V; 89 | 90 | do { 91 | var rand = new SecureRandom(); 92 | var P; 93 | do { 94 | P = new BigInteger(this.q.bitLength(), rand); 95 | } 96 | while (P.compareTo(this.q) >= 0 || !(P.multiply(P).subtract(fourQ).modPow(legendreExponent, this.q).equals(qMinusOne))); 97 | 98 | var result = ec.FieldElementFp.fastLucasSequence(this.q, P, Q, k); 99 | 100 | U = result[0]; 101 | V = result[1]; 102 | if (V.multiply(V).mod(this.q).equals(fourQ)) { 103 | // Integer division by 2, mod q 104 | if (V.testBit(0)) { 105 | V = V.add(this.q); 106 | } 107 | V = V.shiftRight(1); 108 | return new ec.FieldElementFp(this.q, V); 109 | } 110 | } 111 | while (U.equals(BigInteger.ONE) || U.equals(qMinusOne)); 112 | 113 | return null; 114 | }; 115 | 116 | /* 117 | * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org) 118 | * Ported to JavaScript by bitaddress.org 119 | */ 120 | ec.FieldElementFp.fastLucasSequence = function (p, P, Q, k) { 121 | // TODO Research and apply "common-multiplicand multiplication here" 122 | 123 | var n = k.bitLength(); 124 | var s = k.getLowestSetBit(); 125 | var Uh = BigInteger.ONE; 126 | var Vl = BigInteger.TWO; 127 | var Vh = P; 128 | var Ql = BigInteger.ONE; 129 | var Qh = BigInteger.ONE; 130 | 131 | for (var j = n - 1; j >= s + 1; --j) { 132 | Ql = Ql.multiply(Qh).mod(p); 133 | if (k.testBit(j)) { 134 | Qh = Ql.multiply(Q).mod(p); 135 | Uh = Uh.multiply(Vh).mod(p); 136 | Vl = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p); 137 | Vh = Vh.multiply(Vh).subtract(Qh.shiftLeft(1)).mod(p); 138 | } 139 | else { 140 | Qh = Ql; 141 | Uh = Uh.multiply(Vl).subtract(Ql).mod(p); 142 | Vh = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p); 143 | Vl = Vl.multiply(Vl).subtract(Ql.shiftLeft(1)).mod(p); 144 | } 145 | } 146 | 147 | Ql = Ql.multiply(Qh).mod(p); 148 | Qh = Ql.multiply(Q).mod(p); 149 | Uh = Uh.multiply(Vl).subtract(Ql).mod(p); 150 | Vl = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p); 151 | Ql = Ql.multiply(Qh).mod(p); 152 | 153 | for (var j = 1; j <= s; ++j) { 154 | Uh = Uh.multiply(Vl).mod(p); 155 | Vl = Vl.multiply(Vl).subtract(Ql.shiftLeft(1)).mod(p); 156 | Ql = Ql.multiply(Ql).mod(p); 157 | } 158 | 159 | return [Uh, Vl]; 160 | }; 161 | 162 | // ---------------- 163 | // ECPointFp constructor 164 | ec.PointFp = function (curve, x, y, z, compressed) { 165 | this.curve = curve; 166 | this.x = x; 167 | this.y = y; 168 | // Projective coordinates: either zinv == null or z * zinv == 1 169 | // z and zinv are just BigIntegers, not fieldElements 170 | if (z == null) { 171 | this.z = BigInteger.ONE; 172 | } 173 | else { 174 | this.z = z; 175 | } 176 | this.zinv = null; 177 | // compression flag 178 | this.compressed = !!compressed; 179 | }; 180 | 181 | ec.PointFp.prototype.getX = function () { 182 | if (this.zinv == null) { 183 | this.zinv = this.z.modInverse(this.curve.q); 184 | } 185 | var r = this.x.toBigInteger().multiply(this.zinv); 186 | this.curve.reduce(r); 187 | return this.curve.fromBigInteger(r); 188 | }; 189 | 190 | ec.PointFp.prototype.getY = function () { 191 | if (this.zinv == null) { 192 | this.zinv = this.z.modInverse(this.curve.q); 193 | } 194 | var r = this.y.toBigInteger().multiply(this.zinv); 195 | this.curve.reduce(r); 196 | return this.curve.fromBigInteger(r); 197 | }; 198 | 199 | ec.PointFp.prototype.equals = function (other) { 200 | if (other == this) return true; 201 | if (this.isInfinity()) return other.isInfinity(); 202 | if (other.isInfinity()) return this.isInfinity(); 203 | var u, v; 204 | // u = Y2 * Z1 - Y1 * Z2 205 | u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q); 206 | if (!u.equals(BigInteger.ZERO)) return false; 207 | // v = X2 * Z1 - X1 * Z2 208 | v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q); 209 | return v.equals(BigInteger.ZERO); 210 | }; 211 | 212 | ec.PointFp.prototype.isInfinity = function () { 213 | if ((this.x == null) && (this.y == null)) return true; 214 | return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO); 215 | }; 216 | 217 | ec.PointFp.prototype.negate = function () { 218 | return new ec.PointFp(this.curve, this.x, this.y.negate(), this.z); 219 | }; 220 | 221 | ec.PointFp.prototype.add = function (b) { 222 | if (this.isInfinity()) return b; 223 | if (b.isInfinity()) return this; 224 | 225 | // u = Y2 * Z1 - Y1 * Z2 226 | var u = b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q); 227 | // v = X2 * Z1 - X1 * Z2 228 | var v = b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q); 229 | 230 | 231 | if (BigInteger.ZERO.equals(v)) { 232 | if (BigInteger.ZERO.equals(u)) { 233 | return this.twice(); // this == b, so double 234 | } 235 | return this.curve.getInfinity(); // this = -b, so infinity 236 | } 237 | 238 | var THREE = new BigInteger("3"); 239 | var x1 = this.x.toBigInteger(); 240 | var y1 = this.y.toBigInteger(); 241 | var x2 = b.x.toBigInteger(); 242 | var y2 = b.y.toBigInteger(); 243 | 244 | var v2 = v.square(); 245 | var v3 = v2.multiply(v); 246 | var x1v2 = x1.multiply(v2); 247 | var zu2 = u.square().multiply(this.z); 248 | 249 | // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) 250 | var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.q); 251 | // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 252 | var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.q); 253 | // z3 = v^3 * z1 * z2 254 | var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.q); 255 | 256 | return new ec.PointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3); 257 | }; 258 | 259 | ec.PointFp.prototype.twice = function () { 260 | if (this.isInfinity()) return this; 261 | if (this.y.toBigInteger().signum() == 0) return this.curve.getInfinity(); 262 | 263 | // TODO: optimized handling of constants 264 | var THREE = new BigInteger("3"); 265 | var x1 = this.x.toBigInteger(); 266 | var y1 = this.y.toBigInteger(); 267 | 268 | var y1z1 = y1.multiply(this.z); 269 | var y1sqz1 = y1z1.multiply(y1).mod(this.curve.q); 270 | var a = this.curve.a.toBigInteger(); 271 | 272 | // w = 3 * x1^2 + a * z1^2 273 | var w = x1.square().multiply(THREE); 274 | if (!BigInteger.ZERO.equals(a)) { 275 | w = w.add(this.z.square().multiply(a)); 276 | } 277 | w = w.mod(this.curve.q); 278 | //this.curve.reduce(w); 279 | // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) 280 | var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.q); 281 | // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 282 | var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.square().multiply(w)).mod(this.curve.q); 283 | // z3 = 8 * (y1 * z1)^3 284 | var z3 = y1z1.square().multiply(y1z1).shiftLeft(3).mod(this.curve.q); 285 | 286 | return new ec.PointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3); 287 | }; 288 | 289 | // Simple NAF (Non-Adjacent Form) multiplication algorithm 290 | // TODO: modularize the multiplication algorithm 291 | ec.PointFp.prototype.multiply = function (k) { 292 | if (this.isInfinity()) return this; 293 | if (k.signum() == 0) return this.curve.getInfinity(); 294 | 295 | var e = k; 296 | var h = e.multiply(new BigInteger("3")); 297 | 298 | var neg = this.negate(); 299 | var R = this; 300 | 301 | var i; 302 | for (i = h.bitLength() - 2; i > 0; --i) { 303 | R = R.twice(); 304 | 305 | var hBit = h.testBit(i); 306 | var eBit = e.testBit(i); 307 | 308 | if (hBit != eBit) { 309 | R = R.add(hBit ? this : neg); 310 | } 311 | } 312 | 313 | return R; 314 | }; 315 | 316 | // Compute this*j + x*k (simultaneous multiplication) 317 | ec.PointFp.prototype.multiplyTwo = function (j, x, k) { 318 | var i; 319 | if (j.bitLength() > k.bitLength()) 320 | i = j.bitLength() - 1; 321 | else 322 | i = k.bitLength() - 1; 323 | 324 | var R = this.curve.getInfinity(); 325 | var both = this.add(x); 326 | while (i >= 0) { 327 | R = R.twice(); 328 | if (j.testBit(i)) { 329 | if (k.testBit(i)) { 330 | R = R.add(both); 331 | } 332 | else { 333 | R = R.add(this); 334 | } 335 | } 336 | else { 337 | if (k.testBit(i)) { 338 | R = R.add(x); 339 | } 340 | } 341 | --i; 342 | } 343 | 344 | return R; 345 | }; 346 | 347 | // patched by bitaddress.org and Casascius for use with Bitcoin.ECKey 348 | // patched by coretechs to support compressed public keys 349 | ec.PointFp.prototype.getEncoded = function (compressed) { 350 | var x = this.getX().toBigInteger(); 351 | var y = this.getY().toBigInteger(); 352 | var len = 32; // integerToBytes will zero pad if integer is less than 32 bytes. 32 bytes length is required by the Bitcoin protocol. 353 | var enc = ec.integerToBytes(x, len); 354 | 355 | // when compressed prepend byte depending if y point is even or odd 356 | if (compressed) { 357 | if (y.isEven()) { 358 | enc.unshift(0x02); 359 | } 360 | else { 361 | enc.unshift(0x03); 362 | } 363 | } 364 | else { 365 | enc.unshift(0x04); 366 | enc = enc.concat(ec.integerToBytes(y, len)); // uncompressed public key appends the bytes of the y point 367 | } 368 | return enc; 369 | }; 370 | 371 | ec.PointFp.decodeFrom = function (curve, enc) { 372 | var type = enc[0]; 373 | var dataLen = enc.length - 1; 374 | 375 | // Extract x and y as byte arrays 376 | var xBa = enc.slice(1, 1 + dataLen / 2); 377 | var yBa = enc.slice(1 + dataLen / 2, 1 + dataLen); 378 | 379 | // Prepend zero byte to prevent interpretation as negative integer 380 | xBa.unshift(0); 381 | yBa.unshift(0); 382 | 383 | // Convert to BigIntegers 384 | var x = new BigInteger(xBa); 385 | var y = new BigInteger(yBa); 386 | 387 | // Return point 388 | return new ec.PointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y)); 389 | }; 390 | 391 | ec.PointFp.prototype.add2D = function (b) { 392 | if (this.isInfinity()) return b; 393 | if (b.isInfinity()) return this; 394 | 395 | if (this.x.equals(b.x)) { 396 | if (this.y.equals(b.y)) { 397 | // this = b, i.e. this must be doubled 398 | return this.twice(); 399 | } 400 | // this = -b, i.e. the result is the point at infinity 401 | return this.curve.getInfinity(); 402 | } 403 | 404 | var x_x = b.x.subtract(this.x); 405 | var y_y = b.y.subtract(this.y); 406 | var gamma = y_y.divide(x_x); 407 | 408 | var x3 = gamma.square().subtract(this.x).subtract(b.x); 409 | var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y); 410 | 411 | return new ec.PointFp(this.curve, x3, y3); 412 | }; 413 | 414 | ec.PointFp.prototype.twice2D = function () { 415 | if (this.isInfinity()) return this; 416 | if (this.y.toBigInteger().signum() == 0) { 417 | // if y1 == 0, then (x1, y1) == (x1, -y1) 418 | // and hence this = -this and thus 2(x1, y1) == infinity 419 | return this.curve.getInfinity(); 420 | } 421 | 422 | var TWO = this.curve.fromBigInteger(BigInteger.valueOf(2)); 423 | var THREE = this.curve.fromBigInteger(BigInteger.valueOf(3)); 424 | var gamma = this.x.square().multiply(THREE).add(this.curve.a).divide(this.y.multiply(TWO)); 425 | 426 | var x3 = gamma.square().subtract(this.x.multiply(TWO)); 427 | var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y); 428 | 429 | return new ec.PointFp(this.curve, x3, y3); 430 | }; 431 | 432 | ec.PointFp.prototype.multiply2D = function (k) { 433 | if (this.isInfinity()) return this; 434 | if (k.signum() == 0) return this.curve.getInfinity(); 435 | 436 | var e = k; 437 | var h = e.multiply(new BigInteger("3")); 438 | 439 | var neg = this.negate(); 440 | var R = this; 441 | 442 | var i; 443 | for (i = h.bitLength() - 2; i > 0; --i) { 444 | R = R.twice(); 445 | 446 | var hBit = h.testBit(i); 447 | var eBit = e.testBit(i); 448 | 449 | if (hBit != eBit) { 450 | R = R.add2D(hBit ? this : neg); 451 | } 452 | } 453 | 454 | return R; 455 | }; 456 | 457 | ec.PointFp.prototype.isOnCurve = function () { 458 | var x = this.getX().toBigInteger(); 459 | var y = this.getY().toBigInteger(); 460 | var a = this.curve.getA().toBigInteger(); 461 | var b = this.curve.getB().toBigInteger(); 462 | var n = this.curve.getQ(); 463 | var lhs = y.multiply(y).mod(n); 464 | var rhs = x.multiply(x).multiply(x).add(a.multiply(x)).add(b).mod(n); 465 | return lhs.equals(rhs); 466 | }; 467 | 468 | ec.PointFp.prototype.toString = function () { 469 | return '(' + this.getX().toBigInteger().toString() + ',' + this.getY().toBigInteger().toString() + ')'; 470 | }; 471 | 472 | /** 473 | * Validate an elliptic curve point. 474 | * 475 | * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive 476 | */ 477 | ec.PointFp.prototype.validate = function () { 478 | var n = this.curve.getQ(); 479 | 480 | // Check Q != O 481 | if (this.isInfinity()) { 482 | throw new Error("Point is at infinity."); 483 | } 484 | 485 | // Check coordinate bounds 486 | var x = this.getX().toBigInteger(); 487 | var y = this.getY().toBigInteger(); 488 | if (x.compareTo(BigInteger.ONE) < 0 || x.compareTo(n.subtract(BigInteger.ONE)) > 0) { 489 | throw new Error('x coordinate out of bounds'); 490 | } 491 | if (y.compareTo(BigInteger.ONE) < 0 || y.compareTo(n.subtract(BigInteger.ONE)) > 0) { 492 | throw new Error('y coordinate out of bounds'); 493 | } 494 | 495 | // Check y^2 = x^3 + ax + b (mod n) 496 | if (!this.isOnCurve()) { 497 | throw new Error("Point is not on the curve."); 498 | } 499 | 500 | // Check nQ = 0 (Q is a scalar multiple of G) 501 | if (this.multiply(n).isInfinity()) { 502 | // TODO: This check doesn't work - fix. 503 | throw new Error("Point is not a scalar multiple of G."); 504 | } 505 | 506 | return true; 507 | }; 508 | 509 | 510 | 511 | 512 | // ---------------- 513 | // ECCurveFp constructor 514 | ec.CurveFp = function (q, a, b) { 515 | this.q = q; 516 | this.a = this.fromBigInteger(a); 517 | this.b = this.fromBigInteger(b); 518 | this.infinity = new ec.PointFp(this, null, null); 519 | this.reducer = new Barrett(this.q); 520 | } 521 | 522 | ec.CurveFp.prototype.getQ = function () { 523 | return this.q; 524 | }; 525 | 526 | ec.CurveFp.prototype.getA = function () { 527 | return this.a; 528 | }; 529 | 530 | ec.CurveFp.prototype.getB = function () { 531 | return this.b; 532 | }; 533 | 534 | ec.CurveFp.prototype.equals = function (other) { 535 | if (other == this) return true; 536 | return (this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b)); 537 | }; 538 | 539 | ec.CurveFp.prototype.getInfinity = function () { 540 | return this.infinity; 541 | }; 542 | 543 | ec.CurveFp.prototype.fromBigInteger = function (x) { 544 | return new ec.FieldElementFp(this.q, x); 545 | }; 546 | 547 | ec.CurveFp.prototype.reduce = function (x) { 548 | this.reducer.reduce(x); 549 | }; 550 | 551 | // for now, work with hex strings because they're easier in JS 552 | // compressed support added by bitaddress.org 553 | ec.CurveFp.prototype.decodePointHex = function (s) { 554 | var firstByte = parseInt(s.substr(0, 2), 16); 555 | switch (firstByte) { // first byte 556 | case 0: 557 | return this.infinity; 558 | case 2: // compressed 559 | case 3: // compressed 560 | var yTilde = firstByte & 1; 561 | var xHex = s.substr(2, s.length - 2); 562 | var X1 = new BigInteger(xHex, 16); 563 | return this.decompressPoint(yTilde, X1); 564 | case 4: // uncompressed 565 | case 6: // hybrid 566 | case 7: // hybrid 567 | var len = (s.length - 2) / 2; 568 | var xHex = s.substr(2, len); 569 | var yHex = s.substr(len + 2, len); 570 | 571 | return new ec.PointFp(this, 572 | this.fromBigInteger(new BigInteger(xHex, 16)), 573 | this.fromBigInteger(new BigInteger(yHex, 16))); 574 | 575 | default: // unsupported 576 | return null; 577 | } 578 | }; 579 | 580 | ec.CurveFp.prototype.encodePointHex = function (p) { 581 | if (p.isInfinity()) return "00"; 582 | var xHex = p.getX().toBigInteger().toString(16); 583 | var yHex = p.getY().toBigInteger().toString(16); 584 | var oLen = this.getQ().toString(16).length; 585 | if ((oLen % 2) != 0) oLen++; 586 | while (xHex.length < oLen) { 587 | xHex = "0" + xHex; 588 | } 589 | while (yHex.length < oLen) { 590 | yHex = "0" + yHex; 591 | } 592 | return "04" + xHex + yHex; 593 | }; 594 | 595 | /* 596 | * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org) 597 | * Ported to JavaScript by bitaddress.org 598 | * 599 | * Number yTilde 600 | * BigInteger X1 601 | */ 602 | ec.CurveFp.prototype.decompressPoint = function (yTilde, X1) { 603 | var x = this.fromBigInteger(X1); 604 | var alpha = x.multiply(x.square().add(this.getA())).add(this.getB()); 605 | var beta = alpha.sqrt(); 606 | // if we can't find a sqrt we haven't got a point on the curve - run! 607 | if (beta == null) throw new Error("Invalid point compression"); 608 | var betaValue = beta.toBigInteger(); 609 | var bit0 = betaValue.testBit(0) ? 1 : 0; 610 | if (bit0 != yTilde) { 611 | // Use the other root 612 | beta = this.fromBigInteger(this.getQ().subtract(betaValue)); 613 | } 614 | return new ec.PointFp(this, x, beta, null, true); 615 | }; 616 | 617 | 618 | ec.fromHex = function (s) { return new BigInteger(s, 16); }; 619 | 620 | ec.integerToBytes = function (i, len) { 621 | var bytes = i.toByteArrayUnsigned(); 622 | if (len < bytes.length) { 623 | bytes = bytes.slice(bytes.length - len); 624 | } else while (len > bytes.length) { 625 | bytes.unshift(0); 626 | } 627 | return bytes; 628 | }; 629 | 630 | 631 | // Named EC curves 632 | // ---------------- 633 | // X9ECParameters constructor 634 | ec.X9Parameters = function (curve, g, n, h) { 635 | this.curve = curve; 636 | this.g = g; 637 | this.n = n; 638 | this.h = h; 639 | } 640 | ec.X9Parameters.prototype.getCurve = function () { return this.curve; }; 641 | ec.X9Parameters.prototype.getG = function () { return this.g; }; 642 | ec.X9Parameters.prototype.getN = function () { return this.n; }; 643 | ec.X9Parameters.prototype.getH = function () { return this.h; }; 644 | 645 | // secp256k1 is the Curve used by Bitcoin 646 | ec.secNamedCurves = { 647 | // used by Bitcoin 648 | "secp256k1": function () { 649 | // p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1 650 | var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"); 651 | var a = BigInteger.ZERO; 652 | var b = ec.fromHex("7"); 653 | var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"); 654 | var h = BigInteger.ONE; 655 | var curve = new ec.CurveFp(p, a, b); 656 | var G = curve.decodePointHex("04" 657 | + "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798" 658 | + "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8"); 659 | return new ec.X9Parameters(curve, G, n, h); 660 | } 661 | }; 662 | 663 | // secp256k1 called by Bitcoin's ECKEY 664 | ec.getSECCurveByName = function (name) { 665 | if (ec.secNamedCurves[name] == undefined) return null; 666 | return ec.secNamedCurves[name](); 667 | } 668 | })(); 669 | -------------------------------------------------------------------------------- /public/assets/js/wallet/qrcode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview 3 | * - Using the 'QRCode for Javascript library' 4 | * - Fixed dataset of 'QRCode for Javascript library' for support full-spec. 5 | * - this library has no dependencies. 6 | * 7 | * @author davidshimjs 8 | * @see http://www.d-project.com/ 9 | * @see http://jeromeetienne.github.com/jquery-qrcode/ 10 | */ 11 | var QRCode; 12 | 13 | (function () { 14 | //--------------------------------------------------------------------- 15 | // QRCode for JavaScript 16 | // 17 | // Copyright (c) 2009 Kazuhiko Arase 18 | // 19 | // URL: http://www.d-project.com/ 20 | // 21 | // Licensed under the MIT license: 22 | // http://www.opensource.org/licenses/mit-license.php 23 | // 24 | // The word "QR Code" is registered trademark of 25 | // DENSO WAVE INCORPORATED 26 | // http://www.denso-wave.com/qrcode/faqpatent-e.html 27 | // 28 | //--------------------------------------------------------------------- 29 | function QR8bitByte(data) { 30 | this.mode = QRMode.MODE_8BIT_BYTE; 31 | this.data = data; 32 | this.parsedData = []; 33 | 34 | // Added to support UTF-8 Characters 35 | for (var i = 0, l = this.data.length; i < l; i++) { 36 | var byteArray = []; 37 | var code = this.data.charCodeAt(i); 38 | 39 | if (code > 0x10000) { 40 | byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18); 41 | byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12); 42 | byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6); 43 | byteArray[3] = 0x80 | (code & 0x3F); 44 | } else if (code > 0x800) { 45 | byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12); 46 | byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6); 47 | byteArray[2] = 0x80 | (code & 0x3F); 48 | } else if (code > 0x80) { 49 | byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6); 50 | byteArray[1] = 0x80 | (code & 0x3F); 51 | } else { 52 | byteArray[0] = code; 53 | } 54 | 55 | this.parsedData.push(byteArray); 56 | } 57 | 58 | this.parsedData = Array.prototype.concat.apply([], this.parsedData); 59 | 60 | if (this.parsedData.length != this.data.length) { 61 | this.parsedData.unshift(191); 62 | this.parsedData.unshift(187); 63 | this.parsedData.unshift(239); 64 | } 65 | } 66 | 67 | QR8bitByte.prototype = { 68 | getLength: function (buffer) { 69 | return this.parsedData.length; 70 | }, 71 | write: function (buffer) { 72 | for (var i = 0, l = this.parsedData.length; i < l; i++) { 73 | buffer.put(this.parsedData[i], 8); 74 | } 75 | } 76 | }; 77 | 78 | function QRCodeModel(typeNumber, errorCorrectLevel) { 79 | this.typeNumber = typeNumber; 80 | this.errorCorrectLevel = errorCorrectLevel; 81 | this.modules = null; 82 | this.moduleCount = 0; 83 | this.dataCache = null; 84 | this.dataList = []; 85 | } 86 | 87 | QRCodeModel.prototype={addData:function(data){var newData=new QR8bitByte(data);this.dataList.push(newData);this.dataCache=null;},isDark:function(row,col){if(row<0||this.moduleCount<=row||col<0||this.moduleCount<=col){throw new Error(row+","+col);} 88 | return this.modules[row][col];},getModuleCount:function(){return this.moduleCount;},make:function(){this.makeImpl(false,this.getBestMaskPattern());},makeImpl:function(test,maskPattern){this.moduleCount=this.typeNumber*4+17;this.modules=new Array(this.moduleCount);for(var row=0;row=7){this.setupTypeNumber(test);} 90 | if(this.dataCache==null){this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList);} 91 | this.mapData(this.dataCache,maskPattern);},setupPositionProbePattern:function(row,col){for(var r=-1;r<=7;r++){if(row+r<=-1||this.moduleCount<=row+r)continue;for(var c=-1;c<=7;c++){if(col+c<=-1||this.moduleCount<=col+c)continue;if((0<=r&&r<=6&&(c==0||c==6))||(0<=c&&c<=6&&(r==0||r==6))||(2<=r&&r<=4&&2<=c&&c<=4)){this.modules[row+r][col+c]=true;}else{this.modules[row+r][col+c]=false;}}}},getBestMaskPattern:function(){var minLostPoint=0;var pattern=0;for(var i=0;i<8;i++){this.makeImpl(true,i);var lostPoint=QRUtil.getLostPoint(this);if(i==0||minLostPoint>lostPoint){minLostPoint=lostPoint;pattern=i;}} 92 | return pattern;},createMovieClip:function(target_mc,instance_name,depth){var qr_mc=target_mc.createEmptyMovieClip(instance_name,depth);var cs=1;this.make();for(var row=0;row>i)&1)==1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3]=mod;} 98 | for(var i=0;i<18;i++){var mod=(!test&&((bits>>i)&1)==1);this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=mod;}},setupTypeInfo:function(test,maskPattern){var data=(this.errorCorrectLevel<<3)|maskPattern;var bits=QRUtil.getBCHTypeInfo(data);for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<6){this.modules[i][8]=mod;}else if(i<8){this.modules[i+1][8]=mod;}else{this.modules[this.moduleCount-15+i][8]=mod;}} 99 | for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<8){this.modules[8][this.moduleCount-i-1]=mod;}else if(i<9){this.modules[8][15-i-1+1]=mod;}else{this.modules[8][15-i-1]=mod;}} 100 | this.modules[this.moduleCount-8][8]=(!test);},mapData:function(data,maskPattern){var inc=-1;var row=this.moduleCount-1;var bitIndex=7;var byteIndex=0;for(var col=this.moduleCount-1;col>0;col-=2){if(col==6)col--;while(true){for(var c=0;c<2;c++){if(this.modules[row][col-c]==null){var dark=false;if(byteIndex>>bitIndex)&1)==1);} 101 | var mask=QRUtil.getMask(maskPattern,row,col-c);if(mask){dark=!dark;} 102 | this.modules[row][col-c]=dark;bitIndex--;if(bitIndex==-1){byteIndex++;bitIndex=7;}}} 103 | row+=inc;if(row<0||this.moduleCount<=row){row-=inc;inc=-inc;break;}}}}};QRCodeModel.PAD0=0xEC;QRCodeModel.PAD1=0x11;QRCodeModel.createData=function(typeNumber,errorCorrectLevel,dataList){var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel);var buffer=new QRBitBuffer();for(var i=0;itotalDataCount*8){throw new Error("code length overflow. (" 106 | +buffer.getLengthInBits() 107 | +">" 108 | +totalDataCount*8 109 | +")");} 110 | if(buffer.getLengthInBits()+4<=totalDataCount*8){buffer.put(0,4);} 111 | while(buffer.getLengthInBits()%8!=0){buffer.putBit(false);} 112 | while(true){if(buffer.getLengthInBits()>=totalDataCount*8){break;} 113 | buffer.put(QRCodeModel.PAD0,8);if(buffer.getLengthInBits()>=totalDataCount*8){break;} 114 | buffer.put(QRCodeModel.PAD1,8);} 115 | return QRCodeModel.createBytes(buffer,rsBlocks);};QRCodeModel.createBytes=function(buffer,rsBlocks){var offset=0;var maxDcCount=0;var maxEcCount=0;var dcdata=new Array(rsBlocks.length);var ecdata=new Array(rsBlocks.length);for(var r=0;r=0)?modPoly.get(modIndex):0;}} 117 | var totalCodeCount=0;for(var i=0;i=0){d^=(QRUtil.G15<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15)));} 121 | return((data<<10)|d)^QRUtil.G15_MASK;},getBCHTypeNumber:function(data){var d=data<<12;while(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)>=0){d^=(QRUtil.G18<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)));} 122 | return(data<<12)|d;},getBCHDigit:function(data){var digit=0;while(data!=0){digit++;data>>>=1;} 123 | return digit;},getPatternPosition:function(typeNumber){return QRUtil.PATTERN_POSITION_TABLE[typeNumber-1];},getMask:function(maskPattern,i,j){switch(maskPattern){case QRMaskPattern.PATTERN000:return(i+j)%2==0;case QRMaskPattern.PATTERN001:return i%2==0;case QRMaskPattern.PATTERN010:return j%3==0;case QRMaskPattern.PATTERN011:return(i+j)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(i/2)+Math.floor(j/3))%2==0;case QRMaskPattern.PATTERN101:return(i*j)%2+(i*j)%3==0;case QRMaskPattern.PATTERN110:return((i*j)%2+(i*j)%3)%2==0;case QRMaskPattern.PATTERN111:return((i*j)%3+(i+j)%2)%2==0;default:throw new Error("bad maskPattern:"+maskPattern);}},getErrorCorrectPolynomial:function(errorCorrectLength){var a=new QRPolynomial([1],0);for(var i=0;i5){lostPoint+=(3+sameCount-5);}}} 129 | for(var row=0;row=256){n-=255;} 136 | return QRMath.EXP_TABLE[n];},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var i=0;i<8;i++){QRMath.EXP_TABLE[i]=1<>>(7-index%8))&1)==1;},put:function(num,length){for(var i=0;i>>(length-i-1))&1)==1);}},getLengthInBits:function(){return this.length;},putBit:function(bit){var bufIndex=Math.floor(this.length/8);if(this.buffer.length<=bufIndex){this.buffer.push(0);} 151 | if(bit){this.buffer[bufIndex]|=(0x80>>>(this.length%8));} 152 | this.length++;}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]; 153 | 154 | function _isSupportCanvas() { 155 | return typeof CanvasRenderingContext2D != "undefined"; 156 | } 157 | 158 | // android 2.x doesn't support Data-URI spec 159 | function _getAndroid() { 160 | var android = false; 161 | var sAgent = navigator.userAgent; 162 | 163 | if (/android/i.test(sAgent)) { // android 164 | android = true; 165 | var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i); 166 | 167 | if (aMat && aMat[1]) { 168 | android = parseFloat(aMat[1]); 169 | } 170 | } 171 | 172 | return android; 173 | } 174 | 175 | var svgDrawer = (function() { 176 | 177 | var Drawing = function (el, htOption) { 178 | this._el = el; 179 | this._htOption = htOption; 180 | }; 181 | 182 | Drawing.prototype.draw = function (oQRCode) { 183 | var _htOption = this._htOption; 184 | var _el = this._el; 185 | var nCount = oQRCode.getModuleCount(); 186 | var nWidth = Math.floor(_htOption.width / nCount); 187 | var nHeight = Math.floor(_htOption.height / nCount); 188 | 189 | this.clear(); 190 | 191 | function makeSVG(tag, attrs) { 192 | var el = document.createElementNS('http://www.w3.org/2000/svg', tag); 193 | for (var k in attrs) 194 | if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k]); 195 | return el; 196 | } 197 | 198 | var svg = makeSVG("svg" , {'viewBox': '0 0 ' + String(nCount) + " " + String(nCount), 'width': '100%', 'height': '100%', 'fill': _htOption.colorLight}); 199 | svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink"); 200 | _el.appendChild(svg); 201 | 202 | svg.appendChild(makeSVG("rect", {"fill": _htOption.colorLight, "width": "100%", "height": "100%"})); 203 | svg.appendChild(makeSVG("rect", {"fill": _htOption.colorDark, "width": "1", "height": "1", "id": "template"})); 204 | 205 | for (var row = 0; row < nCount; row++) { 206 | for (var col = 0; col < nCount; col++) { 207 | if (oQRCode.isDark(row, col)) { 208 | var child = makeSVG("use", {"x": String(row), "y": String(col)}); 209 | child.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template") 210 | svg.appendChild(child); 211 | } 212 | } 213 | } 214 | }; 215 | Drawing.prototype.clear = function () { 216 | while (this._el.hasChildNodes()) 217 | this._el.removeChild(this._el.lastChild); 218 | }; 219 | return Drawing; 220 | })(); 221 | 222 | var useSVG = document.documentElement.tagName.toLowerCase() === "svg"; 223 | 224 | // Drawing in DOM by using Table tag 225 | var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() ? (function () { 226 | var Drawing = function (el, htOption) { 227 | this._el = el; 228 | this._htOption = htOption; 229 | }; 230 | 231 | /** 232 | * Draw the QRCode 233 | * 234 | * @param {QRCode} oQRCode 235 | */ 236 | Drawing.prototype.draw = function (oQRCode) { 237 | var _htOption = this._htOption; 238 | var _el = this._el; 239 | var nCount = oQRCode.getModuleCount(); 240 | var nWidth = Math.floor(_htOption.width / nCount); 241 | var nHeight = Math.floor(_htOption.height / nCount); 242 | var aHTML = ['']; 243 | 244 | for (var row = 0; row < nCount; row++) { 245 | aHTML.push(''); 246 | 247 | for (var col = 0; col < nCount; col++) { 248 | aHTML.push(''); 249 | } 250 | 251 | aHTML.push(''); 252 | } 253 | 254 | aHTML.push('
'); 255 | _el.innerHTML = aHTML.join(''); 256 | 257 | // Fix the margin values as real size. 258 | var elTable = _el.childNodes[0]; 259 | var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2; 260 | var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2; 261 | 262 | if (nLeftMarginTable > 0 && nTopMarginTable > 0) { 263 | elTable.style.margin = nTopMarginTable + "px " + nLeftMarginTable + "px"; 264 | } 265 | }; 266 | 267 | /** 268 | * Clear the QRCode 269 | */ 270 | Drawing.prototype.clear = function () { 271 | this._el.innerHTML = ''; 272 | }; 273 | 274 | return Drawing; 275 | })() : (function () { // Drawing in Canvas 276 | function _onMakeImage() { 277 | this._elImage.src = this._elCanvas.toDataURL("image/png"); 278 | this._elImage.style.display = "block"; 279 | this._elCanvas.style.display = "none"; 280 | } 281 | 282 | // Android 2.1 bug workaround 283 | // http://code.google.com/p/android/issues/detail?id=5141 284 | if (this._android && this._android <= 2.1) { 285 | var factor = 1 / window.devicePixelRatio; 286 | var drawImage = CanvasRenderingContext2D.prototype.drawImage; 287 | CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) { 288 | if (("nodeName" in image) && /img/i.test(image.nodeName)) { 289 | for (var i = arguments.length - 1; i >= 1; i--) { 290 | arguments[i] = arguments[i] * factor; 291 | } 292 | } else if (typeof dw == "undefined") { 293 | arguments[1] *= factor; 294 | arguments[2] *= factor; 295 | arguments[3] *= factor; 296 | arguments[4] *= factor; 297 | } 298 | 299 | drawImage.apply(this, arguments); 300 | }; 301 | } 302 | 303 | /** 304 | * Check whether the user's browser supports Data URI or not 305 | * 306 | * @private 307 | * @param {Function} fSuccess Occurs if it supports Data URI 308 | * @param {Function} fFail Occurs if it doesn't support Data URI 309 | */ 310 | function _safeSetDataURI(fSuccess, fFail) { 311 | var self = this; 312 | self._fFail = fFail; 313 | self._fSuccess = fSuccess; 314 | 315 | // Check it just once 316 | if (self._bSupportDataURI === null) { 317 | var el = document.createElement("img"); 318 | var fOnError = function() { 319 | self._bSupportDataURI = false; 320 | 321 | if (self._fFail) { 322 | self._fFail.call(self); 323 | } 324 | }; 325 | var fOnSuccess = function() { 326 | self._bSupportDataURI = true; 327 | 328 | if (self._fSuccess) { 329 | self._fSuccess.call(self); 330 | } 331 | }; 332 | 333 | el.onabort = fOnError; 334 | el.onerror = fOnError; 335 | el.onload = fOnSuccess; 336 | el.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // the Image contains 1px data. 337 | return; 338 | } else if (self._bSupportDataURI === true && self._fSuccess) { 339 | self._fSuccess.call(self); 340 | } else if (self._bSupportDataURI === false && self._fFail) { 341 | self._fFail.call(self); 342 | } 343 | }; 344 | 345 | /** 346 | * Drawing QRCode by using canvas 347 | * 348 | * @constructor 349 | * @param {HTMLElement} el 350 | * @param {Object} htOption QRCode Options 351 | */ 352 | var Drawing = function (el, htOption) { 353 | this._bIsPainted = false; 354 | this._android = _getAndroid(); 355 | 356 | this._htOption = htOption; 357 | this._elCanvas = document.createElement("canvas"); 358 | this._elCanvas.width = htOption.width; 359 | this._elCanvas.height = htOption.height; 360 | el.appendChild(this._elCanvas); 361 | this._el = el; 362 | this._oContext = this._elCanvas.getContext("2d"); 363 | this._bIsPainted = false; 364 | this._elImage = document.createElement("img"); 365 | this._elImage.alt = "Scan me!"; 366 | this._elImage.style.display = "none"; 367 | this._el.appendChild(this._elImage); 368 | this._bSupportDataURI = null; 369 | }; 370 | 371 | /** 372 | * Draw the QRCode 373 | * 374 | * @param {QRCode} oQRCode 375 | */ 376 | Drawing.prototype.draw = function (oQRCode) { 377 | var _elImage = this._elImage; 378 | var _oContext = this._oContext; 379 | var _htOption = this._htOption; 380 | 381 | var nCount = oQRCode.getModuleCount(); 382 | var nWidth = _htOption.width / nCount; 383 | var nHeight = _htOption.height / nCount; 384 | var nRoundedWidth = Math.round(nWidth); 385 | var nRoundedHeight = Math.round(nHeight); 386 | 387 | _elImage.style.display = "none"; 388 | this.clear(); 389 | 390 | for (var row = 0; row < nCount; row++) { 391 | for (var col = 0; col < nCount; col++) { 392 | var bIsDark = oQRCode.isDark(row, col); 393 | var nLeft = col * nWidth; 394 | var nTop = row * nHeight; 395 | _oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight; 396 | _oContext.lineWidth = 1; 397 | _oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight; 398 | _oContext.fillRect(nLeft, nTop, nWidth, nHeight); 399 | 400 | // 안티 앨리어싱 방지 처리 401 | _oContext.strokeRect( 402 | Math.floor(nLeft) + 0.5, 403 | Math.floor(nTop) + 0.5, 404 | nRoundedWidth, 405 | nRoundedHeight 406 | ); 407 | 408 | _oContext.strokeRect( 409 | Math.ceil(nLeft) - 0.5, 410 | Math.ceil(nTop) - 0.5, 411 | nRoundedWidth, 412 | nRoundedHeight 413 | ); 414 | } 415 | } 416 | 417 | this._bIsPainted = true; 418 | }; 419 | 420 | /** 421 | * Make the image from Canvas if the browser supports Data URI. 422 | */ 423 | Drawing.prototype.makeImage = function () { 424 | if (this._bIsPainted) { 425 | _safeSetDataURI.call(this, _onMakeImage); 426 | } 427 | }; 428 | 429 | /** 430 | * Return whether the QRCode is painted or not 431 | * 432 | * @return {Boolean} 433 | */ 434 | Drawing.prototype.isPainted = function () { 435 | return this._bIsPainted; 436 | }; 437 | 438 | /** 439 | * Clear the QRCode 440 | */ 441 | Drawing.prototype.clear = function () { 442 | this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height); 443 | this._bIsPainted = false; 444 | }; 445 | 446 | /** 447 | * @private 448 | * @param {Number} nNumber 449 | */ 450 | Drawing.prototype.round = function (nNumber) { 451 | if (!nNumber) { 452 | return nNumber; 453 | } 454 | 455 | return Math.floor(nNumber * 1000) / 1000; 456 | }; 457 | 458 | return Drawing; 459 | })(); 460 | 461 | /** 462 | * Get the type by string length 463 | * 464 | * @private 465 | * @param {String} sText 466 | * @param {Number} nCorrectLevel 467 | * @return {Number} type 468 | */ 469 | function _getTypeNumber(sText, nCorrectLevel) { 470 | var nType = 1; 471 | var length = _getUTF8Length(sText); 472 | 473 | for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) { 474 | var nLimit = 0; 475 | 476 | switch (nCorrectLevel) { 477 | case QRErrorCorrectLevel.L : 478 | nLimit = QRCodeLimitLength[i][0]; 479 | break; 480 | case QRErrorCorrectLevel.M : 481 | nLimit = QRCodeLimitLength[i][1]; 482 | break; 483 | case QRErrorCorrectLevel.Q : 484 | nLimit = QRCodeLimitLength[i][2]; 485 | break; 486 | case QRErrorCorrectLevel.H : 487 | nLimit = QRCodeLimitLength[i][3]; 488 | break; 489 | } 490 | 491 | if (length <= nLimit) { 492 | break; 493 | } else { 494 | nType++; 495 | } 496 | } 497 | 498 | if (nType > QRCodeLimitLength.length) { 499 | throw new Error("Too long data"); 500 | } 501 | 502 | return nType; 503 | } 504 | 505 | function _getUTF8Length(sText) { 506 | var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a'); 507 | return replacedText.length + (replacedText.length != sText ? 3 : 0); 508 | } 509 | 510 | /** 511 | * @class QRCode 512 | * @constructor 513 | * @example 514 | * new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie"); 515 | * 516 | * @example 517 | * var oQRCode = new QRCode("test", { 518 | * text : "http://naver.com", 519 | * width : 128, 520 | * height : 128 521 | * }); 522 | * 523 | * oQRCode.clear(); // Clear the QRCode. 524 | * oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode. 525 | * 526 | * @param {HTMLElement|String} el target element or 'id' attribute of element. 527 | * @param {Object|String} vOption 528 | * @param {String} vOption.text QRCode link data 529 | * @param {Number} [vOption.width=256] 530 | * @param {Number} [vOption.height=256] 531 | * @param {String} [vOption.colorDark="#000000"] 532 | * @param {String} [vOption.colorLight="#ffffff"] 533 | * @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H] 534 | */ 535 | QRCode = function (el, vOption) { 536 | this._htOption = { 537 | width : 256, 538 | height : 256, 539 | typeNumber : 4, 540 | colorDark : "#000000", 541 | colorLight : "#ffffff", 542 | correctLevel : QRErrorCorrectLevel.H 543 | }; 544 | 545 | if (typeof vOption === 'string') { 546 | vOption = { 547 | text : vOption 548 | }; 549 | } 550 | 551 | // Overwrites options 552 | if (vOption) { 553 | for (var i in vOption) { 554 | this._htOption[i] = vOption[i]; 555 | } 556 | } 557 | 558 | if (typeof el == "string") { 559 | el = document.getElementById(el); 560 | } 561 | 562 | if (this._htOption.useSVG) { 563 | Drawing = svgDrawer; 564 | } 565 | 566 | this._android = _getAndroid(); 567 | this._el = el; 568 | this._oQRCode = null; 569 | this._oDrawing = new Drawing(this._el, this._htOption); 570 | 571 | if (this._htOption.text) { 572 | this.makeCode(this._htOption.text); 573 | } 574 | }; 575 | 576 | /** 577 | * Make the QRCode 578 | * 579 | * @param {String} sText link data 580 | */ 581 | QRCode.prototype.makeCode = function (sText) { 582 | this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel); 583 | this._oQRCode.addData(sText); 584 | this._oQRCode.make(); 585 | this._el.title = sText; 586 | this._oDrawing.draw(this._oQRCode); 587 | this.makeImage(); 588 | }; 589 | 590 | /** 591 | * Make the Image from Canvas element 592 | * - It occurs automatically 593 | * - Android below 3 doesn't support Data-URI spec. 594 | * 595 | * @private 596 | */ 597 | QRCode.prototype.makeImage = function () { 598 | if (typeof this._oDrawing.makeImage == "function" && (!this._android || this._android >= 3)) { 599 | this._oDrawing.makeImage(); 600 | } 601 | }; 602 | 603 | /** 604 | * Clear the QRCode 605 | */ 606 | QRCode.prototype.clear = function () { 607 | this._oDrawing.clear(); 608 | }; 609 | 610 | /** 611 | * @name QRCode.CorrectLevel 612 | */ 613 | QRCode.CorrectLevel = QRErrorCorrectLevel; 614 | })(); 615 | --------------------------------------------------------------------------------