npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cloakedxyz/clkd-stealth

v1.0.4

Published

Core stealth address tools for Cloaked

Readme

⚠️ Development Status

This library is currently under active development and is not yet ready for production use. The API and implementation are subject to change as we continue to refine and test the cryptographic primitives. A stable release will be available soon. Please check back for updates or monitor the repository for release announcements.

clkd-stealth

A TypeScript library providing cryptographic primitives for deriving spending and viewing keys from signatures, generating stealth addresses, and managing hierarchical deterministic (HD) key derivations.

Installation

npm install @cloakedxyz/clkd-stealth
# or
pnpm add @cloakedxyz/clkd-stealth
# or
yarn add @cloakedxyz/clkd-stealth

Architecture

sequenceDiagram
    title Cloaked

    actor Alice
    actor Bob
    participant Client
    participant Server
    participant PortoRPC as "Porto RPC"
    participant Blockchain

    Note over Client: Sign-In derivation (p_spend, p_view, P_spend, P_view, child_p_view)

    Client ->> Server: (P_view, P_spend, child_p_view)
    Note over Server: Receive client keys

    Note over Server: Server-side stealth address generation

    Alice ->> Blockchain: Send 1 ETH to a_stealth
    Client ->> Server: Request to send 1 ETH

    Note over Server: Stealth address selection

    Server ->> Client: {(a_stealth, index)}

    Client ->> PortoRPC: RelayActions.prepareUpgradeAccount(a_stealth)
    PortoRPC ->> Client: upgradeRequest

    Note over Client: Upgrade authorization (derive p_stealth & sign auth/exec)

    Client ->> PortoRPC: RelayActions.prepareCalls(a_stealth, to, amount, data)
    PortoRPC ->> Client: paymentRequest

    Note over Client: Payment authorization (sign payment digest)

    Client ->> Server: authSig, execSig, paymentSig, upgradeRequest, paymentRequest

    Server ->> PortoRPC: RelayActions.upgradeAccount(upgradeRequest, authSig, execSig)
    Note over PortoRPC: Lazy deployment (store & activate 7702 delegation)

    Server ->> PortoRPC: RelayActions.sendPrepareCalls(paymentRequest, paymentSig)

    PortoRPC ->> Blockchain: Submit 7702 delegation + payment
    PortoRPC ->> Server: id

    Blockchain ->> Bob: 1 ETH

    Server ->> PortoRPC: RelayActions.getCallsStatus(id)
    PortoRPC ->> Server: 200 status

Detailed Notes

1. Sign-In Derivation

sig       = sign(p, msgHash)

p_spend   = SHA256(first_half_sig)
p_view    = SHA256(second_half_sig)

P_spend   = toPubKey(p_spend)
P_view    = toPubKey(p_view)

master_p_view = bip32.fromMasterSeed(p_view)
child_p_view  = bip32.ckd(master_p_view, "m/5564'/0'")

Security Note: Client sends only child_p_view, not p_view, to protect the full viewing key from the server.


2. Server-Side Stealth Address Generation

coin_type = ensip11(chainId)
c0 = coin_type.firstHalf
c1 = coin_type.secondHalf
if nonce > 0xfffffff:
    parent_nonce = nonce / (0xfffffff + 1)
    nonce        = nonce % (0xfffffff + 1)
else:
    parent_nonce = 0
index = "m/c0'/c1'/0'/parent_nonce'/nonce'"
p_derived = bip32.ckd(child_p_view, index)
S         = p_derived * P_spend  // ECDH shared secret
r         = keccak(S)
P_stealth = P_spend * r
a_stealth = addr(P_stealth)      // EOA address

Note: p_derived replaces the random p_ephemeral in EIP-5564, making stealth addresses deterministic and recoverable.


3. Stealth Address Selection

The server maintains a set of stealth addresses it generated for the user and chooses the optimal one to spend from based on deposits, balances, and gas efficiency.


4. Upgrade Authorization (Client)

p_derived = bip32.ckd(child_p_view, index)
P_derived = toPubKey(p_derived)

S         = P_derived * p_spend  // ECDH shared secret
r         = keccak(S)

p_stealth = p_spend * r
authSig = sign(p_stealth, upgradeRequest.digest.auth)
execSig = sign(p_stealth, upgradeRequest.digest.exec)

5. Payment Authorization

paymentSig = sign(p_stealth, paymentRequest.digest)

6. Lazy Deployment (Porto RPC)

Porto RPC stores ERC-7702 delegation and applies/activates it only when needed (first call requiring it).


7. Execution Flow

  1. Server sends upgrade + prepareCalls bundle.
  2. Porto RPC:
    • publishes 7702 delegation
    • deploys/upgrades account
    • executes payment
  3. Blockchain transfers 1 ETH → Bob.
  4. Server polls status until 200.

References

Standards & Specifications

Related Projects

License

MIT