Browse Source

minor stuff

Adam Ierymenko 5 years ago
parent
commit
a7409486bb
2 changed files with 12 additions and 12 deletions
  1. 11 11
      node/Identity.cpp
  2. 1 1
      node/Speck128.hpp

+ 11 - 11
node/Identity.cpp

@@ -93,13 +93,13 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len)
 
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 #if __BYTE_ORDER == __BIG_ENDIAN
 	b[0] = Utils::swapBytes(b[0]);
 	b[0] = Utils::swapBytes(b[0]);
-	b[1] = Utils::swapBytes(b[0]);
-	b[2] = Utils::swapBytes(b[0]);
-	b[3] = Utils::swapBytes(b[0]);
-	b[4] = Utils::swapBytes(b[0]);
-	b[5] = Utils::swapBytes(b[0]);
-	b[6] = Utils::swapBytes(b[0]);
-	b[7] = Utils::swapBytes(b[0]);
+	b[1] = Utils::swapBytes(b[1]);
+	b[2] = Utils::swapBytes(b[2]);
+	b[3] = Utils::swapBytes(b[3]);
+	b[4] = Utils::swapBytes(b[4]);
+	b[5] = Utils::swapBytes(b[5]);
+	b[6] = Utils::swapBytes(b[6]);
+	b[7] = Utils::swapBytes(b[7]);
 #endif
 #endif
 
 
 	Speck128<24> s16;
 	Speck128<24> s16;
@@ -113,12 +113,12 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len)
 		uint64_t y2 = b[i + 5];
 		uint64_t y2 = b[i + 5];
 		uint64_t x3 = b[i + 6];
 		uint64_t x3 = b[i + 6];
 		uint64_t y3 = b[i + 7];
 		uint64_t y3 = b[i + 7];
-		x0 += x1;
-		x1 += x2;
 		i += 8;
 		i += 8;
+		x0 += x1; // mix parallel 128-bit blocks
+		x1 += x2;
 		x2 += x3;
 		x2 += x3;
 		x3 += y0;
 		x3 += y0;
-		s16.encrypt512(x0,y0,x1,y1,x2,y2,x3,y3);
+		s16.encryptXYXYXYXY(x0,y0,x1,y1,x2,y2,x3,y3);
 		b[i] = x0;
 		b[i] = x0;
 		b[i + 1] = y0;
 		b[i + 1] = y0;
 		b[i + 2] = x1;
 		b[i + 2] = x1;
@@ -147,7 +147,7 @@ bool _v1_identity_generate_cond(const void *in,const unsigned int len)
 #if __BYTE_ORDER == __BIG_ENDIAN
 #if __BYTE_ORDER == __BIG_ENDIAN
 	return ((Utils::swapBytes(b[0]) + Utils::swapBytes(b[1])) >> 56U) == 0;
 	return ((Utils::swapBytes(b[0]) + Utils::swapBytes(b[1])) >> 56U) == 0;
 #else
 #else
-	return ((b[0] + b[1]) >> 56U) == 0;
+	return ((b[0] + b[1]) & 0xffU) == 0;
 #endif
 #endif
 }
 }
 
 

+ 1 - 1
node/Speck128.hpp

@@ -98,7 +98,7 @@ public:
 	/**
 	/**
 	 * Encrypt 512 bits in parallel with the same key
 	 * Encrypt 512 bits in parallel with the same key
 	 */
 	 */
-	ZT_INLINE void encrypt512(uint64_t &x0,uint64_t &y0,uint64_t &x1,uint64_t &y1,uint64_t &x2,uint64_t &y2,uint64_t &x3,uint64_t &y3) const noexcept
+	ZT_INLINE void encryptXYXYXYXY(uint64_t &x0,uint64_t &y0,uint64_t &x1,uint64_t &y1,uint64_t &x2,uint64_t &y2,uint64_t &x3,uint64_t &y3) const noexcept
 	{
 	{
 		for (int i=0;i<R;++i) {
 		for (int i=0;i<R;++i) {
 			const uint64_t kk = _k[i];
 			const uint64_t kk = _k[i];