Skip to content

Commit

Permalink
clean up unused nacl functions for corerage purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
rg911 committed Mar 2, 2020
1 parent ae8c09c commit ece8fa9
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions src/core/crypto/nacl_catapult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,28 +669,6 @@ const unpack25519 = (o, n) => {
o[15] &= 0x7fff;
};

export const cleanup = (arr) => {
for (let i = 0; i < arr.length; i++) {
arr[i] = 0;
}
};

export const crypto_shared_key_hash = (shared, pk, sk, hashfunc) => {
const d = new Uint8Array(64);
const p = [gf(), gf(), gf(), gf()];

hashfunc(d, sk, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;

const q = [gf(), gf(), gf(), gf()];
// tslint:disable: no-use-before-declare
unpackneg(q, pk);
scalarmult(p, q, d);
pack(shared, p);
};

export const crypto_verify_32 = (x, xi, y, yi) => {
return vn(x, xi, y, yi, 32);
};
Expand Down Expand Up @@ -728,47 +706,6 @@ export const add = (p, q) => {
M(p[3], e, h);
};

export const modL = (r, x) => {
// tslint:disable-next-line:one-variable-per-declaration
let carry, i, j, k;
for (i = 63; i >= 32; --i) {
carry = 0;
for (j = i - 32, k = i - 12; j < k; ++j) {
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
carry = (x[j] + 128) >> 8;
x[j] -= carry * 256;
}
x[j] += carry;
x[i] = 0;
}
carry = 0;
for (j = 0; j < 32; j++) {
x[j] += carry - (x[31] >> 4) * L[j];
carry = x[j] >> 8;
x[j] &= 255;
}
for (j = 0; j < 32; j++) {
x[j] -= carry * L[j];
}
for (i = 0; i < 32; i++) {
x[i + 1] += x[i] >> 8;
r[i] = x[i] & 255;
}
};

export const reduce = (r) => {
// tslint:disable-next-line:one-variable-per-declaration
let x = new Float64Array(64),
i;
for (i = 0; i < 64; i++) {
x[i] = r[i];
}
for (i = 0; i < 64; i++) {
r[i] = 0;
}
modL(r, x);
};

export const pack = (r, p) => {
// tslint:disable-next-line:one-variable-per-declaration
const tx = gf(),
Expand Down Expand Up @@ -797,64 +734,6 @@ export const scalarmult = (p, q, s) => {
}
};

export const scalarbase = (p, s) => {
const q = [gf(), gf(), gf(), gf()];
set25519(q[0], X);
set25519(q[1], Y);
set25519(q[2], gf1);
M(q[3], X, Y);
scalarmult(p, q, s);
};

export const unpackneg = (r, p) => {
// tslint:disable-next-line:one-variable-per-declaration
const t = gf(),
chk = gf(),
num = gf(),
den = gf(),
den2 = gf(),
den4 = gf(),
den6 = gf();

set25519(r[2], gf1);
unpack25519(r[1], p);
S(num, r[1]);
M(den, num, D);
Z(num, num, r[2]);
A(den, r[2], den);

S(den2, den);
S(den4, den2);
M(den6, den4, den2);
M(t, den6, num);
M(t, t, den);

pow2523(t, t);
M(t, t, num);
M(t, t, den);
M(t, t, den);
M(r[0], t, den);

S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) {
M(r[0], r[0], I);
}

S(chk, r[0]);
M(chk, chk, den);
if (neq25519(chk, num)) {
return -1;
}

if (par25519(r[0]) === (p[31] >> 7)) {
Z(r[0], gf0, r[0]);
}

M(r[3], r[0], r[1]);
return 0;
};

export const unpack = (r, p) => {
// tslint:disable-next-line:one-variable-per-declaration
const t = gf(),
Expand Down

0 comments on commit ece8fa9

Please sign in to comment.