i want use w=16 to enhance random private key speed
here is my code:
`Secp256K1::Secp256K1() {
GTable = new Point(65536*16);
}
void Secp256K1::Init() {
// Prime for the finite field
Int P;
P.SetBase16("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
// Set up field
Int::SetupField(&P);
// Generator point and order
G.x.SetBase16("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798");
G.y.SetBase16("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");
G.z.SetInt32(1);
order.SetBase16("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
Int::InitK1(&order);
// Compute Generator table
Point N(G);
for(int i = 0; i < 16; i++) {
GTable[i 65536] = N;
N = DoubleDirect(N);
for (int j = 1; j < 65535; j++) {
GTable[i 65536+ j] = N;
N = AddDirect(N, GTable[i 65536]);
}
GTable[i 65536+ 65535] = N; // Dummy point for check function
}
}
Point Secp256K1::ComputePublicKey(Int *privKey) {
int i = 0;
uint16_t b;
Point Q;
Q.Clear();
// Search first significant byte
for (i = 0; i < 16; i++) {
b = privKey->GetShort(i);
if(b)
break;
}
Q = GTable[65536 * i + (b-1)];
i++;
for(; i < 16; i++) {
b = privKey->GetShort(i);
if(b)
Q = Add2(Q, GTable[65536* i + (b-1)]);
}
Q.Reduce();
return Q;
}
`
I do not understand as a beginner to study ECC.
Please help me to correct my code
thank you a lot
hi, Jean-Luc
i want use w=16 to enhance random private key speed
here is my code: `Secp256K1::Secp256K1() { GTable = new Point(65536*16); }
void Secp256K1::Init() {
// Prime for the finite field Int P; P.SetBase16("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
// Set up field Int::SetupField(&P);
// Generator point and order G.x.SetBase16("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"); G.y.SetBase16("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8"); G.z.SetInt32(1); order.SetBase16("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
Int::InitK1(&order);
// Compute Generator table Point N(G); for(int i = 0; i < 16; i++) { GTable[i 65536] = N; N = DoubleDirect(N); for (int j = 1; j < 65535; j++) { GTable[i 65536+ j] = N; N = AddDirect(N, GTable[i 65536]); } GTable[i 65536+ 65535] = N; // Dummy point for check function } }
Point Secp256K1::ComputePublicKey(Int *privKey) {
int i = 0; uint16_t b; Point Q; Q.Clear();
// Search first significant byte for (i = 0; i < 16; i++) { b = privKey->GetShort(i); if(b) break; } Q = GTable[65536 * i + (b-1)]; i++;
for(; i < 16; i++) { b = privKey->GetShort(i); if(b) Q = Add2(Q, GTable[65536* i + (b-1)]); }
Q.Reduce(); return Q; } `
I do not understand as a beginner to study ECC. Please help me to correct my code thank you a lot