on master help sign in
keys: support multi-keyfile generation
bf45baafang
src/lib/keys.js+25−1
@@ -76,12 +76,36 @@ export const compileNetworkKey = (pair, point, revision) => {
76 noun.Atom.fromInt(point),
76 noun.Atom.fromInt(point),
77 noun.Atom.fromInt(revision),
77 noun.Atom.fromInt(revision),
78 noun.Atom.fromString(bnsec.toString()),
78 noun.Atom.fromString(bnsec.toString()),
79− noun.Atom.yes
79+ noun.Atom.fromInt(0)
80 );
80 );
81
81
82 return b64(jam(sed));
82 return b64(jam(sed));
83};
83};
84
84
85+/**
86+ * @param {number} point
87+ * @param {array<{revision: number, pair: object}>} keys
88+ * @return {string}
89+ */
90+export const compileMultiKey = (point, keys) => {
91+ const kyz = keys.map(k => {
92+ const bnsec = new BN(createRing(k.pair), 'hex');
93+ return noun.dwim(
94+ noun.Atom.fromInt(k.revision),
95+ noun.Atom.fromString(bnsec.toString())
96+ );
97+ });
98+ kyz.push(noun.Atom.fromInt(0));
99+
100+ const fed = noun.dwim(
101+ noun.dwim(noun.Atom.fromInt(1), noun.Atom.fromInt(0)), // version
102+ noun.Atom.fromInt(point), // ship
103+ noun.dwim(kyz) // keys
104+ );
105+
106+ return b64(jam(fed));
107+};
108+
85/**
109/**
86 * @param {object} urbitWallet
110 * @param {object} urbitWallet
87 * @param {number} revision
111 * @param {number} revision