|
|
|
@ -44,11 +44,9 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
@@ -44,11 +44,9 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
|
|
|
|
|
//console.log('computeSRP:', password, state, isNew, algo);
|
|
|
|
|
|
|
|
|
|
const p = str2bigInt(bytesToHex(algo.p), 16); |
|
|
|
|
const B = str2bigInt(bytesToHex(state.srp_B), 16); |
|
|
|
|
const g = int2bigInt(algo.g, 32, 256); |
|
|
|
|
|
|
|
|
|
//log('p', bigInt2str(p, 16));
|
|
|
|
|
//log('B', bigInt2str(B, 16));
|
|
|
|
|
|
|
|
|
|
/* if(B.compareTo(BigInteger.ZERO) < 0) { |
|
|
|
|
console.error('srp_B < 0') |
|
|
|
@ -83,14 +81,6 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
@@ -83,14 +81,6 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
|
|
|
|
|
return addPadding(arr, len, true, true, true); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const pForHash = padArray(bytesFromHex(bigInt2str(p, 16)), 256); |
|
|
|
|
const gForHash = padArray(bytesFromHex(bigInt2str(g, 16)), 256); // like uint8array
|
|
|
|
|
const b_for_hash = padArray(bytesFromHex(bigInt2str(B, 16)), 256); |
|
|
|
|
|
|
|
|
|
/* log(bytesToHex(pForHash)); |
|
|
|
|
log(bytesToHex(gForHash)); |
|
|
|
|
log(bytesToHex(b_for_hash)); */ |
|
|
|
|
|
|
|
|
|
const v = powMod(g, x, p); |
|
|
|
|
|
|
|
|
|
const flipper = (arr: Uint8Array | number[]) => { |
|
|
|
@ -111,6 +101,16 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
@@ -111,6 +101,16 @@ export async function computeSRP(password: string, state: AccountPassword, isNew
|
|
|
|
|
return padArray(/* (isBigEndian ? bytes.reverse() : bytes) */bytes, 256); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const B = str2bigInt(bytesToHex(state.srp_B), 16); |
|
|
|
|
//log('B', bigInt2str(B, 16));
|
|
|
|
|
|
|
|
|
|
const pForHash = padArray(bytesFromHex(bigInt2str(p, 16)), 256); |
|
|
|
|
const gForHash = padArray(bytesFromHex(bigInt2str(g, 16)), 256); // like uint8array
|
|
|
|
|
const b_for_hash = padArray(bytesFromHex(bigInt2str(B, 16)), 256); |
|
|
|
|
/* log(bytesToHex(pForHash)); |
|
|
|
|
log(bytesToHex(gForHash)); |
|
|
|
|
log(bytesToHex(b_for_hash)); */ |
|
|
|
|
|
|
|
|
|
//log('g_x', bigInt2str(g_x, 16));
|
|
|
|
|
|
|
|
|
|
const kHash = await CryptoWorker.invokeCrypto('sha256-hash', bufferConcats(pForHash, gForHash)); |
|
|
|
|