floodyberry / scrypt-jane Goto Github PK
View Code? Open in Web Editor NEWA flexible implementation of Colin Percival's scrypt
A flexible implementation of Colin Percival's scrypt
Well, the title says it all.
Getting error during qt creator 5.0.2 build process in scrypt-jane-portable-x86.h lines 241-244
scrypt-jane/code/scrypt-jane-portable-x86.h:241: error: unknown token in expression
a2(mov [%1 + 0], eax)
^
also line 250
scrypt-jane/code/scrypt-jane-portable-x86.h:250: error: invalid instruction mnemonic 'prefix'
asm_gcc_parms() : "+a"(flags) : "S"(regs) : "%ecx", "%edx", "cc"
^
R_X86_64_32S .rodata
include in library requires -fPIC
Had to change malloc.h include to stdlib.h in scrypt-jane.c for it to stop nagging about not being able to locate malloc.h, but now getting compile errors. Something to do with with sse, sse2, ssse3 or avx in scrypt-jane-portable-x86.h
$ gcc scrypt-jane.c scrypt-jane.c -O3 -m64 -DSCRYPT_SALSA64 -DSCRYPT_BLAKE512
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:5:Alignment too large: 15. assumed.
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:178:suffix or operands invalid for ja' /var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:202:suffix or operands invalid for
jne'
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:207:Unknown pseudo-op: .type
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:207:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:208:Unknown pseudo-op: .size
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:208:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:212:Alignment too large: 15. assumed.
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:397:suffix or operands invalid for ja' /var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:421:suffix or operands invalid for
jne'
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:426:Unknown pseudo-op: .type
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:426:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:427:Unknown pseudo-op: .size
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:427:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:5:Alignment too large: 15. assumed.
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:178:suffix or operands invalid for ja' /var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:202:suffix or operands invalid for
jne'
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:207:Unknown pseudo-op: .type
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:207:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:208:Unknown pseudo-op: .size
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:208:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:212:Alignment too large: 15. assumed.
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:397:suffix or operands invalid for ja' /var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:421:suffix or operands invalid for
jne'
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:426:Unknown pseudo-op: .type
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:426:Rest of line ignored. 1st junk character valued 115 (s).
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:427:Unknown pseudo-op: .size
/var/folders/z2/d2tynst114n6bc3cfh672n_40000gn/T//ccMD3jw5.s:427:Rest of line ignored. 1st junk character valued 115 (s).
r and p are not required to be powers of 2 in the scrypt specification and reference implementation.
What's up with defining Nfactor as ld(N)-1 instead of ld(N)? With Nfactor unsigned, this makes it impossible to calculate scrypt at N==1 / ld(N)==0.
I am using Mingw with gcc version 4.7 but there are some lines that choke to the compiler :
$ gcc -O3 -DSCRYPT_KECCAK512 -DSCRYPT_SALSA -DSCRYPT_CHOOSE_COMPILETIME scrypt- jane.c C:\Users\user\AppData\Local\Temp\ccg4co7k.s: Assembler messages: C:\Users\user\AppData\Local\Temp\ccg4co7k.s:23: Warning: .type pseudo-op used outside of .def/.endef ignored. C:\Users\user\AppData\Local\Temp\ccg4co7k.s:23: Error: junk at end of line, firs t unrecognized character is `h' C:\Users\user\AppData\Local\Temp\ccg4co7k.s:24: Warning: .size pseudo-op used outside of .def/.endef ignored. C:\Users\user\AppData\Local\Temp\ccg4co7k.s:24: Error: junk at end of line, firs t unrecognized character is `h'
In scrypt-jane-portable-x86.h, the line
if ((regs.ecx & (1 << 28)) && (xgetbv_flags & 0x6)) cpu_flags |= cpu_avx;
should instead be
if ((regs.ecx & (1 << 28)) && ((xgetbv_flags & 0x6) == 0x6)) cpu_flags |= cpu_avx;
because both bits (0x04 for YMM registers, and 0x02 for XMM registers) must be set to indicate OS support for AVX. Without this, systems that have AVX disabled by the OS (for example, Windows 7 RTM) will select the AVX implementation and crash on first run.
(Also, thanks for providing your simple-to-integrate implementations of various crypto primitives, they have proven to be immensely useful time and time again.)
When linking example, I get "Undefined symbol detect_cpu in file scrypt-jane.o" error with gcc 4.5.2 on new sparc64 with Solaris 11. This is how I compile:
gcc scrypt-jane.c -O3 -DSCRYPT_CHACHA -DSCRYPT_KECCAK512 -DSCRYPT_CHOOSE_COMPILETIME -mcpu=v9 -m64
gcc example.c scrypt-jane.o -mcpu=v9 -m64 -o example
If I insert a dummy detect_cpu function that returns 0 in scrypt-jane-portable.h, the code compiles without error, but I get "scrypt: mix function power-on-self-test failed" at program execution.
I am not sure if this library is supposed to work on sparc64 platform.
Are there any compiler flags I am missing?
when trying to compile https://github.com/cscott/bip38-cracker I got many errors from scrypt-jane:
$ make
gcc -DPACKAGE_NAME=\"cracker\" -DPACKAGE_TARNAME=\"cracker\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"cracker\ 0.1\" -DPACKAGE_BUGREPORT=\"paybitcoin\" -DPACKAGE_URL=\"\" -DPACKAGE=\"cracker\" -DVERSION=\"0.1\" -I. -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -Ipicocoin/include -Iscrypt-jane -O3 -m32 -DSCRYPT_SALSA -DSCRYPT_SHA256 -g -O2 -MT cracker-scrypt-jane.o -MD -MP -MF .deps/cracker-scrypt-jane.Tpo -c -o cracker-scrypt-jane.o `test -f 'scrypt-jane/scrypt-jane.c' || echo './'`scrypt-jane/scrypt-jane.c
In file included from scrypt-jane/scrypt-jane.c:10:
scrypt-jane/code/scrypt-jane-portable.h:139:10: warning: 'ALIGN' macro redefined
#define ALIGN(n) __attribute__((aligned(n)))
^
/usr/include/i386/param.h:83:9: note: previous definition is here
#define ALIGN(p) __DARWIN_ALIGN(p)
^
<inline asm>:20:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix;
^
<inline asm>:45:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix
^
<inline asm>:61:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix
^
<inline asm>:138:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix
^
<inline asm>:157:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix
^
<inline asm>:166:13: error: invalid instruction mnemonic 'prefix'
.att_syntax prefix;
^
In file included from scrypt-jane/scrypt-jane.c:10:
In file included from scrypt-jane/code/scrypt-jane-portable.h:303:
scrypt-jane/code/scrypt-jane-portable-x86.h:313:3: error: unknown token in
expression
a2(mov [%1 + 0], eax)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:185:19: note: expanded from macro
'a2'
#define a2(x, y) GNU_AS2(x, y)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:178:24: note: expanded from macro
'GNU_AS2'
#define GNU_AS2(x, y) #x ", " #y ";\n"
^
<scratch space>:202:2: note: expanded from here
"mov [%1 + 0]"
^
<inline asm>:5:6: note: instantiated into assembly here
mov [%esi + 0], eax;
^
In file included from scrypt-jane/scrypt-jane.c:10:
In file included from scrypt-jane/code/scrypt-jane-portable.h:303:
scrypt-jane/code/scrypt-jane-portable-x86.h:314:3: error: unknown token in
expression
a2(mov [%1 + 4], ebx)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:185:19: note: expanded from macro
'a2'
#define a2(x, y) GNU_AS2(x, y)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:178:24: note: expanded from macro
'GNU_AS2'
#define GNU_AS2(x, y) #x ", " #y ";\n"
^
<scratch space>:204:2: note: expanded from here
"mov [%1 + 4]"
^
<inline asm>:6:6: note: instantiated into assembly here
mov [%esi + 4], ebx;
^
In file included from scrypt-jane/scrypt-jane.c:10:
In file included from scrypt-jane/code/scrypt-jane-portable.h:303:
scrypt-jane/code/scrypt-jane-portable-x86.h:315:3: error: unknown token in
expression
a2(mov [%1 + 8], ecx)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:185:19: note: expanded from macro
'a2'
#define a2(x, y) GNU_AS2(x, y)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:178:24: note: expanded from macro
'GNU_AS2'
#define GNU_AS2(x, y) #x ", " #y ";\n"
^
<scratch space>:206:2: note: expanded from here
"mov [%1 + 8]"
^
<inline asm>:7:6: note: instantiated into assembly here
mov [%esi + 8], ecx;
^
In file included from scrypt-jane/scrypt-jane.c:10:
In file included from scrypt-jane/code/scrypt-jane-portable.h:303:
scrypt-jane/code/scrypt-jane-portable-x86.h:316:3: error: unknown token in
expression
a2(mov [%1 + 12], edx)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:185:19: note: expanded from macro
'a2'
#define a2(x, y) GNU_AS2(x, y)
^
scrypt-jane/code/scrypt-jane-portable-x86.h:178:24: note: expanded from macro
'GNU_AS2'
#define GNU_AS2(x, y) #x ", " #y ";\n"
^
<scratch space>:208:2: note: expanded from here
"mov [%1 + 12]"
^
<inline asm>:8:6: note: instantiated into assembly here
mov [%esi + 12], edx;
^
In file included from scrypt-jane/scrypt-jane.c:10:
In file included from scrypt-jane/code/scrypt-jane-portable.h:303:
scrypt-jane/code/scrypt-jane-portable-x86.h:318:3: error: invalid instruction
mnemonic 'prefix'
asm_gcc_parms() : "+a"(flags) : "S"(regs) : "%ecx", "%e...
^
scrypt-jane/code/scrypt-jane-portable-x86.h:242:27: note: expanded from macro
'asm_gcc_parms'
#define asm_gcc_parms() ".att_syntax prefix;"
^
<inline asm>:10:13: note: instantiated into assembly here
.att_syntax prefix;
^~~~~~~
1 warning and 11 errors generated.
When I try to compile with LTO enabled, the linker suddenly suddenly can't see the assembler function bodies (LTO pass probably removes them too early).
I tried to set __attribute__((used))
on them but I failed, maybe you will find a faster way to do it.
Without LTO it compiles fine:
bujak_e@wraith:~/temp/scrypt-jane$ gcc scrypt-jane-speed.c -O3 -DSCRYPT_SHA256 -DSCRYPT_SALSA $3 -o scrypt_speed
With LTO it gives out link errors:
bujak_e@wraith:~/temp/scrypt-jane$ gcc scrypt-jane-speed.c -O3 -flto -DSCRYPT_SHA256 -DSCRYPT_SALSA $3 -o scrypt_speed
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_sse2.lto_priv.12':
ccK78ets.ltrans2.o:(.text+0x117): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x149): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x1b1): undefined reference to `scrypt_ChunkMix_sse2'
ccK78ets.ltrans2.o:(.text+0x1d3): undefined reference to `scrypt_ChunkMix_sse2'
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_avx.lto_priv.11':
ccK78ets.ltrans2.o:(.text+0x367): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x399): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x401): undefined reference to `scrypt_ChunkMix_avx'
ccK78ets.ltrans2.o:(.text+0x423): undefined reference to `scrypt_ChunkMix_avx'
/tmp/ccK78ets.ltrans2.ltrans.o: In function `scrypt_ROMix_xop.lto_priv.10':
ccK78ets.ltrans2.o:(.text+0x5b7): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x5e9): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x651): undefined reference to `scrypt_ChunkMix_xop'
ccK78ets.ltrans2.o:(.text+0x673): undefined reference to `scrypt_ChunkMix_xop'
collect2: error: ld returned 1 exit status
GCC version:
bujak_e@wraith:~/temp/scrypt-jane$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
scrypt-jane seems to generate a keystream different to the one generated by the reference implementation. Example:
N=1024, r=1, p=1,
salt (hex) = "0AF023E55F804AD303C1DBDF6A2B2BED8CC1AB3D0B2F3312C073628DC041E6F3",
pw (ascii) = "mypassword"
Compiler parameters for scrypt-jane: -DSCRYPT_SALSA -DSCRYPT_SHA256
Stream (hex) generated by scrypt reference implementation:
76596404E35C5745E7842435F299524D6DB0743BECD68AEFB0E5811465015F75F337B0AAE51EFF89359BC41FCFBB9CF0E935C5C2D649854827E170AC6F9AA86A3B08959425969536EB8D15A438B79E85E4FB77CBDD8BBFB3
Stream (hex) generated by scrypt-jane:
15F92C2AC917F5FD864D6BC0D0FE15EDDFCAFE5908A0F2A0D078D4842F525AE52335FD1EE74FC6A4A1D6E44A3873630BE29FCAA81F3F613CE83D30899E69CA57E87157102CB526FEE834F81A3BCE487AF1DEA6CEB37008D3
Including this library into the miner for YaCoin so it compiles under MinGW, it compiles just fine under x86. Setting -DCPU_X86_FORCE_INTRINSICS causes the following error:
In file included from scrypt-jane/code/scrypt-jane-chacha.h:14:0,
from scrypt-jane/code/scrypt-jane-romix.h:2,
from scrypt-jane/scrypt-jane.c:12:
scrypt-jane/code/scrypt-jane-mix_chacha-avx.h:265:1: error: static declaration of 'scrypt_ChunkMix_avx' follows non-static declaration
scrypt-jane/code/scrypt-jane-mix_chacha-avx.h:149:1: note: previous declaration of 'scrypt_ChunkMix_avx' was here
also, looking at the code, this may be important, but I'm forcing AVX with the -march directive
In "Using" section, the p and r parameters are in the wrong order.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.