ECC private key is longer than public key

后端 未结 1 1030
名媛妹妹
名媛妹妹 2021-01-28 06:51

I have generated ECC public and private key using secp192r1 curve. I get 75 for public and 125 for private encoded key array length. Why private key is longer than public key? W

相关标签:
1条回答
  • 2021-01-28 07:27

    Code fragment below outputs 24 bytes private key:

    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    
    ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp192r1");
    
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
    g.initialize(spec, new SecureRandom());
    KeyPair pair = g.generateKeyPair();
    ECPrivateKey ecPrivateKey = (ECPrivateKey)pair.getPrivate();
    
    System.out.println(ecPrivateKey.getS().toByteArray().length);
    
    0 讨论(0)
提交回复
热议问题