urbit-ob

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

commit 04ae6635b4bca0624743fba97119969be846dc3c
parent aa2867a7159d7193898b844ebe6b16a6cf35ea32
Author: Jared Tobin <jared@jtobin.io>
Date:   Tue, 12 Mar 2019 21:05:54 +1300

Use same PRF seeds that exhaustive test uses.

I had simplified some index math that changed the order of the
pseudorandom functions used by 'fe'.  This is benign (it just permutes
every @p), but to match the output of the exhaustive test, it's best to
preserve the order of the functions.

Diffstat:
Msrc/internal/ob.js | 11++++++++++-
Mtest/ob.test.js | 16++++++++--------
2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/internal/ob.js b/src/internal/ob.js @@ -15,6 +15,14 @@ const u_65535 = new BN('65535') const u_65536 = new BN('65536') // PRF seeds +const rako = [ + 0x4b387af7, + 0x85bcae01, + 0xee281300, + 0xb76d5eed, +] + +// old PRF seeds const raku = [ 0xb76d5eed, 0xee281300, @@ -24,7 +32,7 @@ const raku = [ // a PRF for j in { 0, .., 3 } const F = (j, arg) => - muk(raku[j], 2, arg) + muk(rako[j], 2, arg) /** * Conceal structure v3. @@ -284,6 +292,7 @@ module.exports = { F, raku, + rako, fe, Fe, diff --git a/test/ob.test.js b/test/ob.test.js @@ -65,20 +65,20 @@ describe('fein/fynd', () => { it('fein matches expected reference values', () => { let input = new BN('123456789') - let output = new BN('249127493') + let output = new BN('1645384789') expect(fein(input).eq(output)).to.equal(true) input = new BN('15663360') - output = new BN('148913959') + output = new BN('1032628475') expect(fein(input).eq(output)).to.equal(true) }) it('fynd matches expected reference values', () => { - let input = new BN('249127493') + let input = new BN('1645384789') let output = new BN('123456789') expect(fynd(input).eq(output)).to.equal(true) - input = new BN('148913959') + input = new BN('1032628475') output = new BN('15663360') expect(fynd(input).eq(output)).to.equal(true) }) @@ -124,20 +124,20 @@ describe('feis/tail', () => { it('feis matches expected reference values', () => { let input = new BN ('123456789') - let output = new BN('2483218125') + let output = new BN('3869445208') expect(feis(input).eq(output)).to.equal(true) input = new BN('15663360') - output = new BN('2530652268') + output = new BN('2746999232') expect(feis(input).eq(output)).to.equal(true) }) it('tail matches expected reference values', () => { - let input = new BN('2483218125') + let input = new BN('3869445208') let output = new BN ('123456789') expect(tail(input).eq(output)).to.equal(true) - input = new BN('2530652268') + input = new BN('2746999232') output = new BN('15663360') expect(tail(input).eq(output)).to.equal(true) })