1
0
mirror of https://github.com/danog/fast-srp.git synced 2024-11-26 20:04:49 +01:00

Optimizing code

This commit is contained in:
Zarmack Tanen 2015-09-10 11:49:44 +02:00
parent c44264be7e
commit 85cfc7d81b

View File

@ -231,8 +231,7 @@ function getu(params, A, B) {
var u_buf = crypto.createHash(params.hash)
.update(A).update(B)
.digest();
//! return bignum.fromBuffer(u_buf);
return(new BigInteger(u_buf));
return(new BigInteger(u_buf));
};
/*
@ -255,8 +254,6 @@ function client_getS(params, k_num, x_num, a_num, B_num, u_num) {
assertIsBigInteger(a_num);
assertIsBigInteger(B_num);
assertIsBigInteger(u_num);
// var g = params.g;
// var N = params.N;
if((zero.compareTo(B_num) > 0) && (N.compareTo(B_num) < 0))
throw new Error("invalid server-supplied 'B', must be 1..N-1");
var S_num = B_num.subtract(k_num.multiply(params.g.modPow(x_num, params.N))).modPow(a_num.add(u_num.multiply(x_num)), params.N).mod(params.N);
@ -281,12 +278,10 @@ function server_getS(params, v_num, A_num, b_num, u_num) {
assertIsBigInteger(A_num);
assertIsBigInteger(b_num);
assertIsBigInteger(u_num);
var N = params.N;
//! if (zero.greater(A_num) || N.lesser(A_num))
if((zero.compareTo(A_num) > 0) && (N.compareTo(A_num) < 0))
throw new Error("invalid client-supplied 'A', must be 1..N-1");
//* var S_num = A_num.mul(v_num.powm(u_num, N)).powm(b_num, N).mod(N);
var S_num = A_num.multiply(v_num.modPow(u_num, N)).modPow(b_num, N).mod(N);
var S_num = A_num.multiply(v_num.modPow(u_num, params.N)).modPow(b_num, params.N).mod(params.N);
return padToN(S_num, params);
};