bcoin-org / bcrypto

JS crypto library
Other
99 stars 41 forks source link

bcrypto 5.0.0 fails to install on Windows #40

Closed alexsmith540 closed 4 years ago

alexsmith540 commented 4 years ago

Latest 5.0.0 build fails to compile on windows during npm install and blocks hsd from installing. Seems to be related to libtorsion.

`

node-gyp rebuild

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. aead.c chacha20.c drbg.c dsa.c ecc.c c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p192_32.h(14): error C4235: nonstandard extension used: 'int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p192_32.h(15): error C4235: nonstandard extension used: '__int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p521_32.h(14): error C4235: nonstandard extension used: 'int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p521_32.h(15): error C4235: nonstandard extension used: 'int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p448_32.h(14): error C4235: nonstandard extension used: '__int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] c:\users\someuser\hsd\node_modules\bcrypto\src\torsion\src\fields\p448_32.h(15): error C4235: nonstandard extension used: 'int128' keyword not supported on this architecture [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] ..\src\torsion\src\ecc.c(9640): warning C4098: 'torsion_schnorr_scratch_destroy': 'void' function returning a value [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] ..\src\torsion\src\ecc.c(9682): warning C4098: 'torsion_schnorr_privkey_generate': 'void' function returning a value [C:\Users\someuser\hsd\node_modules\bcrypto\build\bcrypto.vcxproj] gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:197:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12) gyp ERR! System Windows_NT 10.0.18362 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\someuser\hsd\node_modules\bcrypto gyp ERR! node -v v11.10.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bcrypto@5.0.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bcrypto@5.0.0 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. `

chjj commented 4 years ago

Very strange. The 64 bit field element backends should not be built on windows: https://github.com/bcoin-org/bcrypto/blob/master/binding.gyp#L86

I wonder if the node-gyp OS variable is being set to something other than win?

chjj commented 4 years ago

Oh, it's not building the 64 bit backends. Strange that the 32 bit fiat backends require __int128. Hmm.

chjj commented 4 years ago

Okay, it seems like only unsaturated solinas primes require an __int128 type for 32 bit. I think we could maybe compile those backends using montgomery reduction instead to make them work on windows.

chjj commented 4 years ago

Strangely enough, p25519 32 bit doesn't require __int128. Investigating more.

chjj commented 4 years ago

It seems as though the shape of the prime and the number of limbs determines whether int128 is used for 32 bit. I've tweaked the fiat build script and increased the number of limbs for those backends to avoid using int128.