Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bbs = (m, s, n) => {
- const res = [s];
- for (let i = 1; i < n; i++) {
- res.push(Math.pow(res[i - 1], 2) % m);
- }
- return res.map(e => e & 1);
- };
- /**
- *
- * @param {Number} n
- * @param {Number} s
- * @param {Array<Number>} y
- */
- const inv_bbs = (n, s, y) => {
- const bin = y.reduce((str, e) => {
- str += e.toString(2);
- return str;
- }, "");
- // const maxlen = Math.ceil(Math.log2(n + 1));
- // const helper = Math.floor(Math.log2(maxlen));
- // const xn = (y.length * 8) / 4;
- const seq = bbs(n, s, 32);
- return [...bin].map((e, index) => e ^ seq[index]).join("");
- // return maxlen;
- };
- console.log(bbs(407 * 588, 3164, 8));
- console.log(inv_bbs(30353, 17849, [214, 190, 100]));
- console.log(inv_bbs(243793, 48914, [16, 182, 219, 83]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement