Fix module imports
This commit is contained in:
parent
3ea90b786b
commit
03c2db100f
7
aead.lua
7
aead.lua
|
@ -1,7 +1,6 @@
|
||||||
local expect = require "cc.expect".expect
|
local expect = require "cc.expect".expect
|
||||||
|
local chacha20 = require "ccryptolib.chacha20"
|
||||||
local chacha20 = require "ecnet.primitives.chacha20"
|
local poly1305 = require "ccryptolib.poly1305"
|
||||||
local poly1305 = require "ecnet.primitives.poly1305"
|
|
||||||
|
|
||||||
local bxor = bit32.bxor
|
local bxor = bit32.bxor
|
||||||
local bor = bit32.bor
|
local bor = bit32.bor
|
||||||
|
|
34
fq.lua
34
fq.lua
|
@ -1,13 +1,39 @@
|
||||||
--- Arithmetic on Curve25519's scalar field.
|
--- Arithmetic on Curve25519's scalar field.
|
||||||
--
|
--
|
||||||
-- @module ecnet.primitives.scalar
|
-- @module ccryptolib.fq
|
||||||
--
|
--
|
||||||
|
|
||||||
local util = require "ecnet.util"
|
|
||||||
|
|
||||||
local rebaseLE = util.rebaseLE
|
|
||||||
local unpack = unpack or table.unpack
|
local unpack = unpack or table.unpack
|
||||||
|
|
||||||
|
--- Converts a little-endian array from one power-of-two base to another.
|
||||||
|
--
|
||||||
|
-- @tparam {number...} a The array to convert, in little-endian.
|
||||||
|
-- @tparam number base1 The base to convert from. Must be a power of 2.
|
||||||
|
-- @tparam number base2 The base to convert to. Must be a power of 2.
|
||||||
|
-- @treturn {number...}
|
||||||
|
--
|
||||||
|
local function rebaseLE(a, base1, base2)
|
||||||
|
local out = {}
|
||||||
|
local outlen = 1
|
||||||
|
local acc = 0
|
||||||
|
local mul = 1
|
||||||
|
for i = 1, #a do
|
||||||
|
acc = acc + a[i] * mul
|
||||||
|
mul = mul * base1
|
||||||
|
while mul >= base2 do
|
||||||
|
local rem = acc % base2
|
||||||
|
acc = (acc - rem) / base2
|
||||||
|
mul = mul / base2
|
||||||
|
out[outlen] = rem
|
||||||
|
outlen = outlen + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if mul > 0 then
|
||||||
|
out[outlen] = acc
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
--- The scalar field's order, q.
|
--- The scalar field's order, q.
|
||||||
local Q = {
|
local Q = {
|
||||||
16110573,
|
16110573,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local expect = require "cc.expect".expect
|
local expect = require "cc.expect".expect
|
||||||
local fp = require "ecnet.primitives.fp"
|
local fp = require "ccryptolib.fp"
|
||||||
|
|
||||||
local add = fp.add
|
local add = fp.add
|
||||||
local sub = fp.sub
|
local sub = fp.sub
|
||||||
|
|
Loading…
Reference in a new issue