Skip to content

Treat intermediate identity as identity in pubkey/privkey sums - #32

Closed
Steve0x2a wants to merge 1 commit into
BlueWallet:masterfrom
Steve0x2a:fix/sum-identity-order
Closed

Steve0x2a wants to merge 1 commit into
BlueWallet:masterfrom
Steve0x2a:fix/sum-identity-order

Conversation

@Steve0x2a

Copy link
Copy Markdown
Contributor

Treat intermediate identity as identity in pubkey and privkey sums.
Reported by @shuv-amp.
Fixes #30

sumPubKeys and _sumPrivkeys aborted as soon as an intermediate sum was the ECC identity.
Continue through intermediate identity; only fail if the final sum is identity.

Test plan

  • New unit test for both key orders using reporter scalars
  • Existing BIP-352 sending vectors stay green

sumPubKeys and _sumPrivkeys aborted as soon as tiny-secp256k1 returned
null for the point at infinity / zero scalar, so [A, -A, A] failed while
[A, A, -A] succeeded. Continue through intermediate identity and only
fail if the final sum is identity.

Fixes BlueWallet#30

@GladosBlueWallet GladosBlueWallet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugfix PR for #30: intermediate ECC identity was aborting sumPubKeys/_sumPrivkeys early. Core scalar/point logic looks sound for compressed keys, but the test chamber is half-built — _sumPrivkeys/createTransaction and final-zero edges are untested, and the infinity-resume path still faceplants on x-only successors.

console.log("1000 tweak mults took", (end - start) / 1000, "sec");
});

it("sumPubKeys is order-independent when an intermediate sum is the point at infinity", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Your test plan promised both key orders for pubkey and privkey sums. I only see sumPubKeys. _sumPrivkeys and the createTransaction [A,-A,A] failure from #30 remain unobserved — excellent science, if you enjoy not knowing whether half the fix works.

console.log("1000 tweak mults took", (end - start) / 1000, "sec");
});

it("sumPubKeys is order-independent when an intermediate sum is the point at infinity", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] You patched the 'stop at intermediate zero' bug but never verify the actual failure boundary: [A,-A] must stay null, and three keys that fully cancel must still throw in _sumPrivkeys. Edge cases are the whole experiment; skipping them is how subjects lie about passing.

Comment thread src/index.ts
let atIdentity = false;
for (let i = 1; i < pubkeys.length; i++) {
if (atIdentity) {
result = pubkeys[i];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] After infinity you blindly adopt the next pubkey as result. getPubkeysFromTransactionInputs feeds x-only 32-byte keys; the very next pointAdd at 321 demands compressed/uncompressed and throws. Compressed cancel-then-x-only still detonates — you fixed one ordering trap and left a mixed-encoding trapdoor.

@Overtorment Overtorment left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i think its mergeable as is, but let me know if you want to address glados remarks

@Overtorment

Copy link
Copy Markdown
Member

merged in #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sumPubKeys is order-dependent when an intermediate sum hits infinity

3 participants