Skip to content

Conversation

@gregnazario
Copy link
Collaborator

Description

This should reduce the bundle size significantly when keyless is not needed.

This has been requested often.

Test Plan

Related Links

Checklist

  • Have you ran pnpm fmt?
  • Have you updated the CHANGELOG.md?

@gregnazario gregnazario requested a review from a team as a code owner January 4, 2026 18:34
@gregnazario gregnazario requested review from Copilot and removed request for a team January 4, 2026 18:41
Copy link

Copilot AI left a 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.

Comment on lines 20 to 24
Ed25519PrivateKey,
AccountAddress,
// Keyless-specific imports (only available in full SDK)
EphemeralKeyPair,
KeylessAccount,
Copy link

Copilot AI Jan 4, 2026

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.

Suggested change
Ed25519PrivateKey,
AccountAddress,
// Keyless-specific imports (only available in full SDK)
EphemeralKeyPair,
KeylessAccount,
// Keyless-specific imports (only available in full SDK)
EphemeralKeyPair,

Copilot uses AI. Check for mistakes.
Comment on lines 20 to 61
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";
Copy link

Copilot AI Jan 4, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines 17 to 44
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";
Copy link

Copilot AI Jan 4, 2026

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.

Copilot uses AI. Check for mistakes.
import { AccountAddressInput, AccountPublicKey, AuthenticationKey, Ed25519PrivateKey } from "../core";
import type { AccountAddressInput } from "../core/accountAddress";
import { AccountPublicKey } from "../core/crypto/publicKey";
import { AuthenticationKey } from "../core/authenticationKey";
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

Unused import AuthenticationKey.

Copilot uses AI. Check for mistakes.
import { MoveVector, Serialized } from "../../bcs/serializable/moveStructs";
import { AccountAddress, Hex } from "../../core";
import { AccountAddress } from "../../core/accountAddress";
import { Hex } from "../../core/hex";
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

Unused import Hex.

Copilot uses AI. Check for mistakes.
@gregnazario gregnazario requested a review from WGB5445 January 5, 2026 13:12
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