Git Product home page Git Product logo

Comments (6)

panva avatar panva commented on May 22, 2024 1

This is your key's structure. The library expects it to be this, i.e. having the publicKey member.

I have a fix for this for Node runtimes >= 12.0.0. I can't fix this for ^10.13.0 because i lack the functionality to compute the public key out of a private one and the extra code needed does seem like an overkill when all a person needs is to use lts/12 runtime.

from jose.

panva avatar panva commented on May 22, 2024

I think my code doesn’t account for EC private keys that don’t include the public key in them.

I’ll see what I can do, in the meantime, can you post the command that generated this key?

from jose.

swapnilgt avatar swapnilgt commented on May 22, 2024

I was trying out some openssl commands to generate a private key that does not have a public key embedded. Tried this:

openssl ecparam -name prime256v1 -genkey -noout -out key.pem

I am searching for a way to extra only the private key part from here.

PS: The library works fine with the key embedded with the public key

I generally generate the KeyPair using the Java security library:

public static KeyPair generateEcKeyPair() {
        String name = "prime256v1";
        try {
            KeyPairGenerator generator = KeyPairGenerator.getInstance("EC");
            ECGenParameterSpec spec = new ECGenParameterSpec(name);
            generator.initialize(spec, new SecureRandom());
            return generator.generateKeyPair();
        } catch (Exception exp) {
           // Your code
        }
    }

Once you get the key pair, you can access the private key separately and extract the base64 encoded format using Java's util functions.

@panva

from jose.

panva avatar panva commented on May 22, 2024

PS: The library works fine with the key embedded with the public key

I know.

from jose.

swapnilgt avatar swapnilgt commented on May 22, 2024

Thanks a lot @panva fo your quick support. :)

from jose.

panva avatar panva commented on May 22, 2024

Please consider supporting the library if it provides value to you or your company and this support was of help to you. Supporting the library means, amongst other things, that such support will be available in the future.

from jose.

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.