|
1 | | - |
2 | | - |
3 | | -# WrkzCoin: Standalone Cryptography Library |
4 | | - |
5 | | - [](https://github.com/wrkzcoin/wrkzcoin-crypto/graphs/commit-activity) [](https://github.com/wrkzcoin/wrkzcoin-crypto/blob/master/LICENSE) [](https://twitter.com/_WrkzCoin) |
6 | | - |
7 | | -#### Master Build Status |
8 | | -[](https://github.com/wrkzcoin/wrkzcoin-crypto/actions) |
9 | | - |
10 | | -#### Development Build Status |
11 | | -[](https://github.com/wrkzcoin/wrkzcoin-crypto/actions) |
12 | | - |
13 | | -This repository contains the necessary files to compile the cryptography library used within [WrkzCoin](https://wrkzcoin.lol) as a standalone library that can be included in various other projects in a variety of development environments, including: |
14 | | - |
15 | | -* Node.js >= 6.x |
16 | | -* C++ |
17 | | -* C# (via C++ shared library & P/Invoke) |
18 | | -* Native Javascript |
19 | | -* WASM |
20 | | - |
21 | | -## Javascript Library |
22 | | - |
23 | | -**Note:** This library is currently source-distributed. Build the Node.js native addon and WASM/JS binaries locally. |
24 | | - |
25 | | -### Dependencies |
26 | | - |
27 | | -* [Node.js](https://nodejs.org) >= +6.x LTS (or Node v11) |
28 | | - |
29 | | -#### Windows |
30 | | - |
31 | | -##### Prerequisites |
32 | | - |
33 | | -Read very careful if you want this to work right the first time. |
34 | | - |
35 | | -1) Open a *Windows Powershell* console as **Administrator** |
36 | | - |
37 | | -2) Run the command: `npm install -g windows-build-tools --vs2015` |
38 | | - ***This will take a while. Sit tight.*** |
39 | | - |
40 | | -### Installation (from source) |
| 1 | +# WrkzCoin Crypto Library |
| 2 | + |
| 3 | +Standalone cryptography library for WrkzCoin with a focus on building `wrkzcoin-crypto-wasm.js` for multiple Linux distributions and platforms. |
| 4 | + |
| 5 | +## Build Targets |
| 6 | + |
| 7 | +- WASM JS bundle: `dist/wrkzcoin-crypto-wasm.js` |
| 8 | +- Native JS bundle: `dist/wrkzcoin-crypto.js` |
| 9 | + |
| 10 | +## Quick Build (WASM-focused) |
41 | 11 |
|
42 | 12 | ```bash |
43 | 13 | git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
44 | 14 | cd wrkzcoin-crypto |
45 | | -npm install |
46 | | -npm run build-typescript |
47 | | -npm run build-native |
| 15 | +yarn install |
| 16 | +yarn build-typescript |
| 17 | +``` |
| 18 | + |
| 19 | +Then build WASM/JS: |
| 20 | + |
| 21 | +```bash |
| 22 | +yarn build-native |
| 23 | +``` |
| 24 | + |
| 25 | +If `yarn build-native` fails due to submodule/private repo fetch, use the manual build path below. |
| 26 | + |
| 27 | +## Manual WASM Build (No `build-native` script) |
| 28 | + |
| 29 | +Prerequisite: Emscripten tools available in `PATH` (`emcmake`, `emconfigure`, `emmake`). |
| 30 | + |
| 31 | +```bash |
| 32 | +mkdir -p dist |
| 33 | +mkdir -p jsbuild |
| 34 | +cd jsbuild |
| 35 | + |
| 36 | +emconfigure cmake .. -DNO_AES=1 -DARCH=default -DBUILD_WASM=1 -DBUILD_JS=0 |
| 37 | +cmake --build . -- -j |
| 38 | +cp wrkzcoin-crypto-wasm.js ../dist/ |
| 39 | + |
| 40 | +emconfigure cmake .. -DNO_AES=1 -DARCH=default -DBUILD_WASM=0 -DBUILD_JS=1 |
| 41 | +cmake --build . -- -j |
| 42 | +cp wrkzcoin-crypto.js ../dist/ |
| 43 | +``` |
| 44 | + |
| 45 | +## Platform Prerequisites |
| 46 | + |
| 47 | +### Ubuntu / Debian |
| 48 | + |
| 49 | +```bash |
| 50 | +sudo apt-get update |
| 51 | +sudo apt-get install -y build-essential cmake git python3 make curl |
48 | 52 | ``` |
49 | | - |
50 | | -### Intialization |
51 | | - |
52 | | -#### TypeScript |
53 | | - |
54 | | -```javascript |
| 53 | + |
| 54 | +### Fedora / RHEL / Rocky |
| 55 | + |
| 56 | +```bash |
| 57 | +sudo dnf groupinstall -y "Development Tools" |
| 58 | +sudo dnf install -y cmake git python3 make curl |
| 59 | +``` |
| 60 | + |
| 61 | +### Alpine |
| 62 | + |
| 63 | +```bash |
| 64 | +sudo apk add --no-cache build-base cmake git python3 make bash curl |
| 65 | +``` |
| 66 | + |
| 67 | +### macOS |
| 68 | + |
| 69 | +```bash |
| 70 | +xcode-select --install |
| 71 | +brew install cmake git python make |
| 72 | +``` |
| 73 | + |
| 74 | +### Windows |
| 75 | + |
| 76 | +Recommended: WSL2 (Ubuntu) and use Linux steps above. |
| 77 | + |
| 78 | +## TypeScript Usage (Local Build) |
| 79 | + |
| 80 | +```ts |
55 | 81 | import { Crypto } from './dist'; |
56 | | -const WrkzCoinCrypto = new Crypto(); |
57 | | -``` |
58 | | - |
59 | | -#### CommonJS |
60 | | - |
61 | | -```javascript |
62 | | -const Crypto = require('./dist').Crypto |
63 | | -const WrkzCoinCrypto = new Crypto() |
64 | | -``` |
65 | | - |
66 | | -#### Documentation |
67 | | - |
68 | | -You can find the full TypeScript/JS documentation for this library [here](https://crypto.wrkzcoin.dev). |
69 | | - |
70 | | -## C++ Library |
71 | | - |
72 | | -### How To Compile |
73 | | - |
74 | | -#### Build Optimization |
75 | | - |
76 | | -The CMake build system will, by default, create optimized *native* builds for your particular system type when you build the software. Using this method, the binaries created provide a better experience and all together faster performance. |
77 | | - |
78 | | -However, if you wish to create *portable* binaries that can be shared between systems, specify `-DARCH=default` in your CMake arguments during the build process. Note that *portable* binaries will have a noticable difference in performance than *native* binaries. For this reason, it is always best to build for your particuar system if possible. |
79 | | - |
80 | | -#### Linux |
81 | | - |
82 | | -##### Ubuntu, using GCC |
83 | | - |
84 | | -```bash |
85 | | -sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
86 | | -sudo apt-get update |
87 | | -sudo apt-get install aptitude -y |
88 | | -sudo aptitude install -y build-essential git cmake |
89 | | -git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
90 | | -cd wrkzcoin-crypto |
91 | | -mkdir build |
92 | | -cd build |
93 | | -cmake .. |
94 | | -make -j |
95 | | -``` |
96 | | - |
97 | | -The static library will be built as `libwrkzcoin-crypto.a` in the build folder. |
98 | | - |
99 | | -##### Ubuntu, using Clang |
100 | | - |
101 | | -```bash |
102 | | -sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
103 | | -wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
104 | | -``` |
105 | | - |
106 | | -You need to modify the below command for your version of ubuntu - see https://apt.llvm.org/ |
107 | | - |
108 | | -* Ubuntu 14.04 (Trusty) |
109 | | -- `sudo add-apt-repository "deb https://apt.llvm.org/trusty/ llvm-toolchain-trusty 6.0 main"` |
110 | | - |
111 | | -* Ubuntu 16.04 (Xenial) |
112 | | -- `sudo add-apt-repository "deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial 6.0 main"` |
113 | | - |
114 | | -* Ubuntu 18.04 (Bionic) |
115 | | -- `sudo add-apt-repository "deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic 6.0 main"` |
116 | | - |
117 | | -```bash |
118 | | -sudo apt-get update |
119 | | -sudo apt-get install aptitude -y |
120 | | -sudo aptitude install -y -o Aptitude::ProblemResolver::SolutionCost='100*canceled-actions,200*removals' |
121 | | -sudo aptitude install build-essential clang-6.0 libstdc++-7-dev git cmake |
122 | | -export CC=clang-6.0 |
123 | | -export CXX=clang++-6.0 |
124 | | -git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
125 | | -cd wrkzcoin-crypto |
126 | | -mkdir build |
127 | | -cd build |
128 | | -cmake .. |
129 | | -make -j |
130 | | -``` |
131 | | - |
132 | | -The following library files will be created in the `build` folder: |
133 | | - |
134 | | -* `libwrkzcoin-crypto-static.a` |
135 | | - |
136 | | -##### Generic Linux |
137 | | - |
138 | | -Ensure you have the dependencies listed above. |
139 | | - |
140 | | -If you want to use clang, ensure you set the environment variables `CC` and `CXX`. |
141 | | -See the ubuntu instructions for an example. |
142 | | - |
143 | | -```bash |
144 | | -git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
145 | | -cd wrkzcoin-crypto |
146 | | -mkdir build |
147 | | -cd build |
148 | | -cmake .. |
149 | | -make -j |
150 | | -``` |
151 | | - |
152 | | -The following library files will be created in the `build` folder: |
153 | | - |
154 | | -* `libwrkzcoin-crypto-static.a` |
155 | | - |
156 | | -#### OSX/Apple, using Clang |
157 | | - |
158 | | -##### Prerequisites |
159 | | - |
160 | | -- Install XCode and Developer Tools. |
161 | | - |
162 | | -##### Building |
163 | | - |
164 | | -```bash |
165 | | -which brew || /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
166 | | -brew install --force cmake boost llvm |
167 | | -export CC=/usr/local/opt/llvm/bin/clang |
168 | | -export CXX=/usr/local/opt/llvm/bin/clang++ |
169 | | -git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
170 | | -cd wrkzcoin-crypto |
171 | | -mkdir build |
172 | | -cd build |
173 | | -cmake .. |
174 | | -make |
175 | | -``` |
176 | | - |
177 | | -The following library files will be created in the `build` folder: |
178 | | - |
179 | | -* `libwrkzcoin-crypto-static.a` |
180 | | - |
181 | | -#### Windows |
182 | | - |
183 | | -##### Prerequisites |
184 | | - |
185 | | -- Install [Visual Studio 2017 Community Edition](https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15&page=inlineinstall) |
186 | | -- When installing Visual Studio, it is **required** that you install **Desktop development with C++** |
187 | | - |
188 | | -##### Building |
189 | | - |
190 | | -- From the start menu, open 'x64 Native Tools Command Prompt for vs2017'. |
191 | | -``` |
192 | | -cd <your_wrkzcoin-crypto_directory> |
193 | | -mkdir build |
194 | | -cd build |
195 | | -set PATH="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin";%PATH% |
196 | | -cmake -G "Visual Studio 15 2017 Win64" .. |
197 | | -``` |
198 | | - |
199 | | -**Note:** If you have errors on this step about not being able to find the some libraries, you may need to update your cmake. Open 'Visual Studio Installer' and click 'Update'. |
200 | | - |
201 | | -`MSBuild wrkzcoin-crypto.sln /p:Configuration=Release /m` |
202 | | - |
203 | | -The following library files will be created in the `build/Release` folder: |
204 | | - |
205 | | -* `wrkzcoin-crypto-static.lib` |
206 | | -* `wrkzcoin-crypto-shared.lib` |
207 | | -* `wrkzcoin-crypto-shared.dll` |
208 | | - |
209 | | -## Native Javascript & WASM |
210 | | - |
211 | | -### Prerequisites |
212 | | - |
213 | | -You will need the following packages: |
214 | | - |
215 | | -* CMake (2.8 or higher), make, and git. |
216 | | - |
217 | | -### Compiling |
218 | | - |
219 | | -```bash |
220 | | -git clone -b master --single-branch https://github.com/wrkzcoin/wrkzcoin-crypto |
221 | | -cd wrkzcoin-crypto |
222 | | -source ./build_js.sh |
223 | | -``` |
224 | | - |
225 | | -This script will install the necessary dependencies on your machine and then proceed to compile the library to Native Javascript and WASM. |
226 | | - |
227 | | -The following library files will be created in the `jsbuild` folder: |
228 | | - |
229 | | -* Native Javascript |
230 | | - * `wrkzcoin-crypto.js` |
231 | | -* WASM |
232 | | - * `wrkzcoin-crypto-wasm.js` |
233 | | - |
234 | | -## Thanks |
235 | | -Cryptonote Developers, Bytecoin Developers, Monero Developers, Forknote Project, TurtleCoin Community, WrkzCoin Community |
236 | | - |
237 | | -## Copypasta for license when editing files |
238 | | - |
239 | | -Hi WrkzCoin contributor, thanks for forking and sending back Pull Requests. Original credits remain with TurtleCoin and upstream projects. For now this is the bit we need to get into all the files we touch. Please add it to the top of the files. |
240 | | - |
241 | | -``` |
242 | | -// Copyright (c) 2012-2017, The CryptoNote developers, The Bytecoin developers |
243 | | -// Copyright (c) 2014-2018, The Monero Project |
244 | | -// Copyright (c) 2018-2019, The TurtleCoin Developers |
245 | | -// |
246 | | -// Please see the included LICENSE file for more information. |
247 | | -``` |
| 82 | +const crypto = new Crypto(); |
| 83 | +``` |
| 84 | + |
| 85 | +## Notes |
| 86 | + |
| 87 | +- Coin ticker: `WRKZ` |
| 88 | +- Decimal places: `2` |
| 89 | +- This repo is source-distributed; no npm package is required. |
| 90 | + |
| 91 | +## Credits |
| 92 | + |
| 93 | +Cryptonote Developers, Bytecoin Developers, Monero Developers, Forknote Project, TurtleCoin Community, WrkzCoin Community. |
0 commit comments