@@ -1,4 +1,5 @@
1import { hex2patp } from 'urbit-ob';
1import { hex2patp } from 'urbit-ob';
2+import { createRing } from 'lib/keys';
3import jssha256 from 'js-sha256';
4import jssha256 from 'js-sha256';
@@ -7,7 +8,7 @@ function shax(buf) {
7 return Buffer.from(hashed);
8 return Buffer.from(hashed);
10−function hexToArrayBuffer(hex) {
11+function hex2buf(hex) {
11 return Buffer.from(hex, 'hex').reverse();
12 return Buffer.from(hex, 'hex').reverse();
@@ -38,10 +39,10 @@ function shaf(buf, salt) {
38 return xor(front, back);
39 return xor(front, back);
41−export const generateCode = async privKeyHex => {
42+export const generateCode = pair => {
42− const privKey = hexToArrayBuffer(privKeyHex);
43+ const ring = hex2buf(createRing(pair));
43− const salt = hexToArrayBuffer('73736170');
44+ const salt = hex2buf('73736170'); // salt is the noun %pass
44− const hash = shax(privKey);
45+ const hash = shax(ring);
45 const result = shaf(hash, salt);
46 const result = shaf(hash, salt);
46 const half = result.slice(0, result.length / 2);
47 const half = result.slice(0, result.length / 2);