1import { hex2patp } from 'urbit-ob';
2import { createRing } from 'lib/keys';
4import jssha256 from 'js-sha256';
7 const hashed = jssha256.sha256.array(buf);
8 return Buffer.from(hashed);
11function hex2buf(hex) {
12 return Buffer.from(hex, 'hex').reverse();
15function buf2hex(buf) {
16 return Buffer.from(buf)
21function shas(buf, salt) {
22 return shax(xor(salt, shax(buf)));
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];
34function 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);
42export 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);
49 return hex2patp(buf2hex(half));
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list