Skip to content

Add HDKeyOrigin and SIngleKeyOrigin for Signer#107

Open
ikripaka wants to merge 6 commits into
masterfrom
feat/singer-key-origin
Open

Add HDKeyOrigin and SIngleKeyOrigin for Signer#107
ikripaka wants to merge 6 commits into
masterfrom
feat/singer-key-origin

Conversation

@ikripaka

@ikripaka ikripaka commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator
  • This PR suggests a bug fix and I've added the necessary tests.
  • This PR introduces a new feature and I've discussed the update in an Issue or with the team.
  • This PR is just a minor change like a typo fix.

Add the KeyOrigin trait to move the logic for determining keys into a separate entity

  • add HDKey and SingleKey
  • implement the KeyOrigin trait for them and adapt tests

…parate entity

* add HDKeyOrigin and SingleKeyOrigin
* impement KeyProvider trait for them and adapt tests
@ikripaka ikripaka force-pushed the feat/singer-key-origin branch from 789c518 to de219be Compare July 1, 2026 11:14
Comment thread crates/sdk/src/provider/network.rs Outdated
Comment thread crates/sdk/src/signer/core.rs Outdated
Comment thread crates/sdk/src/signer/core.rs Outdated
rename:
* KeyProvider - KeyOrigin
* HDKeyOrigin - HDKey
* SingleKeyOrigin - SingleKey
remove network conversion to bitcoin type
@ikripaka ikripaka marked this pull request as ready for review July 1, 2026 15:02
* inline HDKey initialization in tests
Comment thread crates/sdk/src/signer/key_origin.rs
Comment thread crates/sdk/src/signer/key_origin.rs Outdated
fn get_blinding_private_key(&self, secp: &Secp256k1<All>, network: &SimplicityNetwork) -> PrivateKey {
let master_blinding = self
.blinding_key
.expect("Blinding key is required for confidential operations");

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.

How will this work with the unblinding logic? We can skip the unblinding (move the unblind function from the Signer to KeyOrigin). Maybe there is a better solution.

@ikripaka ikripaka Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Based on rust-elements, I could only find 1 function where we need to insert
blinding_key: SecretKey
link

Since both objects would have the same unblinding implementation anyway, it might be best to keep the current setup for now.

https://docs.rs/elements/latest/elements/?search=unblind

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed the interface a little bit, now we'd throw an error if something fails in unblinding.
Move code and improve the interface of KeyOrigin and Signer.
Improve the implementation and the interface of get_utxos_filter().

Test the implementation with Lending. To migrate it to our code version, we need to handle an error from get_blinding_public_key and remove & before the closure when we pass it into the UTXO filtering function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

before:

let matching_utxos = context.signer.get_utxos_filter(
            &|utxo| utxo.outpoint == reissuance_outpoint,
            &|utxo| utxo.outpoint == reissuance_outpoint,
        )?;

now:

let matching_utxos = context.signer.get_utxos_filter(
            |utxo| utxo.outpoint == reissuance_outpoint,
            |utxo| utxo.outpoint == reissuance_outpoint,
        )?;

And get_blinding_public_key, get_blinding_private_key, get_confidential_address now return errors.

ikripaka added 3 commits July 2, 2026 14:46
* improve allocations in get_utxos_filter
* remove &dyn in Fn closure passing
* return SignerTrait implementation
Base automatically changed from dev to master July 6, 2026 12:52
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.

2 participants