Giter Club home page Giter Club logo

Comments (6)

Xor-el avatar Xor-el commented on June 16, 2024

First of all, I must apologize for replying late as I am just seeing this issue now.
GitHub unfortunately didn't notify me that an issue was created.

I have done something similar to what you want but for Blake2B.

Links can be found below

KeyPair Generator

Other relevant links

https://github.com/Xor-el/CryptoLib4Pascal/blob/master/CryptoLib/src/Math/EC/Rfc8032/ClpEd25519Blake2B.pas

https://github.com/Xor-el/CryptoLib4Pascal/blob/master/CryptoLib/src/Crypto/Signers/ClpEd25519Blake2BSigner.pas

using the above links as guidelines, you can create your own variant which uses SHA3-512.

do feel free to reach out if you encounter any other issues along the way.
Regards.

from cryptolib4pascal.

GamSui avatar GamSui commented on June 16, 2024

from cryptolib4pascal.

Xor-el avatar Xor-el commented on June 16, 2024

Hello, strangely again, GitHub didn't notify me of your update.
Got to see it by chance.
To answer your question, Nem used SHA3-512 before it was standardized as SHA-3 by NIST which essentially means that Nem uses KECCAK-512.

So the hash you need is

result := TDigestUtilities.GetDigest('KECCAK-512');

from cryptolib4pascal.

GamSui avatar GamSui commented on June 16, 2024

Hello again. No worries! And thanks a lot for checking from time to time.

I forgot to mention that I also tested with KECCAK-512. But unfortunately this didn't work out either :-(

Private Key: 4ba47b6ace2abe73ef593c3cf32a999fb57349a6038bc334d3b50edff8bd33f6
Expected Public Key: 576192500b07f5c78482d05cb17bfcde61fcd819e447447ada0f7ad149928bf2
Generated Public Key: 473c6df8dbbbde579b700323cd4f3d0df868573868bf1d9a53c30a2056d0ff5a

Hhmmm... I was pretty sure that with NEM the only difference to the standard Ed25519 implementation is the hash function. But maybe there is more...

Again, thank you very much for your support so far.

Best regards

Guido

from cryptolib4pascal.

Xor-el avatar Xor-el commented on June 16, 2024

Hello again. No worries! And thanks a lot for checking from time to time.

I forgot to mention that I also tested with KECCAK-512. But unfortunately this didn't work out either :-(

Private Key: 4ba47b6ace2abe73ef593c3cf32a999fb57349a6038bc334d3b50edff8bd33f6
Expected Public Key: 576192500b07f5c78482d05cb17bfcde61fcd819e447447ada0f7ad149928bf2
Generated Public Key: 473c6df8dbbbde579b700323cd4f3d0df868573868bf1d9a53c30a2056d0ff5a

Hhmmm... I was pretty sure that with NEM the only difference to the standard Ed25519 implementation is the hash function. But maybe there is more...

Again, thank you very much for your support so far.

Best regards

Guido

Hi, so I did some research about Nem and discovered that the private key is first reversed (as a byte array) before passed to the ED25519 method.
The code below gives me 576192500b07f5c78482d05cb17bfcde61fcd819e447447ada0f7ad149928bf2 as my public key.

var
  sk, skreversed: TBytes;
  privateKey: IEd25519Blake2BPrivateKeyParameters;
  publicKey: IEd25519Blake2BPublicKeyParameters;
  pk: string;
  i: Int32;
begin
  sk := DecodeHex
    (('4ba47b6ace2abe73ef593c3cf32a999fb57349a6038bc334d3b50edff8bd33f6'));
  System.SetLength(skreversed, length(sk));
  for i := Low(sk) to High(sk) do
  begin
    skreversed[High(sk) - i] := sk[i];
  end;

  privateKey := TEd25519Blake2BPrivateKeyParameters.Create(skreversed, 0);
  publicKey := privateKey.GeneratePublicKey;
  pk := EncodeHex(publicKey.GetEncoded);
end;

** Note, I used Keccak-512 as the digest.

from cryptolib4pascal.

GamSui avatar GamSui commented on June 16, 2024

Hello again

Wow! Thanks a lot! Works like a charm!

Donation is on the way...

Best regards

Guido

from cryptolib4pascal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.