-
Notifications
You must be signed in to change notification settings - Fork 56
KDF V2: Proper blinding factor reduction per NUT-13 spec #454
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: main
Are you sure you want to change the base?
Conversation
|
@callebtc - Can you rebase this to the development branch please |
|
@callebtc - this is generally an excellent idea. Previously we were leaning on noble curves to ensure It does, however, highlight the issue I raised here, where it was pointed out that BIP-32 does not appear to do modulo n on derived factors. Assuming we are committing to deviate from that and ensure legacy NUT-13 factors WILL always be mod n as per your linked PR. That leaves just NUT-26 (P2BK) as the outlier... I originally specified it as mod n, but @aidenvalue said this was problematic in CDK, so it was relaxed to a "try again if > n-1". Your PR here makes it mod n. Are we able to commit to that now in CDK? |
|
|
||
| // Core Utils | ||
| export * from './utils/core'; | ||
| export * from './utils'; |
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.
Why is this export being widened?
Personally I think for something like Cashu proofs skipping an index if it produces an invalid result is perfectly fine. That would be inline with BIP-32 Edit: On the other hand it requires counters to be adjusted somehow, which might be managed in a different layer of the app. |
Implements the correct KDF for V2 keysets (01-prefixed) as specified in the updated Keyset V2 version of NUT-13 (PR).
Changes:
Modulo optimization: A 256-bit HMAC output only needs one subtraction to be < SECP256K1_N. Full modulo is ~10-20x more expensive than a single comparison and conditional subtraction.