-
Notifications
You must be signed in to change notification settings - Fork 15
fix(open from existing): create encrypted core from unencrypted core #104
fix(open from existing): create encrypted core from unencrypted core #104
Conversation
dedf073
to
31605ad
Compare
@nazeh hmm somehow this got a ton of unrelated changes bundled into it |
same logic in core.session() added to core._openFromExisting with one difference; new core will override existing.encryption Closes hypercore-protocol/corestore-next#17
31605ad
to
165fdc8
Compare
@mafintosh My bad, solved now. The function is not simplified as you suggested, but close enough |
…ore-next into encrypted-from-existing
df1e2d0
to
2b66115
Compare
if (!opts.encryptionKey) return | ||
// Only override the block encryption if its either not already set or if | ||
// the caller provided a different key. | ||
if (!core.encryption || !b4a.equals(core.encryption.key, opts.encryptionKey)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kasperisager is there actually ever a case where core.encryption is not set here? this is a freshly minted session no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case should be if the root session is unencrypted, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but core is always the session isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the core variable here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, and only the root session initializes block encryption. From there it's passed to other sessions. If the root session is unencrypted, session.encryption
will be null
, in this case core.encryption
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything I need to do here?
…ore-next into encrypted-from-existing
…104) same logic in core.session() added to core._openFromExisting with one difference; new core will override existing.encryption Closes hypercore-protocol/corestore-next#17
same logic in core.session() added to core._openFromExisting with one
difference; new core will override existing.encryption
Allows hypercore-protocol/corestore-next#17 to pass