@@ -1,4 +1,5 @@
11import { hex2patp } from 'urbit-ob';
2+import { createRing } from 'lib/keys';
23
34import jssha256 from 'js-sha256';
45
@@ -7,7 +8,7 @@ function shax(buf) {
78 return Buffer.from(hashed);
89}
910
10−function hexToArrayBuffer(hex) {
11+function hex2buf(hex) {
1112 return Buffer.from(hex, 'hex').reverse();
1213}
1314
@@ -38,10 +39,10 @@ function shaf(buf, salt) {
3839 return xor(front, back);
3940}
4041
41−export const generateCode = async privKeyHex => {
42− const privKey = hexToArrayBuffer(privKeyHex);
43− const salt = hexToArrayBuffer('73736170');
44− const hash = shax(privKey);
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);
4546 const result = shaf(hash, salt);
4647 const half = result.slice(0, result.length / 2);
4748