Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1x 1x 79x 79x 1x 78x 77x 77x 77x 77x 77x 77x 1x | /** * @file MFKDF Stack Factor Setup * @copyright Multifactor, Inc. 2022–2025 * * @description * Setup key stacking factor for multi-factor key derivation * * @author Vivek Nair (https://nair.me) <[email protected]> */ const defaults = require('../../defaults') const setupKey = require('../key').key /** * Setup an MFKDF stacked key factor * * @example * // setup key with stack factor * const setup = await mfkdf.setup.key([ * await mfkdf.setup.factors.stack([ * await mfkdf.setup.factors.password('password1', { * id: 'password1' * }), * await mfkdf.setup.factors.password('password2', { * id: 'password2' * }) * ]), * await mfkdf.setup.factors.password('password3', { id: 'password3' }) * ]) * * // derive key with stack factor * const derive = await mfkdf.derive.key(setup.policy, { * stack: mfkdf.derive.factors.stack({ * password1: mfkdf.derive.factors.password('password1'), * password2: mfkdf.derive.factors.password('password2') * }), * password3: mfkdf.derive.factors.password('password3') * }) * * setup.key.toString('hex') // -> 01d0…2516 * derive.key.toString('hex') // -> 01d0…2516 * * @param {Array.<MFKDFFactor>} factors - Array of factors used to derive this key * @param {Object} [options] - Configuration options * @param {string} [options.id='stack'] - Unique identifier for this factor * @param {number} [options.threshold] - Number of factors required to derive key; factors.length by default (all required) * @param {Buffer} [options.salt] - Cryptographic salt; generated via secure PRG by default (recommended) * @returns {MFKDFFactor} MFKDF factor information * @author Vivek Nair (https://nair.me) <[email protected]> * @since 0.15.0 * @async * @memberof setup.factors */ async function stack (factors, options) { options = Object.assign(Object.assign({}, defaults.stack), options) if (typeof options.id !== 'string') { throw new TypeError('id must be a string') } if (options.id.length === 0) throw new RangeError('id cannot be empty') options.stack = true options.integrity = false const key = await setupKey(factors, options) return { type: 'stack', id: options.id, entropy: key.entropyBits.real, data: key.key, params: async () => { return key.policy }, output: async () => { return key } } } module.exports.stack = stack |