You are not logged in.
Pages: 1
I am trying the private/public key functions but the first conversion isn't working with the testing 'private_key' I have:
var PrivateKey : TEccPrivateKey;
PublicKey : TEccPublicKey;
private_key,
public_key : RawUtf8;
begin
private_key := '18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725';
if mormot.core.text.HexToBin(PAnsiChar(private_key), @PrivateKey, SizeOf(PrivateKey)) then
begin
Ecc256r1PublicFromPrivate(PrivateKey, PublicKey);
public_key := mormot.core.text.BinToHexDisplay(@PublicKey, SizeOf(PublicKey)); // I'm not sure if this conversion is the proper one
// 'public_key' should be '50863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352'
end;
end;
Also, I'm unsure how to convert the 'PublicKey' variable to a readable one while in the testing phase. Any hint?
Last edited by Prometeus (2024-09-21 19:54:59)
Offline
Try to understand a little bit how it works, and look at the documentation.
If HexToBin fails, it means that your private key hexa is not of the right size.
So how did you create your private_key content?
You can try DerToEcc() overloaded function, or another means.
Online
Ab,
I always try to understand what I am doing. Believe me, I avoid asking in this forum because of the intimidating way you respond to some people here, without knowing precisely what each user may have done before asking, but for this case, it simply didn't work. I also tried to google some responses using mormot stuff, but I also found nothing. I didn't invent the private key. There is one page with some steps to find a final result, starting with a 256-bit private key given by them (the one used in my post, as well as the result public key from the original private key, also posted there). It is a 256-bit private key as it is supposed to be, the SAME SIZE of the one used in your 'test.core.ecc', line 89. I just need to calculate a 256-bit public key for a well-generated 256-bit private key, as is the case in my original question, and I am trying to use the mormot one because looks like it's fast.
Last edited by Prometeus (2024-09-21 19:32:53)
Offline
Ab,
I always try to understand what I am doing. Believe me, I avoid asking in this forum because of the intimidating way you respond to some people here, without knowing precisely what each user may have done before asking, but for this case, it simply didn't work. I also tried to google some responses using mormot stuff, but I also found nothing. I didn't invent the private key. There is one page with some steps to find a final result, starting with a 256-bit private key given by them (the one used in my post, as well as the result public key from the original private key, also posted there). It is a 256-bit private key as it is supposed to be, the SAME SIZE of the one used in your 'test.core.ecc', line 89. In fact, I just realized that the key you used in that example also doesn't pass the test above ('DC5B79BD481E536DD8075D06C18D42B25B557B4671017BA2A26102B69FD9B70A'). So, I am using the same functions used in your tests and it is not working. I just need to calculate a 256-bit public key for a well-generated 256-bit private key, as is the case in my original question, and I am trying to use the mormot one because looks like they are fast.
I would recommend making sure that the one you are using is ecc256r1 and not ec25519, Because mORMot2 only support the ecc256r1.
Mac, Windows, Linux
FPC Trunk, Lazarus Trunk, Delphi 12.x Latest
Offline
And this is an example I created a while ago when I was researching mORMot2.
Mac, Windows, Linux
FPC Trunk, Lazarus Trunk, Delphi 12.x Latest
Offline
=Coldzer0
I would recommend making sure that the one you are using is ecc256r1 and not ec25519, Because mORMot2 only support the ecc256r1.
I'll investigate if the provided private key is of type 'ecc256r1', and also thank you for the sample!
Last edited by Prometeus (2024-09-21 18:47:11)
Offline
My guess is that your private key comes from
https://bitcoin.stackexchange.com/quest … generation
And Bitcoin uses ecc256k1, not ecc256r1, AFAICT.
Online
My guess is that your private key comes from
https://bitcoin.stackexchange.com/quest … generationAnd Bitcoin uses ecc256k1, not ecc256r1, AFAICT.
Thanks for pointing out the right 'ecc' format for this case, and unfortunately mormot can't handle it.
Last edited by Prometeus (2024-09-22 02:35:18)
Offline
Pages: 1