Add subtraction stub

This commit is contained in:
Henry de Valence 2017-03-12 23:17:49 -07:00
parent eb66088cb9
commit 4db735ca44

View file

@ -75,6 +75,16 @@ pub fn mul64(a: &[u64;5], b: &[u64;5]) -> [u64;5] {
[c0,c1,c2,c3,c4]
}
fn subtract(a: &[u64; 5], b: &[u64; 5]) -> [u64; 5] {
// add p to avoid underflow
[ (a[0] + 2251799813685229) - b[0]
, (a[1] + 2251799813685247) - b[1]
, (a[2] + 2251799813685247) - b[2]
, (a[3] + 2251799813685247) - b[3]
, (a[4] + 2251799813685247) - b[4]
]
}
fn from_bytes_64(bytes: &[u8;32]) -> [u64; 5] {
let low_51_bit_mask = (1u64 << 51) - 1;
// load bits [ 0, 64), no shift