diff options
author | Shen Noether <Shen.Noether@gmx.com> | 2016-07-09 20:04:23 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:29:16 +0100 |
commit | dbb5f2d6a3d34c0fa899fd26313873cc69dbad9d (patch) | |
tree | c0ec7fe483b6918479bfa62a65396f9800fad82d /src/ringct/rctSigs.cpp | |
parent | ringct: "simple" ringct variant (diff) | |
download | monero-dbb5f2d6a3d34c0fa899fd26313873cc69dbad9d.tar.xz |
ringct: optimization/cleanup of hash functions
Diffstat (limited to '')
-rw-r--r-- | src/ringct/rctSigs.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index c9e34ddb6..7fcb8e158 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -169,22 +169,21 @@ namespace rct { keyV alpha(rows); keyV aG(rows); keyV aHP(rows); - key m2hash; - unsigned char m2[128]; - memcpy(m2, message.bytes, 32); + keyV toHash(1 + 3 * rows); + toHash[0] = message; DP("here1"); for (i = 0; i < rows; i++) { skpkGen(alpha[i], aG[i]); //need to save alphas for later.. Hi = hashToPoint(pk[index][i]); aHP[i] = scalarmultKey(Hi, alpha[i]); - memcpy(m2+32, pk[index][i].bytes, 32); - memcpy(m2 + 64, aG[i].bytes, 32); - memcpy(m2 + 96, aHP[i].bytes, 32); + toHash[3 * i + 1] = pk[index][i]; + toHash[3 * i + 2] = aG[i]; + toHash[3 * i + 3] = aHP[i]; rv.II[i] = scalarmultKey(Hi, xx[i]); precomp(Ip[i].k, rv.II[i]); - m2hash = hash_to_scalar128(m2); - sc_add(c_old.bytes, c_old.bytes, m2hash.bytes); } + c_old = hash_to_scalar(toHash); + i = (index + 1) % cols; if (i == 0) { @@ -198,12 +197,11 @@ namespace rct { addKeys2(L, rv.ss[i][j], c_old, pk[i][j]); hashToPoint(Hi, pk[i][j]); addKeys3(R, rv.ss[i][j], Hi, c_old, Ip[j].k); - memcpy(m2+32, pk[i][j].bytes, 32); - memcpy(m2 + 64, L.bytes, 32); - memcpy(m2 + 96, R.bytes, 32); - m2hash = hash_to_scalar128(m2); - sc_add(c.bytes, c.bytes, m2hash.bytes); + toHash[3 * j + 1] = pk[i][j]; + toHash[3 * j + 2] = L; + toHash[3 * j + 3] = R; } + c = hash_to_scalar(toHash); copy(c_old, c); i = (i + 1) % cols; @@ -248,10 +246,8 @@ namespace rct { for (i= 0 ; i< rows ; i++) { precomp(Ip[i].k, II[i]); } - unsigned char m2[128]; - memcpy(m2, message.bytes, 32); - - key m2hash; + keyV toHash(1 + 3 * rows); + toHash[0] = message; i = 0; while (i < cols) { sc_0(c.bytes); @@ -259,12 +255,11 @@ namespace rct { addKeys2(L, rv.ss[i][j], c_old, pk[i][j]); hashToPoint(Hi, pk[i][j]); addKeys3(R, rv.ss[i][j], Hi, c_old, Ip[j].k); - memcpy(m2 + 32, pk[i][j].bytes, 32); - memcpy(m2 + 64, L.bytes, 32); - memcpy(m2 + 96, R.bytes, 32); - m2hash = hash_to_scalar128(m2); - sc_add(c.bytes, c.bytes, m2hash.bytes); + toHash[3 * j + 1] = pk[i][j]; + toHash[3 * j + 2] = L; + toHash[3 * j + 3] = R; } + c = hash_to_scalar(toHash); copy(c_old, c); i = (i + 1); } |