-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor key backup recovery to prepare for rust #3708
Conversation
4e78cf3
to
4c4ab28
Compare
4c4ab28
to
641f07a
Compare
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.
Looks good, very minor questions and comments.
src/client.ts
Outdated
const algorithm = await BackupManager.makeAlgorithm(backupInfo, async () => { | ||
return privKey; | ||
}); | ||
const backupDecryptor = await this.cryptoBackend!.getBackupDecryptor(backupInfo, privKey); |
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.
How do we know that this.cryptoBackend
is defined? Can we have a comment explaining?
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.
Oh wait, I see it on line 3786. In that case, I think we shouldn't need the !
? If we do, please add a little comment saying that we bailed out earlier if we had no cryptoBackend
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.
Thx, removed
src/crypto/index.ts
Outdated
public async getBackupDecryptor(backupInfo: IKeyBackupInfo, privKey: ArrayLike<number>): Promise<BackupDecryptor> { | ||
if (!(privKey instanceof Uint8Array)) { | ||
// eslint-disable-next-line @typescript-eslint/no-base-to-string | ||
throw new Error(`getBackupDecryptor expects Uint8Array, got ${privKey}`); |
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.
Is it potentially dangerous to log the private key here? Maybe we could log its type, or omit 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.
(would also mean we could remove the eslint-disable...
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.
Right, was copied from old code but agree that it doesn't look right. Removed
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.
All good, thanks!
Introduce a new
BackupDecryptor
interface, which we can implement separately for legacy and Rust crypto.Checklist
This change is marked as an internal change (Task), so will not be included in the changelog.