Pointers are so cruel…

They’re bad! And mean!

After weeks of debugging, and still cannot get the plaintext back, now I’m moving to the next: building ECC on composite fields.

Note: below is the result of the codes with printf-s everywhere. With the help of this debugger.

The algorithm seems correct but the data recovered looks weird.


poly_prime =
8 0 0 0 0 c9
setting up curves

the curve after setting up:
form: 1
a2: 0 0 0 0 0 2
a6: 0 0 0 0 0 1

counter = 0
inc = 5
Base point
x: 5 63323eab 10fc68f8 254d4d11 d2d518f2 9979dd24
y: 4 883e6269 de8bf93e f6c224e3 330dbf7f 2dd25ec1

create side 2's private key

Side 2 secret:
5 5d0be8bb a913fcdb 91edee60 4da6d486 295d85ac

Generate side 2's public key

Side 2 public key
x: 1d5ba6c2 5378466 ae5d1cce 48770132 e9d6d710 a7448cd1
y: 4 85500816 ccee8906 56a133dc 19c325f8 4bb9ffa6
data =
68616c6c 6f0a0000 0 0 0 60000000

Hide data on curve and send from side 1 to side 2

curve before send_elgamal:
form: 1
a2: 0 0 0 0 0 2
a6: 0 0 0 0 0 1

Their_public before send_elgamal:
x: 1d5ba6c2 5378466 ae5d1cce 48770132 e9d6d710 a7448cd1
y: 4 85500816 ccee8906 56a133dc 19c325f8 4bb9ffa6
=====IN send_elgamal=====
data (in send_gamal function) :
68616c6c 6f0a0000 0 0 0 60000000
Base point
x: 5 63323eab 10fc68f8 254d4d11 d2d518f2 9979dd24
y: 4 883e6269 de8bf93e f6c224e3 330dbf7f 2dd25ec1
Base curve
form: 1
a2: 0 0 0 0 0 2
a6: 0 0 0 0 0 1

random value:
5 3a0f94f6 e0caf9a7 2d189f04 8591c5e5 3935d4dc
Random point C1
x: 2 d6670f0 ab08aca3 8818adbe cf36881d 83accc06
y: 2 cad560f5 72c889b5 226934a2 733455c8 c53a15a6
counter = 0
inc = 0
counter = 0
-- pnt->x =
x: bffff4b8 a00754ec bffff4d8 a0073a58 a a
y: 68616c6d 6f0a0000 0 0 0 60000000
raw point M (after poly_embed)
x: 68616c6d 6f0a0000 0 0 0 60000000
y: 1 2c310f6b e4c3751c 2ef637ef ce837cb2 88e21c99
Their_public:
x: 1d5ba6c2 5378466 ae5d1cce 48770132 e9d6d710 a7448cd1
y: 4 85500816 ccee8906 56a133dc 19c325f8 4bb9ffa6
hidden point (after poly_elptic_mul)
x: 6 987b3fe3 f486168f 19bba08c b943f599 c43cfa22
y: 1 6a16b493 afad94b4 f93c6f41 40281e42 8c448f24
Hidden data (C2):
x: 68616c6c d3ba4b92 8c4b46c0 a6c78778 afcaf788 5187c979
y: 68616c69 372ef71c 96586e6d bad28a2 ff127133 b48ca3de
Random point (C1):
x: 2 d6670f0 ab08aca3 8818adbe cf36881d 83accc06
y: 2 cad560f5 72c889b5 226934a2 733455c8 c53a15a6
=====OUT send_elgamal

AFTER send_elgamal
curve after send_elgamal:
form: 1
a2: 0 0 0 0 0 2
a6: 0 0 0 0 0 1

Hidden data (C2)
x: 68616c6c d3ba4b92 8c4b46c0 a6c78778 afcaf788 5187c979
y: 68616c69 372ef71c 96586e6d bad28a2 ff127133 b48ca3de
Random point (C1)
x: 2 d6670f0 ab08aca3 8818adbe cf36881d 83accc06
y: 2 cad560f5 72c889b5 226934a2 733455c8 c53a15a6

Recover transmitted message

IN receive_elgamal
Base curve in receive_elgamal
form: 1
a2: 0 0 0 0 0 2
a6: 0 0 0 0 0 1

Hidden_data (in receive_elgamal) :
x: 68616c6c d3ba4b92 8c4b46c0 a6c78778 afcaf788 5187c979
y: 68616c69 372ef71c 96586e6d bad28a2 ff127133 b48ca3de
Random point
x: 2 d6670f0 ab08aca3 8818adbe cf36881d 83accc06
y: 2 cad560f5 72c889b5 226934a2 733455c8 c53a15a6
hidden_point (d*C1):
x: 7 1f5fceb7 8269106c c1708600 cde8821b 38e0c7ee
y: 2 d752fec4 40840001 be4a3e7f 347e7013 7f36ce97
&raw_point:
x: 68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389
y: 3 fae10821 85e832bb b9c6d8ab cc4439f4 eb7441ea
raw_point.x
68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389
&raw_data (point):
x: bffff670 10700ccf af82abf6 b46a9779 16316b62 7df7f7d
y: 4037177 debca93c 4b16e65 77a8ff5a 70c28f88 1d5ba6c1
raw_data (point):
x: 68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389
y: 68616c6c 6f0a0000 0 0 0 60000000
&raw_data (field):
bffff670 10700ccf af82abf6 b46a9779 16316b62 7df7f7d
raw_data (field):
68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389
=====OUT receive elgamal

sent data
68616c6c 6f0a0000 0 0 0 60000000
received data (point)
x: 68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389
y: 68616c6c 6f0a0000 0 0 0 60000000
received data (field)
68616c6a de301be6 24719966 c269b54f ef049a08 8c7af389

Advertisements