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

Strongly typed crypto proposal #294

Merged
merged 7 commits into from
Feb 27, 2024

Conversation

hardsetting
Copy link
Contributor

Simplified and cleaned up #147

Notably, I rolled back renaming the Account class into Signer to avoid a breaking change and following some naming discussions.

Will add a better description in the AM.

@hardsetting hardsetting self-assigned this Feb 16, 2024
@hardsetting hardsetting requested a review from a team as a code owner February 16, 2024 11:01
Copy link
Collaborator

@0xmaayan 0xmaayan left a comment

Choose a reason for hiding this comment

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

Very nice!

CHANGELOG updates is missing

tests/e2e/api/account.test.ts Outdated Show resolved Hide resolved
tests/e2e/transaction/helper.ts Outdated Show resolved Hide resolved
src/core/account/account.ts Outdated Show resolved Hide resolved
src/core/account/account.ts Outdated Show resolved Hide resolved
src/core/account/singleKey.ts Outdated Show resolved Hide resolved
src/core/crypto/multiEd25519.ts Show resolved Hide resolved
src/core/crypto/multiKey.ts Show resolved Hide resolved
src/transactions/transactionBuilder/transactionBuilder.ts Outdated Show resolved Hide resolved
src/transactions/transactionBuilder/transactionBuilder.ts Outdated Show resolved Hide resolved
src/transactions/types.ts Outdated Show resolved Hide resolved
@hardsetting hardsetting force-pushed the gabriele/strongly-typed-crypto-account branch from 583b038 to f8c3caf Compare February 16, 2024 19:48
@hardsetting hardsetting force-pushed the gabriele/strongly-typed-crypto-account branch 6 times, most recently from ad77ec3 to ededd97 Compare February 22, 2024 19:20
Copy link
Contributor

@hariria hariria left a comment

Choose a reason for hiding this comment

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

I think the naming of some of the types are a bit confusing. Some may have been there from before this PR, but it would be great to clarify them if possible.

src/core/account/account.ts Outdated Show resolved Hide resolved
src/core/account/account.ts Outdated Show resolved Hide resolved
src/core/crypto/publicKey.ts Outdated Show resolved Hide resolved
src/core/crypto/signature.ts Outdated Show resolved Hide resolved
src/core/crypto/signature.ts Outdated Show resolved Hide resolved
src/core/crypto/multiEd25519.ts Outdated Show resolved Hide resolved
src/core/crypto/multiKey.ts Outdated Show resolved Hide resolved
src/core/crypto/singleKey.ts Outdated Show resolved Hide resolved
src/core/authenticationKey.ts Show resolved Hide resolved
.eslintrc.js Show resolved Hide resolved
*
* Note: Generating a signer instance does not create the account on-chain.
*/
export class Ed25519Account implements Account {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is representation of the "legacy" ed25519 right? I wonder if we should mention it and encourage using the new single key scheme

Copy link
Contributor Author

@hardsetting hardsetting Feb 26, 2024

Choose a reason for hiding this comment

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

Honestly, the more I think of it, the more I think we should just always use the "legacy" ed25519 and possibly even discourage using the ed25519 variant of the single key authentication scheme.

We have to keep the legacy authentication scheme forever anyway. And if that's the case why should we over-complicate things and have two types of Ed25519 accounts around that can cause confusion and bugs.

Or maybe not? And maybe we can drop support in a year or two, and push users to rotate their authentication key.
And then we remove the code that handles the legacy authentication schemes..

I personally don't know what is the right call and I'm open to any of the solutions.
But the "laziest" for everyone would be what I proposed, where the only downside is to have to keep around the legacy authentication keys and authenticators.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this is an implementation decision question and @davidiw can help with it.

I assume we eventually would want to support by default single key scheme, for future new authentication schemes also.

Also, if aptos-core supports both schemes, I think the sdk should probably support it also. We already need to support single key scheme for secp and probably some in the future so why not support all single key schemes?

src/core/crypto/singleKey.ts Show resolved Hide resolved
src/core/account/singleKey.ts Outdated Show resolved Hide resolved
src/core/crypto/singleKey.ts Outdated Show resolved Hide resolved
src/core/crypto/singleKey.ts Outdated Show resolved Hide resolved
src/types/index.ts Outdated Show resolved Hide resolved
*
* Note: Generating an account instance does not create the account on-chain.
*/
export abstract class Account {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As part of the new wallet standard, we had the AccountInfo interface to hold an account of type Account

export interface AccountInfo = { account: Account, ansName?: string }

this was mostly done so it would be easier for us to resolve the account type (single signer/ multi signer) using the variant field - was this changed with this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, where did AptosAccountVariant enum go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got some feedback regarding having both Signer and Account from @heliuchuan .
The argument is that it would be a breaking change, and the Signer name wouldn't be as intuitive.

So in this PR we only have Account and it has signing capabilities.
I think that for AccountInfo we can have the following struct, which would be functionally equivalent and similar to what we had before:

export interface AccountInfo = { address: AccountAddress, publicKey: AccountPublicKey, ansName?: string }

would also be nice to make it BCS serializable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's update the standard AIP then. The AIP currently relies on that change we planned to have

@hardsetting hardsetting force-pushed the gabriele/strongly-typed-crypto-account branch 2 times, most recently from 9639916 to 46bff83 Compare February 26, 2024 22:34
@0xmaayan
Copy link
Collaborator

0xmaayan commented Feb 26, 2024

@hardsetting once it lands, we might need to update the docs on aptos.dev if there is anything specific to call out

@hardsetting hardsetting force-pushed the gabriele/strongly-typed-crypto-account branch 2 times, most recently from b9828a4 to 117c3c7 Compare February 27, 2024 00:56
@hardsetting
Copy link
Contributor Author

once it lands, we might need to update the docs on aptos.dev if there is anything specific to call out

there's no breaking change at this point

@hardsetting
Copy link
Contributor Author

Gathered all the feedback, and just rolled back more changes from the original PR.
The only notable change in this PR is now just splitting the monolithic Account class into abstract class + implementations

Copy link
Contributor

@hariria hariria left a comment

Choose a reason for hiding this comment

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

LGTM pending Oliver's feedback

Copy link
Collaborator

@0xmaayan 0xmaayan left a comment

Choose a reason for hiding this comment

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

LGTM!

src/core/account/Account.ts Show resolved Hide resolved
src/core/account/Account.ts Show resolved Hide resolved
src/core/account/Account.ts Show resolved Hide resolved
src/core/crypto/multiKey.ts Outdated Show resolved Hide resolved
src/core/account/Account.ts Show resolved Hide resolved
@hardsetting hardsetting force-pushed the gabriele/strongly-typed-crypto-account branch from 117c3c7 to bb8d2e7 Compare February 27, 2024 21:36
@heliuchuan heliuchuan enabled auto-merge (squash) February 27, 2024 21:39
@0xaptosj 0xaptosj mentioned this pull request Feb 27, 2024
@heliuchuan heliuchuan merged commit 9bf8d28 into main Feb 27, 2024
12 checks passed
@heliuchuan heliuchuan deleted the gabriele/strongly-typed-crypto-account branch February 27, 2024 21:43
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.

4 participants