Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyFromPrivate returning incorrect Keypair #274

Open
legion2002 opened this issue Mar 21, 2022 · 0 comments
Open

keyFromPrivate returning incorrect Keypair #274

legion2002 opened this issue Mar 21, 2022 · 0 comments

Comments

@legion2002
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant