我需要使用jdk 1.7实现ECC(椭圆曲线加密)算法.我尝试使用充气城堡,sunEC,但他们都给出了错误和错误.我的目标是使用私钥生成椭圆曲线,我将被赋予系统.
因此,我需要使用jdk1.7获取使用给定私钥生成公钥的准确代码.我使用的IDE是ecllipse.我需要知道,除了私钥之外,我应该给出的其他参数是什么?提供一个曲线点和私钥是否足够?
有人可以帮助我从私钥生成公钥吗?我可以管理其余的实现.
任何知道使用java实现Elliptic Curve Cryptography键的人,请告诉我这段代码是否正确?
public class ECCrypt {
private ECPoint curve_point;
public ECCrypt(ECPoint curve_point) {
this.curve_point = curve_point;
}
public BigInteger makePublicKey(BigInteger privateKey) {
ECPoint ecPublicKey = new ECPoint(curve_point);
ecPublicKey.mult(privateKey);
return ecPublicKey.pack();
}
public static void main(String[] argv) throws Exception {
java.util.Random rnd = new java.util.Random();
ECPoint cp = new ECPoint();
cp.random(rnd);
ECCrypt ec = new ECCrypt(cp);
BigInteger priv = new BigInteger(255,rnd);
BigInteger pub = ec.makePublicKey(priv);
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在NIST指定的曲线“ p192”上执行椭圆曲线点算术运算。为了进行测试,我采用了NIST常规文档中所示曲线p192的示例点。对于点的加法和点的加倍,我得到了正确的答案,但是对于标量乘法,我的答案是不正确的。由于这个原因,我无法确定是否
$ k^{-1}(kP) = P $
Run Code Online (Sandbox Code Playgroud)
哪里
$ k^{-1}.k = 1 mod p $
Run Code Online (Sandbox Code Playgroud)
请帮助我了解我在哪里犯错。
package a;
import java.math.BigInteger;
import java.security.spec.ECPoint;
public class ScalarMultiply {
private static final BigInteger ONE = new BigInteger("1");;
static BigInteger TWO = new BigInteger("2");
static BigInteger p = new BigInteger("6277101735386680763835789423207666416083908700390324961279");
public static ECPoint scalmult(ECPoint P, BigInteger k){
ECPoint R =P,S = P;
int length = k.bitLength();
//System.out.println("length is" + length);
byte[] binarray = new byte[length];
for(int i=0;i<=length-1;i++){
binarray[i] = k.mod(TWO).byteValue(); …Run Code Online (Sandbox Code Playgroud)