core/crypto/_edwards25519: Initial import

This commit is contained in:
Yawning Angel
2024-04-09 14:37:59 +09:00
parent fec42a6d74
commit 563c527419
7 changed files with 885 additions and 49 deletions
@@ -20,6 +20,10 @@ _TWO_336 := Montgomery_Domain_Field_Element {
0x3d217f5be65cb5c,
}
fe_clear :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) {
mem.zero_explicit(arg1, size_of(Montgomery_Domain_Field_Element))
}
fe_from_bytes :: proc "contextless" (
out1: ^Montgomery_Domain_Field_Element,
arg1: ^[32]byte,
@@ -85,7 +89,7 @@ fe_from_bytes_wide :: proc "contextless" (
fe_mul(&tmp, &tmp, &_TWO_336) // c * 2^336
fe_add(out1, out1, &tmp) // a + b * 2^168 + c * 2^336
mem.zero_explicit(&tmp, size_of(tmp))
fe_clear(&tmp)
}
@(private)
@@ -125,7 +129,7 @@ fe_equal :: proc "contextless" (arg1, arg2: ^Montgomery_Domain_Field_Element) ->
// which will be 1.
_, borrow := bits.sub_u64(fe_non_zero(&tmp), 1, 0)
mem.zero_explicit(&tmp, size_of(tmp))
fe_clear(&tmp)
return int(borrow)
}