-
Notifications
You must be signed in to change notification settings - Fork 82
[refactor] Split keyless #807
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
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.
Pull request overview
This pull request refactors the SDK to split keyless authentication into separate entry points, enabling better tree-shaking and significantly reducing bundle size for applications that don't need keyless features. The main SDK bundle is reduced from ~910KB to ~102KB (89% reduction) for the lite entry point.
Key changes:
- Created new entry points:
@aptos-labs/ts-sdk/lite(without keyless) and@aptos-labs/ts-sdk/keyless(keyless-only) - Made
EphemeralKeyPair.generate()async to support lazy loading of poseidon constants - Implemented lazy loading for poseidon-lite constants (~600KB) via dynamic imports
- Added lazy initialization for Aptos class API namespaces
- Refactored imports to use specific paths instead of barrel imports
- Created a registry pattern for optional crypto types (keyless)
Reviewed changes
Copilot reviewed 88 out of 100 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lite/index.ts | New lite SDK entry point without keyless authentication |
| src/keyless/index.ts | New keyless-only entry point |
| src/core/crypto/poseidon.ts | Lazy loading implementation for poseidon constants |
| src/core/crypto/anyKeyRegistry.ts | Registry pattern for optional crypto types |
| src/core/crypto/keylessRegistry.ts | Keyless type registration |
| src/core/crypto/singleKey.ts | Updated to use registry for keyless types |
| src/api/aptos.ts | Lazy initialization of API namespaces |
| package.json | Added new entry points and sideEffects: false |
| tsup.config.ts | Build configuration for new entry points |
| src/account/EphemeralKeyPair.ts | Made generate() async |
| examples/typescript/* | New examples for lite, keyless, and full SDK |
| Multiple import refactoring | Changed imports to specific paths |
| Formatting changes | Prettier formatting updates across config files |
Files not reviewed (2)
- examples/javascript/pnpm-lock.yaml: Language not supported
- examples/typescript/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Ed25519PrivateKey, | ||
| AccountAddress, | ||
| // Keyless-specific imports (only available in full SDK) | ||
| EphemeralKeyPair, | ||
| KeylessAccount, |
Copilot
AI
Jan 4, 2026
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.
Unused imports AccountAddress, Ed25519PrivateKey, KeylessAccount.
| Ed25519PrivateKey, | |
| AccountAddress, | |
| // Keyless-specific imports (only available in full SDK) | |
| EphemeralKeyPair, | |
| KeylessAccount, | |
| // Keyless-specific imports (only available in full SDK) | |
| EphemeralKeyPair, |
| import { | ||
| // Keyless public keys | ||
| KeylessPublicKey, | ||
| FederatedKeylessPublicKey, | ||
|
|
||
| // Ephemeral key management | ||
| EphemeralKeyPair, | ||
| EphemeralPublicKey, | ||
| EphemeralSignature, | ||
|
|
||
| // Keyless accounts | ||
| KeylessAccount, | ||
| FederatedKeylessAccount, | ||
| AbstractKeylessAccount, | ||
|
|
||
| // Keyless API | ||
| Keyless, | ||
|
|
||
| // ZK proof types | ||
| Groth16Zkp, | ||
| ZeroKnowledgeSig, | ||
| ZkProof, | ||
| Proof, | ||
|
|
||
| // Poseidon hashing (for advanced use) | ||
| poseidonHash, | ||
| hashStrToField, | ||
| ensurePoseidonLoaded, | ||
|
|
||
| // Configuration | ||
| KeylessConfiguration, | ||
| getKeylessConfig, | ||
| EPK_HORIZON_SECS, | ||
|
|
||
| // Signature verification | ||
| verifyKeylessSignature, | ||
| verifyKeylessSignatureWithJwkAndConfig, | ||
|
|
||
| // Types | ||
| type ProofFetchCallback, | ||
| type ProofFetchStatus, | ||
| } from "@aptos-labs/ts-sdk/keyless"; |
Copilot
AI
Jan 4, 2026
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.
Unused imports AbstractKeylessAccount, EphemeralPublicKey, EphemeralSignature, FederatedKeylessAccount, FederatedKeylessPublicKey, Groth16Zkp, Keyless, KeylessAccount, KeylessConfiguration, KeylessPublicKey, Proof, ZeroKnowledgeSig, ZkProof, getKeylessConfig, hashStrToField, verifyKeylessSignature, verifyKeylessSignatureWithJwkAndConfig.
| import { | ||
| // Core types | ||
| AccountAddress, | ||
| Hex, | ||
| AuthenticationKey, | ||
|
|
||
| // Cryptographic primitives | ||
| Ed25519PrivateKey, | ||
| Ed25519PublicKey, | ||
| Ed25519Signature, | ||
| Secp256k1PrivateKey, | ||
| Secp256k1PublicKey, | ||
| AnyPublicKey, | ||
| AnySignature, | ||
|
|
||
| // BCS serialization | ||
| Serializer, | ||
| Deserializer, | ||
| MoveVector, | ||
| U64, | ||
| U8, | ||
| Bool, | ||
|
|
||
| // Network configuration | ||
| Network, | ||
| NetworkToNodeAPI, | ||
| APTOS_COIN, | ||
| } from "@aptos-labs/ts-sdk/lite"; |
Copilot
AI
Jan 4, 2026
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.
Unused imports AnySignature, Bool, Ed25519PublicKey, Ed25519Signature, Hex, MoveVector, Secp256k1PublicKey, U64, U8.
| import { AccountAddressInput, AccountPublicKey, AuthenticationKey, Ed25519PrivateKey } from "../core"; | ||
| import type { AccountAddressInput } from "../core/accountAddress"; | ||
| import { AccountPublicKey } from "../core/crypto/publicKey"; | ||
| import { AuthenticationKey } from "../core/authenticationKey"; |
Copilot
AI
Jan 4, 2026
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.
Unused import AuthenticationKey.
| import { MoveVector, Serialized } from "../../bcs/serializable/moveStructs"; | ||
| import { AccountAddress, Hex } from "../../core"; | ||
| import { AccountAddress } from "../../core/accountAddress"; | ||
| import { Hex } from "../../core/hex"; |
Copilot
AI
Jan 4, 2026
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.
Unused import Hex.
Description
This should reduce the bundle size significantly when keyless is not needed.
This has been requested often.
Test Plan
Related Links
Checklist
pnpm fmt?CHANGELOG.md?