Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2007, 07:56
TmC TmC is offline
VIP
 
Join Date: Aug 2004
Posts: 330
Rept. Given: 1
Rept. Rcvd 15 Times in 9 Posts
Thanks Given: 2
Thanks Rcvd at 23 Times in 17 Posts
TmC Reputation: 15
Help with ECC (FGInt)

Hi,
I need some help with figuring out how to create a key-scheme with ECDSA and Delphi 7.

I am using the FGInt package and the ECDSA one, downloadable from the triade system homepage (http://www.submanifold.be/triade/GInt/bin/ECDSA.zip)

With the RSA version, no problem. I replaced n with d, so that only me is able to generate keys, while everyone can test them (with this package i can go up to 4096 with succesfull speed) and replaced the RSASign(test, d, n, Nilgint, Nilgint, Nilgint, Nilgint, signature) RSAVerify(test, signature, e, n, ok); with th actual values of d, n and e so that all the prime generation part is onl done by me once at time to get the keys.

I am new to ECDSA, so maybe i don't understand something. I am stuck with doing the same thing with ECDSA because there are some things i don't understand.

1) I suppose that similarly to RSA, i should exchange the secret key with the public one, so that only me is able to generate keys, BUT i don't understand where the private key is:
Also, if the private key is x i should put x in ECDSASign and the public key in ECDSAVerify, but the only differences between the two are x and y, but they cannot be exchanged since y is an ECPoint and x is FGInt so i am a bit stuck up in this.
I even asked myself if this scheme could be used to do what i am trying to do, but since armadillo uses ECDSA 113 it SHOULD BE possible.

2) Also for RSA i deleted the generation routine and replaced the values in RSAVerify with actual values, calling the Base10StringtoFGInt (or whatever its name is) and things actually worked.
In this ECDSA, i can't do that, since k should change at every generation and, MOST IMPORTANT THING, theparameters accepted by the ECDSAVerify are NOT all FGInts but there are also ECPoints, and there is no function to convert back and forth them to and from string, so i am unable to replace that values.
I could use the ECPointKMultiple(g, p, a, x, y) that generates y, but it requires also x making the entire scheme useless since the secret key would be revealed. That made me think that maybe x is not the private key but did not find in the implementation any information about it.

3) Also, what is the encrypted(signature) resulting from ECDSASign, r or s? if it is s, what is r? (o vice versa).

Can someone help me to clarify those issues?
Thanks in advance

Last edited by TmC; 07-25-2007 at 08:05.
Reply With Quote
  #2  
Old 07-25-2007, 20:09
tofu-sensei tofu-sensei is offline
Friend
 
Join Date: Jul 2004
Posts: 113
Rept. Given: 1
Rept. Rcvd 15 Times in 9 Posts
Thanks Given: 4
Thanks Rcvd at 24 Times in 13 Posts
tofu-sensei Reputation: 15
x is the private key (used for signing), y the public key (used to verify a signature), the actual signature is comprised of both r and s.
Reply With Quote
  #3  
Old 07-25-2007, 22:03
TmC TmC is offline
VIP
 
Join Date: Aug 2004
Posts: 330
Rept. Given: 1
Rept. Rcvd 15 Times in 9 Posts
Thanks Given: 2
Thanks Rcvd at 23 Times in 17 Posts
TmC Reputation: 15
Quote:
Originally Posted by tofu-sensei
x is the private key (used for signing), y the public key (used to verify a signature), the actual signature is comprised of both r and s.
And how do I pass the ECPoint parameters?

ECDSAVerify(T, r, s, p, a, n, g, y, ok);

T, r and s are string so no problem, T:= 'somestring';
p,a,n are FGInt so no problem, p := Base10ToFGInt('somestring');

but for g and y?
Reply With Quote
  #4  
Old 07-26-2007, 19:02
taos's Avatar
taos taos is offline
The Art Of Silence
 
Join Date: Aug 2004
Location: In front of my screen
Posts: 580
Rept. Given: 65
Rept. Rcvd 54 Times in 19 Posts
Thanks Given: 69
Thanks Rcvd at 137 Times in 36 Posts
taos Reputation: 54
Uhmm I'm not expert in Delphi (ASM is better) but g,y are TECPoint data types.
Tecpoint is a record
:TECPoint = Record
XCoordinate, YCoordinate : TFGInt;
Infinity : Boolean;
You can manipulate TECPOINT to convert to string ( ECPointToECPointString) or reverse (ECPointStringToECPoint). TEcpoints are this y^2 = x^3 + a*x + b and they are points on a elliptic curve.
Maybe this can help you:
ECPointKMultiple(g, p, a, x, y);

'Code:
Begin
// setting up parameters
writeln('setting up EC parameters ...');
Base256StringToFGInt('222222aatzzzznnn', p);
ok := true;
While ok Do
Begin
FindPrimeGoodCurveAndPoint(p, a, b, h, n, 60, g);
IsECSuperSingular(p, a, b, ok);
If ok Then
Begin
FGIntDestroy(a);
FGIntDestroy(b);
FGIntDestroy(h);
FGIntDestroy(n);
ECPointDestroy(g);
End;
End;
Base256StringToFGInt('ergezam', x);
ECPointKMultiple(g, p, a, x, y);
Base10StringToFGInt('63557', k);
Base2StringToFGInt('1', one);
FGIntGCD(k, n, temp);
While Not (FGIntCompareAbs(one, temp) = Eq) Do
Begin
FGIntDestroy(temp);
FGIntAddBis(k, one);
FGIntGCD(k, n, temp);
End;
FGIntDestroy(temp);
FGIntDestroy(one);

// with all these precautions everything is set up for signing/verifying

T := 'A black hole is a place where God divided by zero';
writeln('Signing the following string: ', T);
ECDSASign(T, p, a, x, n, k, g, r, s);
writeln('Verifying signature...');
ECDSAVerify(T, r, s, p, a, n, g, y, ok);
If ok Then writeln('Verification complete: signature is valid') Else writeln('Signature is not valid');

FGIntDestroy(p);
FGIntDestroy(a);
FGIntDestroy(n);
FGIntDestroy(k);
FGIntDestroy(h);
FGIntDestroy(x);
ECPointDestroy(g);
ECPointDestroy(y);
readln;
'End CODE
__________________
omnino lo qui quae que quod somos es pulvis en el ventus.
TAOS

-The opposite of courage in our society is not cowardice, but conformity-

Last edited by taos; 07-26-2007 at 19:08.
Reply With Quote
  #5  
Old 07-28-2007, 08:17
TmC TmC is offline
VIP
 
Join Date: Aug 2004
Posts: 330
Rept. Given: 1
Rept. Rcvd 15 Times in 9 Posts
Thanks Given: 2
Thanks Rcvd at 23 Times in 17 Posts
TmC Reputation: 15
Quote:
Originally Posted by taos
Uhmm I'm not expert in Delphi (ASM is better) but g,y are TECPoint data types.
Tecpoint is a record
:TECPoint = Record
XCoordinate, YCoordinate : TFGInt;
Infinity : Boolean;
You can manipulate TECPOINT to convert to string ( ECPointToECPointString) or reverse (ECPointStringToECPoint). TEcpoints are this y^2 = x^3 + a*x + b and they are points on a elliptic curve.
Maybe this can help you:
ECPointKMultiple(g, p, a, x, y);

'Code:
Begin
// setting up parameters
writeln('setting up EC parameters ...');
Base256StringToFGInt('222222aatzzzznnn', p);
ok := true;
While ok Do
Begin
FindPrimeGoodCurveAndPoint(p, a, b, h, n, 60, g);
IsECSuperSingular(p, a, b, ok);
If ok Then
Begin
FGIntDestroy(a);
FGIntDestroy(b);
FGIntDestroy(h);
FGIntDestroy(n);
ECPointDestroy(g);
End;
End;
Base256StringToFGInt('ergezam', x);
ECPointKMultiple(g, p, a, x, y);
Base10StringToFGInt('63557', k);
Base2StringToFGInt('1', one);
FGIntGCD(k, n, temp);
While Not (FGIntCompareAbs(one, temp) = Eq) Do
Begin
FGIntDestroy(temp);
FGIntAddBis(k, one);
FGIntGCD(k, n, temp);
End;
FGIntDestroy(temp);
FGIntDestroy(one);

// with all these precautions everything is set up for signing/verifying

T := 'A black hole is a place where God divided by zero';
writeln('Signing the following string: ', T);
ECDSASign(T, p, a, x, n, k, g, r, s);
writeln('Verifying signature...');
ECDSAVerify(T, r, s, p, a, n, g, y, ok);
If ok Then writeln('Verification complete: signature is valid') Else writeln('Signature is not valid');

FGIntDestroy(p);
FGIntDestroy(a);
FGIntDestroy(n);
FGIntDestroy(k);
FGIntDestroy(h);
FGIntDestroy(x);
ECPointDestroy(g);
ECPointDestroy(y);
readln;
'End CODE
Thanks taos, but the problem is just that one:

I should get y and g without involving x(the private key) or the entire scheme is useless since the private key is revealed and included in the program so everyone can create keys for it (etc etc)...

other helps?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for FGInt signature pack for IDA Pro Stingered General Discussion 12 08-30-2023 21:13


All times are GMT +8. The time now is 15:35.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )