diff --git a/test/oplog/log.test.js b/test/oplog/log.test.js index 5adf757..d3bd3eb 100644 --- a/test/oplog/log.test.js +++ b/test/oplog/log.test.js @@ -145,8 +145,13 @@ describe('Log', function () { }) it('encrypts the value of an entry in the log', async () => { - const encryptFn = encrypt({ identity: testIdentity }) - const decryptFn = decrypt({ identities, identity: testIdentity }) + const keys = await keystore.createKey('hello1') + + const privateKey = await keystore.getKey('hello1') + const publicKey = await keystore.getPublic(keys) + + const encryptFn = encrypt({ publicKey }) + const decryptFn = decrypt({ privateKey }) const log = await Log(testIdentity, { encryptFn, decryptFn }) const entry = await log.append('hello1') const value = await log.get(entry.hash) diff --git a/test/utils/encrypt.js b/test/utils/encrypt.js index fe72bee..feef7a8 100644 --- a/test/utils/encrypt.js +++ b/test/utils/encrypt.js @@ -1,13 +1,12 @@ import EthCrypto from 'eth-crypto' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' -const encrypt = ({ identity }) => async (value) => { - const encryptedObj = await EthCrypto.encryptWithPublicKey(identity.publicKey, value) +const encrypt = ({ publicKey }) => async (value) => { + const encryptedObj = await EthCrypto.encryptWithPublicKey(publicKey, value) return EthCrypto.cipher.stringify(encryptedObj) } -const decrypt = ({ identities, identity }) => async (value) => { - const privateKey = await identities.keystore.getKey(identity.id) +const decrypt = ({ privateKey }) => async (value) => { const privateKeyStr = uint8ArrayToString(privateKey.marshal(), 'base16') const encryptedObj = EthCrypto.cipher.parse(value)