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)
21export function shas(buf, salt) {
22 return shax(xor(salt, shax(buf)));
26 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
29 throw new Error('only xor buffers!');
31 const length = Math.max(a.byteLength, b.byteLength);
32 const result = new Uint8Array(length);
33 for (let i = 0; i < length; i++) {
34 result[i] = a[i] ^ b[i];
39function shaf(buf, salt) {
40 const result = shas(buf, salt);
41 const halfway = result.length / 2;
42 const front = result.slice(0, halfway);
43 const back = result.slice(halfway, result.length);
44 return xor(front, back);
47export const generateCode = pair => {
48 const ring = hex2buf(createRing(pair));
49 const salt = hex2buf('73736170'); // salt is the noun %pass
50 const hash = shax(ring);
51 const result = shaf(hash, salt);
52 const half = result.slice(0, result.length / 2);
54 return hex2patp(buf2hex(half)).slice(1);
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