import { CryptoEffects , ECDSA_KEY_PARAMS , ExportedKeyPair , SIGN_AND_VERIFY , stringToArrayBuffer , } from '../common' ; import { exportKeyPair } from '../effects/exportKeyPair' ; import { generateKey } from '../effects/subtle' ; /**
 * Generates an exported key pair. WARNING :: be very careful about what you do with this KeyPair. We highly
 * recommend encrypting them with another CryptoKey that never leaves memory and can be derived by user-supplied info.
 */ export function * generateEcdsaExportedKeys ( ) { const exportableKey = yield * generateKey ( ECDSA_KEY_PARAMS , true , SIGN_AND_VERIFY ) ; const jsonWebKeyPair = yield * exportKeyPair ( exportableKey ) ; return { privateKey : stringToArrayBuffer ( JSON . stringify ( jsonWebKeyPair . privateKey ) ) , publicKey : stringToArrayBuffer ( JSON . stringify ( jsonWebKeyPair . publicKey ) ) , } ; }