ref: d975956a1a2a1b05e328247fc0f5ca841edc8e18
parent: 1ed7430691158c6a2a0c5a7bae36e9e49a43a0e2
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jan 27 17:30:08 EST 2019
Add commonly used constants.
--- a/lib/crypto/curve25519.myr
+++ b/lib/crypto/curve25519.myr
@@ -50,9 +50,16 @@
use std
pkg crypto =
- const curve25519 : (pub : byte[:/*32*/], secret : byte[:/*32*/], basepoint : byte[:/*32*/] -> void)
+ const Nine : byte[:]
+ const curve25519 : (pub : byte[:/*32*/], secret : byte[:/*32*/], basepoint : byte[:/*32*/] -> void)
;;
+const Nine = \
+ "\x09\x00\x00\x00\x00\x00\x00\x00" \
+ "\x00\x00\x00\x00\x00\x00\x00\x00" \
+ "\x00\x00\x00\x00\x00\x00\x00\x00" \
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+
/* Sum two numbers: out += in */
const fsum = {out, in
for var i = 0; i < 10; i += 2
@@ -692,11 +699,14 @@
var z : int64[11] /* one extra for reduced coefficients */
var zmone : int64[10]
+ std.assert(pub.len == 32 , "wrong pubkey size\n")
+ std.assert(secret.len == 32 , "wrong secret size\n")
+ std.assert(basepoint.len == 32 , "wrong basepoint size\n")
+
secret[0] &= 248
secret[31] &= 127
secret[31] |= 64
- std.assert(pub.len == 32 && secret.len == 32 && basepoint.len == 32, "wrong key sizes")
fexpand(bp[:], basepoint[:])
cmult(x[:], z[:], secret[:], bp[:])
crecip(zmone[:], z[:])