因此,过了一会儿,我想出了一个解决方案,并决定将其发布,以防其他人遇到与我相同的问题:
KeyFactory keyFactory = KeyFactory.getInstance("ECDSA", "BC"); ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp256k1"); ECPoint Q = ecSpec.getG().multiply(((org.bouncycastle.jce.interfaces.ECPrivateKey) this.privateKey).getD()); ECPublicKeySpec pubSpec = new ECPublicKeySpec(Q, ecSpec); PublicKey publicKeyGenerated = keyFactory.generatePublic(pubSpec); this.publicKey = publicKeyGenerated;
编辑:删除了根据@MaartenBodewes注释解码ECPoint的代码。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)