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 | 4x 3x 3x 3x 1x | /** * @file MFKDF Persisted Factor Derivation * @copyright Multifactor 2022 All Rights Reserved * * @description * Use persisted factor for multi-factor key derivation * * @author Vivek Nair (https://nair.me) <[email protected]> */ /** * Use a persisted MFDKF factor * * @example * // setup 3-factor multi-factor derived key * const setup = await mfkdf.setup.key([ * await mfkdf.setup.factors.password('password1', { id: 'password1' }), * await mfkdf.setup.factors.password('password2', { id: 'password2' }), * await mfkdf.setup.factors.password('password3', { id: 'password3' }) * ], {size: 8}) * * // persist one of the factors * const factor2 = setup.persistFactor('password2') * * // derive key with 2 factors * const derived = await mfkdf.derive.key(setup.policy, { * password1: mfkdf.derive.factors.password('password1'), * password2: mfkdf.derive.factors.persisted(factor2), * password3: mfkdf.derive.factors.password('password3') * }) * * setup.key.toString('hex') // -> 64587f2a0e65dc3c * derived.key.toString('hex') // -> 64587f2a0e65dc3c * * @param {Buffer} share - The share corresponding to the persisted factor * @returns {function(config:Object): Promise<MFKDFFactor>} Async function to generate MFKDF factor information * @author Vivek Nair (https://nair.me) <[email protected]> * @since 0.18.0 * @memberof derive.factors */ function persisted (share) { if (!Buffer.isBuffer(share)) throw new TypeError('share must be a buffer') return async (params) => { return { type: 'persisted', data: share, params: async () => { return params } } } } module.exports.persisted = persisted |