Skip to content
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

NativeScript signing #1599

Merged

Conversation

Riley-Kilgore
Copy link
Member

Context

Lace currently fails to identify when it is being requested to sign a transaction on behalf of a NativeScript where it's signature may be one of the signatures required by that NativeScript.

Proposed Solution

Evaluate NativeScript(s) used as witnesses to determine keypaths which must be used to sign (if any).

Important Changes Introduced

Added the capability described above to enhance Lace's functionality with CIP-30 dApps that leverage NativeScripts.

@rhyslbw
Copy link
Member

rhyslbw commented Feb 14, 2025

Thanks for submitting this @Riley-Kilgore. @AngelCastilloB, who is the best candidate for review, will be back on Monday. In the mean-time, would you mind re-working your commits to follow Conventional Commits? This product has an automatic release process that requires formatting in this way to generate the changelog. Sorry, we're missing a contributor guide

Copy link
Member

@AngelCastilloB AngelCastilloB left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Riley-Kilgore ❤️ . I made a small change request, additionally, for this change to be effective we need to:

add a new property here:

https://github.com/input-output-hk/cardano-js-sdk/blob/master/packages/key-management/src/types.ts#L166-L170

probably 'scripts' ?,

Then we need to use that new property to pass into ownSignatureKeyPaths in this two places:

const signatureKeyPaths = uniqWith(
[...ownSignatureKeyPaths(txBody, knownAddresses, txInKeyPathMap, dRepKeyHash), ...additionalKeyPaths],
deepEquals

const derivationPaths = ownSignatureKeyPaths(body, knownAddresses, txInKeyPathMap, dRepKeyHash);

Additionally would be great to add some unit test to the change to ownSignatureKeyPaths here:

util.ownSignatureKeyPaths(txBody, knownAddresses, {

As a side note, this will only enable signing transactions with native scripts with in-memory wallets. For hardware wallets, we need to somehow tell the devices to sign with these keys found on the scripts (currently they only parse the body data), I think they allow to specify additional key paths for signing as options, but I am not sure, we need to check. There is a workaround for this, and is to add the key hashes present on the scripts on the DApp side to the requieredExtraSigners field in the transaction body:

https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/conway.cddl#L531

@Riley-Kilgore Riley-Kilgore force-pushed the fix/nativescript-signing branch 4 times, most recently from 6c37f72 to 8a7a723 Compare February 19, 2025 05:47
Copy link
Member

@AngelCastilloB AngelCastilloB left a comment

Choose a reason for hiding this comment

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

LGTM @Riley-Kilgore , thanks for the contribution. adding @mkazlauskas and @mirceahasegan for review

Copy link
Member

@mkazlauskas mkazlauskas left a comment

Choose a reason for hiding this comment

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

Thanks for contribution! ❤️

@Riley-Kilgore Riley-Kilgore force-pushed the fix/nativescript-signing branch from 8a7a723 to 85befa6 Compare February 24, 2025 15:21
@Riley-Kilgore Riley-Kilgore force-pushed the fix/nativescript-signing branch from 85befa6 to 255d0d5 Compare February 24, 2025 15:25
Copy link
Contributor

@mirceahasegan mirceahasegan left a comment

Choose a reason for hiding this comment

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

Fantastic work @Riley-Kilgore 👏 . Thank you

@AngelCastilloB AngelCastilloB merged commit d3f03b2 into input-output-hk:master Feb 24, 2025
9 checks passed
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.

5 participants