urbit-ob

JavaScript utilities for phonemic base wrangling.
Log | Files | Refs | README

commit 94a842d7eaddb56b3085792dbcd9d4a65da717db
parent cc32174f7226a7377a7a16025487316f735c4229
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 18 Mar 2019 10:07:29 +1300

Remove deprecated ob code.

Replaces deprecated obfuscation functions (e.g. 'fice', 'teil', etc.)
with corrected versions ('feis', 'tail').

Diffstat:
Msrc/internal/ob.js | 115-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 115 deletions(-)

diff --git a/src/internal/ob.js b/src/internal/ob.js @@ -69,48 +69,6 @@ const fynd = (arg) => { } /** - * Conceal structure v2. - * - * @param {String, Number, BN} pyn - * @return {BN} - */ -const feen = (arg) => { - const loop = (pyn) => { - const lo = pyn.and(ux_ffff_ffff) - const hi = pyn.and(ux_ffff_ffff_0000_0000) - - return pyn.gte(ux_1_0000) && pyn.lte(ux_ffff_ffff) - ? ux_1_0000.add(fice(pyn.sub(ux_1_0000))) - : pyn.gte(ux_1_0000_0000) && pyn.lte(ux_ffff_ffff_ffff_ffff) - ? hi.or(loop(lo)) - : pyn - } - - return loop(new BN(arg)) -} - -/** - * Restore structure v2. - * - * @param {String, Number, BN} pyn - * @return {BN} - */ -const fend = (arg) => { - const loop = (cry) => { - const lo = cry.and(ux_ffff_ffff) - const hi = cry.and(ux_ffff_ffff_0000_0000) - - return cry.gte(ux_1_0000) && cry.lte(ux_ffff_ffff) - ? ux_1_0000.add(teil(cry.sub(ux_1_0000))) - : cry.gte(ux_1_0000_0000) && cry.lte(ux_ffff_ffff_ffff_ffff) - ? hi.or(loop(lo)) - : cry - } - - return loop(new BN(arg)) -} - -/** * Generalised Feistel cipher. * * See: Black and Rogaway (2002), "Ciphers with arbitrary finite domains." @@ -162,25 +120,6 @@ const fe = (r, a, b, f, m) => { } /** - * Adapted from Black and Rogaway "Ciphers with arbitrary finite domains", - * 2002. - * - * @param {String, Number, BN} - * @return {BN} - */ -const fice = (arg) => { - const nor = new BN(arg) - - const sel = - rynd(3, - rynd(2, - rynd(1, - rynd(0, [ nor.mod(u_65535), nor.div(u_65535) ])))) - - return (u_65535.mul(sel[0])).add(sel[1]) -} - -/** * Reverse 'feis'. * * See: Black and Rogaway (2002), "Ciphers with arbitrary finite domains." @@ -248,60 +187,7 @@ const fen = (r, a, b, f, m) => { return loop(r, L, R) } -/** - * Reverse fice. - * - * @param {String} vip - * @return {BN} - */ -const teil = (arg) => { - const vip = new BN(arg) - - const sel = - rund(0, - rund(1, - rund(2, - rund(3, [ vip.mod(u_65535), vip.div(u_65535) ])))) - - return (u_65535.mul(sel[0])).add(sel[1]) -} - -/** - * Feistel round. - * - * @param {Number} n - * @param {Array<BN>} [l, r] - * @return {Array<BN>} - */ -const rynd = (n, arr) => { - const l = arr[0] - const r = arr[1] - const p = n % 2 === 0 ? u_65535 : u_65536 - return [ r, l.add(muk(raku[n], 2, r)).mod(p) ] -} - -/** - * Reverse round. - * - * @param {Number} n - * @param {Array<BN>} [l, r] - * @return {Array<BN>} - */ -const rund = (n, arr) => { - const l = arr[0] - const r = arr[1] - const p = n % 2 === 0 ? u_65535 : u_65536 - return [ r, l.add(p).sub(muk(raku[n], 2, r).mod(p)).mod(p) ] -} - module.exports = { - feen, - fend, - fice, - teil, - rynd, - rund, - F, raku, @@ -314,5 +200,4 @@ module.exports = { Fen, tail, fynd - }