keyFromPrivate returning incorrect Keypair
legion2002 opened this issue · 0 comments
Hi, I am facing issues with signing messages using Signer, in Starknet, and I think that the issue stems from the ec.keyFromPrivate function
( I am using the starknet js library)
Here is the error that I am getting - https://alpha4.starknet.io/feeder_gateway/get_transaction?transactionHash=0x5d7e3c4e333b4db6a1e6f8dd8809fc3661cd51c5852a6a139f2561f8da59121
I have debugged it to the point, where I can see that the private key I feed into the ec.keyFromPrivate is not the same private key I get back from the keyPair
Here is the code I am using to create the signer
const gateway = new Provider({ baseUrl: gatewayUrl });
const keyPair = ec.ec.keyFromPrivate(privKey, "hex");
console.log(`The Private Key sent is: ${privKey}`);
console.log(`The Private Key from Keypair is ${keyPair.getPrivate("hex")}`);
console.log(`The Abstract Account Address is ${abstractAccountAddr}`);
console.log(`The Public Key from Keypair is ${keyPair.getPublic("hex")}`);
this.signer = new Signer(gateway, abstractAccountAddr, keyPair);
The first two console logs don't output the same private key as they should.
There seems to be an issue with the keyPair that I get back from the ec.ec.keyFromPrivate function,
I noticed that the beginning and end of the private keys is the same, but there are chunks of variation in the middle digits of the key
Kindly help me with this issue
thanks