I am reverse engineering an application. What I noticed is that in a part of this application, a request is made to the server and a key is received from the server in base64 format. Then it converts the same key into hex format and then derives from it and creates another key named shared secret key. Then, it uses this key for symmetric encryption operations in the AES method. I want to know what the algorithm of this derivation is like and how I can get from the main key string to the derived key string, which is called shared secret key.
main key base64 receive from server : BEdGgIH9PLFU2BcF41Uqvn38inO3bBHbUwKcAIJRBAnf+hfiZo4hWogn8eqVHBCzjdtxmzieFEuRpqi8NRlWH6o=
convert base64 key to hex format : 0447468081fd3cb154d81705e3552abe7dfc8a73b76c11db53029c0082510409dffa17e2668e215a8827f1ea951c10b38ddb719b389e144b91a6a8bc3519561faa
derived key : 7e2f725debc83adafe237b95ed5cf1c9a8b16e25b83848049ecbd4a85b38f000
i found some code of this application in javascript that i trace for generate shared secret key The codes that perform this operation in my desired system (in JavaScript language) are as follows:
let a = '0447468081fd3cb154d81705e3552abe7dfc8a73b76c11db53029c0082510409dffa17e2668e215a8827f1ea951c10b38ddb719b389e144b91a6a8bc3519561faa';
n = d.keyFromPublic(a, "hex");
s = e.derive(n.getPublic());
r = s.toString(16);
//after run this code r is 7e2f725debc83adafe237b95ed5cf1c9a8b16e25b83848049ecbd4a85b38f000
now r is a hex and use for AES.
Also, the terms "secp256k1" can be seen in the codes, which I think are related to the methods and algorithms of this operation
What exactly do these codes do? How and during what operation is the primary key derived and we reach the second key? Thank you for providing explanations regarding this operation