DelphiEncryptionCompendium icon indicating copy to clipboard operation
DelphiEncryptionCompendium copied to clipboard

CPU/GPU Accelerating Hashing & Encryption

Open c-michail opened this issue 4 years ago • 14 comments

Describe the solution you'd like CPU/GPU Accelerating Hashing & Encryption

Additional context On CPU using SSE/AVX Extensions and GPU using OpenCL/CUDA

c-michail avatar Jan 24 '21 21:01 c-michail

I can understand the desire to have this implemented. There are a few issues though which might lead to postphoning this a bit.

  1. I see speed as an important goal, but the library lacks some modern algorithms in some areas which should at least be added in a basic version first (e.g. implementing SHA3 most likely will still take some time as this is a bit tricky)
  2. While I took over this library and saved it from starvation I'm still no expert in cryptography (I learned quite some things already but am still no expert)
  3. I don't know ASM very well and AVX is most likely not natively supported by Delphi's compiler
  4. If implementing this it should most likely be based on the mormot works (if possible from the license) as they have at least an AVX version of the AES algorithm implemented. And I need an AVX capable CPU. I guess my i5 desktop CPU is too old for this and I'm not sure my newer i5 Laptop CPU supports this.
  5. Things tend to get quicker when I get help on implementing those.
  6. I don't know much about OpenCL/CUDA. One would need to find out first how that can be used from a Delphi app and what it brings means how to use it in a cryptographic algorithm.

=> I really would see value in such an implementation but I fear I cannot do that without help from somebody/people having knowledge in these areas.

MHumm avatar Jan 25 '21 21:01 MHumm

Oh, looking at your repository on GitHub just revealed, that you might be a good candidate for help ;-) You seem to have knowledge. Just some notes:

  1. If done I don't want to depend on any other external libraries besides Delphi and FPC RTL/VCL/FMX
  2. It (AVX) needs to be implemented in such a way that it can be turned off or is only used when ASM define in DECOptions.inc is used and a compatible CPU is present, so it doesn't interfere with the cross platform compatibility goals of DEC.
  3. Oh, and any contributions need to be compatible with the APL 2.0 license used for DEC...

MHumm avatar Jan 25 '21 21:01 MHumm

Hello, Yes i know it's not easy but if you look at the eg. crypto miners they use GPU for hasing but unfortunately they are coded c++. As far the UltraCode is something i want to start working as soons as i finish some stuff that i'm doing. (I do not have a time frame) I guess as soon this project start to kick off a lot of developers (i hope) will contribute so you can borrow knowledge from there.

Thank you

c-michail avatar Jan 26 '21 09:01 c-michail

If you leave GPL 3 as only license for your project I cannot borrow code from there as I don't want to make my library "viral". I've choosen APL 2.0 as license.

MHumm avatar Jan 26 '21 13:01 MHumm

Any news about that one?

MHumm avatar Dec 29 '21 08:12 MHumm

Any news about that one?

Hello, Nope still busy with my projects. I hope to find some time in 2022 to make the benchmarks in order to kickstart the project! :)

c-michail avatar Jan 02 '22 11:01 c-michail

Two good news for you about this one:

  1. in system.pas there is some CPUID code which might be used to detect whether AVX is available
  2. since Delphi 11.0 AVX/AVX2 ASM opcodes have been added to the built in ASM so you can write such ASM code. But when you start be please aware that DEC's minimum supported Delphi version is 10.1 starting with the V6.5 which is currently in development.

MHumm avatar Feb 25 '22 19:02 MHumm

Since Delphi 11 has only AVX support I think we'll use NASM assembler.

c-michail avatar Feb 28 '22 21:02 c-michail

Why not? So just start with it, I'm not holding you up ;-)

MHumm avatar Mar 04 '22 17:03 MHumm

Any progress on this?

MHumm avatar Dec 22 '22 19:12 MHumm

Any progress on your side? Shall I create a branch for you for this?

MHumm avatar Jan 28 '23 10:01 MHumm

Any progress on this on your side?

MHumm avatar Dec 17 '23 16:12 MHumm

Hello, Well i was pretty busy but I am planning to start around next month so i hope to have something ready in the next couple months.

c-michail avatar Dec 17 '23 20:12 c-michail

Ok, next month is over. I'd politely like to ask about whether any work has already begun? If you like you can have a branch for this.

MHumm avatar Feb 09 '24 07:02 MHumm