-
Notifications
You must be signed in to change notification settings - Fork 109
xpubcache: allow choosing if xpub computation should be repeated #1536
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
base: master
Are you sure you want to change the base?
Conversation
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.
utACK, with a small suggestion
|
||
/// Derives an xpub from the root xpub using the provided keypath. | ||
fn from_keypath(keypath: &[u32]) -> Result<Self, ()>; | ||
fn from_keypath(keypath: &[u32], compute: Compute) -> Result<Self, ()>; | ||
} | ||
|
||
/// Implements a cache for xpubs. Cached intermediate xpubs are used to derive child xpubs. |
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.
Unrelated to the change, but I think that the cache_keypath()
in the comment should be changed to add_keypath()
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.
Added separate commit.
@@ -17,12 +17,18 @@ use super::keystore; | |||
use crate::bip32; | |||
use alloc::vec::Vec; | |||
|
|||
#[derive(Copy, Clone)] | |||
pub enum Compute { |
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.
nit: Maybe it could be useful to add a comment here (or somewhere else) explaining that this is used as an additional bitflips check for sensitive operations
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.
Added comments.
End-goal: reduce the number of secure chip ops when signing a BTC transaction, to reduce the chance of going over the Optiga chip's "rate limit", which induces throttling. By default keystore::get_xpub computed the xpub twice, to mitigate potential bitflips, which could be bad when delivering the wrong xpub (or derivatives) to the host. When signing a transaction however, one does not need the extra protection - if there is a bit flip, the resulting signature will be invalid. This commit reduces the number of secure chip ops needed when the bitflip mitigation is not required. The existing method `get_xpub` was renamed so the compiler can tell us all the instances where we need to decide between one or the other.
End-goal: reduce the number of secure chip ops when signing a BTC transaction, to reduce the chance of going over the Optiga chip's "rate limit", which induces throttling.
By default keystore::get_xpub computed the xpub twice, to mitigate potential bitflips, which could be bad when delivering the wrong xpub (or derivatives) to the host.
When signing a transaction however, one does not need the extra protection - if there is a bit flip, the resulting signature will be invalid.
This commit reduces the number of secure chip ops needed when the bitflip mitigation is not required.
The existing method
get_xpub
was renamed so the compiler can tell us all the instances where we need to decide between one or the other.