IoTone / TheShellProject

The Shell Project aims to build a viable general purpose blockchain written in Dlang, with attributes of security, ease of deployment, clear specification, ease of use for DAPPs, and multiple implementation interop
1 stars 1 forks source link

We need a Sha-3 implementation #56

Closed truedat101 closed 5 years ago

truedat101 commented 5 years ago

Add one. There's ones available but not in libsodium. Could use some alternatives, however, just want to get something that's close to what we need.

References:

https://github.com/truedat101/dlang-sv-community/issues/50

truedat101 commented 5 years ago

Instead of building from scratch as I started to do in the sha3-d subdir, I will wrap a C library. This one I started on was based off of sha3-js. It's extremely slick for JS. Interpreting a lot of the tricks they used to generation a functional (programming) style to generate the library was going to take me too long. I prefer something that just exposes the few interfaces I need. I found: https://github.com/coruus/keccak-tiny

This seems to be (1) good license some sort of CC0 thing (2) works (3) compiles easily (4) small. Make a new library around that.

truedat101 commented 5 years ago

So I think I'll move sha3-d off to the boneyard.

truedat101 commented 5 years ago

So in reading a bit more on this, it appears there were some spec changes to keccak and sha3. So the library I started with was .1 base. And we need to get this up to .2 base to have the current keccek implementation.

https://ethereum.stackexchange.com/questions/30369/difference-between-keccak256-and-sha3/30373

https://github.com/emn178/js-sha3#notice

😿

truedat101 commented 5 years ago

So good news, there is a fork and I'll take that in to get the updates I need.

truedat101 commented 5 years ago

Ok, so here is the plan. Pull in the fork. Add in the new test cases.

truedat101 commented 5 years ago

I've forked the upstream libkeccak-tiny for IoTone to add in some pull requests.

truedat101 commented 5 years ago

And here's the latest goodness:

dkords@yangon:libkeccak-d(proto5-dev*)$ nm libkeccak-tiny.dylib
0000000000011ef0 s _RC
0000000000000880 T ___sputc
                 U ___stack_chk_fail
                 U ___stack_chk_guard
                 U ___swbuf
000000000000afc0 T _keccak_224
000000000000cc10 T _keccak_256
000000000000e800 T _keccak_384
0000000000010370 T _keccak_512
00000000000040c0 T _sha3_224
0000000000005d10 T _sha3_256
0000000000007900 T _sha3_384
0000000000009470 T _sha3_512
00000000000008c0 T _shake128
00000000000024e0 T _shake256
                 U dyld_stub_binder
truedat101 commented 5 years ago

The are the new guys:

000000000000afc0 T _keccak_224 000000000000cc10 T _keccak_256 000000000000e800 T _keccak_384 0000000000010370 T _keccak_512

truedat101 commented 5 years ago

Ok, integration looks good. I'll wrap up test cases tomorrow and call it done.

truedat101 commented 5 years ago

Hmmm, I need to ensure this builds on windows. The simple do.sh file doesn't properly address the question of what kind of library to produce and assumes it's either a mac or linux. So it produces a .dylib or a .so.

Second problem is that what it produces is odd: libkeccak-tiny.lib: PE32+ executable (DLL) (console) x86-64, for MS Windows

Third problem is it is named wrong. Windows is looking for keccak-tiny.lib, not libkeccak-tiny.lib. Deal with this later.

Also read: http://www.mingw.org/wiki/sampleDLL

https://forums.ni.com/t5/LabVIEW/create-a-dll-for-windows-with-gcc/td-p/332736

pedroalvesbatista commented 5 years ago

I'll read up all these refs to get a little understanding of how Windows deals with this libraries stuffs.

truedat101 commented 5 years ago

I'll leave this in proto5. I'd say this is done. I'll close it out tonight. I will deal with the windows issues in a new issue.