<div dir="ltr"><div><div><div><div><div><div>Hi,<br><br></div>I'm trying to replace the deprecated crypto functions dh_generate_key/1 and dh_compute_key/3 with the new functions generate_key/2 and compute_key/3 but my app fails.<br>
<br></div><div>The byte_size of the results are different between the old and new API:<br></div><div>Old: <br>PublicKey - 132 Bytes<br>PrivateKey - 132 Bytes<br></div><div>Shared - 128 Bytes<br><br></div><div>New<br>PublicKey - 129 Bytes<br>
PrivateKey - 129 Bytes<br>Shared - 129 Bytes<br><br></div></div></div>Shouldn't the functionality and the size of the keys be the same?<br></div>Do I need to change something to make it work?<br><br></div>Code:<br><div>
<div><div><div><div><br><div><div>Old functions:<br>{PublicKey, PrivateKey} = crypto:dh_generate_key([?DH_P, ?DH_G]),<br>Shared = crypto:dh_compute_key(ClientKey, PrivateKey, [?DH_P, ?DH_G]),<br><<_:32, PublicKey2/binary>> = PublicKey. % Needed for my app with the old API<br>
<br>New functions:<br>{PublicKey, PrivateKey} = crypto:generate_key(dh, [?DH_P, ?DH_G]),<br>Shared = crypto:compute_key(dh, ClientKey, PrivateKey, [?DH_P, ?DH_G]),<br><<_:32, PublicKey2/binary>> = PublicKey.<br>
<br></div><div>% ?DH_P size is 132 Bytes<br></div><div>% ?DH_G size is 5 Bytes<br></div><div><br></div><div>Thanks<br></div></div></div></div></div></div></div></div>