Coder Social home page Coder Social logo

Comments (4)

xJonathanLEI avatar xJonathanLEI commented on August 15, 2024 1

Correct. Note that you don't need to directly import starknet-signers. It's re-exported through the umbrella starknet crate as well. So you can do something like starknet::signers::xxxx.

from starknet-rs.

xJonathanLEI avatar xJonathanLEI commented on August 15, 2024

Technically Starknet.js is wrong here. When you randomly generate 32 bytes it's very likely the result is not a valid field element, as the Starknet field element is only 252 bits (it doesn't even make use of all of 252 bits, meaning that even if you randomly generate just 252 bits (instead of 256) you could still get an invalid value). Starknet.js is incorrect in that it should have rejected your input. This is not a bug in starknet-rs. starknet-rs is correctly pointing out that your input is invalid.

That said, if you do want to use that key, you would need to study the Starknet.js code to understand how it's turning your invalid input into a valid one (it has to happen somewhere inside their code, after all). Then, you can use that valid, in-range, field element as private key in starknet-rs.

I haven't looked but my guess is that they simply take the your input and mod P. If that's the case you can simply do that too and use the result for starknet-rs.

from starknet-rs.

whyubel1eve avatar whyubel1eve commented on August 15, 2024

thank u for reply, I will look into it.

from starknet-rs.

whyubel1eve avatar whyubel1eve commented on August 15, 2024

Hi @xJonathanLEI. I think I might need to give up that old private key. If I want to generate a valid private key that can be used in starknet-rs, what should I do?
use SigningKey::from_random from starknet-signers instead?

from starknet-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.