on master help sign in
Revert "View +code inside bridge"
commit76862ca759b6630e2fcc2ecf81d54bdbcd25b35d authorAnthony Arroyo <anthony@tlon.io> dateWed 16 Oct 2019, 20:44 (7 years ago) parent7502d29
4 files changed+4−75
src/lib/keys.js+4−4 src/lib/networkCode.js−50 src/lib/useKeyfileGenerator.js−7 src/views/Point.js−14
src/lib/keys.js+4−4
@@ -59,9 +59,6 @@ const jam = seed => {
5959// simple alias to avoid importing kg into component scope
6060export const deriveNetworkKeys = seed => kg.deriveNetworkKeys(seed);
6161
62−export const createRing = pair =>
63− pair.crypt.private + pair.auth.private + NETWORK_KEY_CURVE_PARAMETER;
64−
6562/**
6663 * @param {object} pair
6764 * @param {number} point
@@ -69,7 +66,10 @@ export const createRing = pair =>
6966 * @return {string}
7067 */
7168export const compileNetworkingKey = (pair, point, revision) => {
72− const bnsec = new BN(createRing(pair), 'hex');
69+ const bnsec = new BN(
70+ pair.crypt.private + pair.auth.private + NETWORK_KEY_CURVE_PARAMETER,
71+ 'hex'
72+ );
7373
7474 const sed = noun.dwim(
7575 noun.Atom.fromInt(point),
src/lib/networkCode.jsdeleted−50
@@ -1,50 +0,0 @@
1−import { hex2patp } from 'urbit-ob';
2−import { createRing } from 'lib/keys';
3−
4−import jssha256 from 'js-sha256';
5−
6−function shax(buf) {
7− const hashed = jssha256.sha256.array(buf);
8− return Buffer.from(hashed);
9−}
10−
11−function hex2buf(hex) {
12− return Buffer.from(hex, 'hex').reverse();
13−}
14−
15−function buf2hex(buf) {
16− return Buffer.from(buf)
17− .reverse()
18− .toString('hex');
19−}
20−
21−function shas(buf, salt) {
22− return shax(xor(salt, shax(buf)));
23−}
24−
25−function xor(a, b) {
26− const length = Math.max(a.byteLength, b.byteLength);
27− const result = new Uint8Array(length);
28− for (let i = 0; i < length; i++) {
29− result[i] = a[i] ^ b[i];
30− }
31− return result;
32−}
33−
34−function shaf(buf, salt) {
35− const result = shas(buf, salt);
36− const halfway = result.length / 2;
37− const front = result.slice(0, halfway);
38− const back = result.slice(halfway, result.length);
39− return xor(front, back);
40−}
41−
42−export const generateCode = pair => {
43− const ring = hex2buf(createRing(pair));
44− const salt = hex2buf('73736170'); // salt is the noun %pass
45− const hash = shax(ring);
46− const result = shaf(hash, salt);
47− const half = result.slice(0, result.length / 2);
48−
49− return hex2patp(buf2hex(half));
50−};
src/lib/useKeyfileGenerator.js−7
@@ -8,7 +8,6 @@ import { useWallet } from 'store/wallet';
88import { usePointCursor } from 'store/pointCursor';
99
1010import * as need from 'lib/need';
11−import { generateCode } from 'lib/networkCode';
1211
1312import {
1413 attemptNetworkSeedDerivation,
@@ -29,8 +28,6 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
2928 const [generating, setGenerating] = useState(true);
3029 const [keyfile, setKeyfile] = useState(false);
3130
32− const [code, setCode] = useState(false);
33−
3431 const _point = need.point(pointCursor);
3532 const _details = need.details(getDetails(_point));
3633
@@ -74,8 +71,6 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
7471
7572 const pair = deriveNetworkKeys(_networkSeed);
7673
77− setCode(generateCode(pair));
78−
7974 if (!keysMatchChain(pair, _details)) {
8075 setGenerating(false);
8176 setNotice('Derived networking keys do not match on-chain details.');
@@ -93,7 +88,6 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
9388 urbitWallet,
9489 wallet,
9590 authMnemonic,
96− setCode,
9791 _details,
9892 _point,
9993 ]);
@@ -119,7 +113,6 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
119113 downloaded,
120114 download,
121115 notice,
122− code,
123116 };
124117
125118 return { ...values, bind: values };
src/views/Point.js−14
@@ -9,7 +9,6 @@ import View from 'components/View';
99import Greeting from 'components/Greeting';
1010import Passport from 'components/Passport';
1111import { ForwardButton, BootArvoButton } from 'components/Buttons';
12−import CopyButton from 'components/CopyButton';
1312import { matchBlinky } from 'components/Blinky';
1413import DownloadSigilButton from 'components/DownloadSigilButton';
1514
@@ -18,7 +17,6 @@ import useInvites from 'lib/useInvites';
1817import { useSyncOwnedPoints } from 'lib/useSyncPoints';
1918import useCurrentPermissions from 'lib/useCurrentPermissions';
2019import { useLocalRouter } from 'lib/LocalRouter';
21−import useKeyfileGenerator from 'lib/useKeyfileGenerator';
2220
2321export default function Point() {
2422 const { pop, push, names } = useLocalRouter();
@@ -26,8 +24,6 @@ export default function Point() {
2624
2725 const point = need.point(pointCursor);
2826
29− const { code, notice } = useKeyfileGenerator();
30−
3127 const {
3228 isParent,
3329 isActiveOwner,
@@ -105,16 +101,6 @@ export default function Point() {
105101 Admin
106102 </Grid.Item>
107103 <Grid.Divider />
108− <Grid.Item
109− full
110− as={ForwardButton}
111− accessory={code && <CopyButton text={code} />}
112− detail={code || notice}
113− disabled={!code}
114− detailClassName="mono">
115− Login Code
116− </Grid.Item>
117− <Grid.Divider />
118104 {isParent && (
119105 <>
120106 <Grid.Item