1
1
镜像自地址 https://github.com/henrydcase/pqc.git 已同步 2024-11-22 15:39:07 +00:00

NTRU Prime: avoid unsigned unary negation

这个提交包含在:
John M. Schanck 2020-09-01 16:18:21 -04:00 提交者 Kris Kwiatkowski
父节点 191aed977f
当前提交 4883bb44c0
共有 9 个文件被更改,包括 9 次插入9 次删除

查看文件

@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -16,7 +16,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -15,7 +15,7 @@
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}

查看文件

@ -14,7 +14,7 @@ typedef int8 small;
static int int16_nonzero_mask(int16 x) {
uint16 u = (uint16) x; /* 0, else 1...65535 */
uint32 v = u; /* 0, else 1...65535 */
v = -v; /* 0, else 2^32-65535...2^32-1 */
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
v >>= 31; /* 0, else 1 */
return -(int) v; /* 0, else -1 */
}