Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@zkred/agent-id

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zkred/agent-id

A package for zkred agent identification

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
5
-86.49%
Maintainers
3
Weekly downloads
 
Created
Source

zkred-agent-id

A package for agent identification and management.

Installation

npm install @zkred/agent-id

Usage

import zkredAgentId from "@zkred/agent-id";

// Generate a new private key
const privateKey = zkredAgentId.generatePrivateKey();

// Create an agent identity
const identity = await zkredAgentId.createIdentity(
  privateKey,
  "My Agent Description",
  80002, // Polygon Amoy testnet
  "https://my-agent-service.com"
);

API Reference

Core Functions

generateDID(ethAddress, chain, network)

Generates a Decentralized Identifier (DID) from an Ethereum address.

  • Parameters:
    • ethAddress: Ethereum address (0x-prefixed, 20 bytes)
    • chain: Chain name (e.g., "polygon", "privado")
    • network: Network name (e.g., "amoy", "main")
  • Returns: DID string in the format did:iden3:chain:network:base58Id

getETHPublicKeyFromDID(didFull)

Extracts the Ethereum public key from a DID.

  • Parameters:
    • didFull: Full DID string (e.g., "did:iden3:polygon:amoy:x6x5sor7zpyT5mmpg4fADaR47NADVbohtww4ppWZF")
  • Returns: Ethereum public key (hex) or null if not Ethereum-controlled

createIdentity(privateKey, description, chainId, serviceEndpoint, rpcUrl)

Registers an agent to the central Registry using native token payment.

  • Parameters:
    • privateKey: Private key of wallet to register
    • description: Description of the agent
    • chainId: Chain ID (80002 for Polygon Amoy, 296 for Hedera, 16602 for OG)
    • serviceEndpoint: Service endpoint URL
    • rpcUrl: (Optional) RPC URL for the chain
  • Returns: Object containing transaction hash, DID, description, service endpoint, and agent ID

validateAgent(did, chainId, rpcUrl)

Validates an agent's registration.

  • Parameters:
    • did: DID of the agent
    • chainId: Chain ID
    • rpcUrl: (Optional) RPC URL
  • Returns: Agent details including DID, agent ID, description, and service endpoint

registerAgentByUSDC(privateKey, description, chainId, serviceEndpoint, rpcUrl)

Registers an agent using USDC payment via x402 payment interceptor.

  • Parameters:
    • privateKey: Private key of wallet to register
    • description: Description of the agent
    • chainId: Chain ID
    • serviceEndpoint: Service endpoint URL
    • rpcUrl: (Optional) RPC URL
  • Returns: Promise resolving to agent details

Handshake Functions

initiateHandshake(initiatorDid, initiatorChainId, receiverDid, receiverChainId, initiatorRpcUrl, receiverRpcUrl)

Initiates a handshake between two agents.

  • Parameters:
    • initiatorDid: DID of the initiating agent
    • initiatorChainId: Chain ID of the initiator
    • receiverDid: DID of the receiving agent
    • receiverChainId: Chain ID of the receiver
    • initiatorRpcUrl: (Optional) RPC URL for initiator chain
    • receiverRpcUrl: (Optional) RPC URL for receiver chain
  • Returns: Session details including session ID, callback endpoint, and challenge

copmleteHandshake(privateKey, sessionId, receiverAgentCallbackEndPoint, challenge)

Completes a handshake by signing the challenge.

  • Parameters:
    • privateKey: Private key for signing
    • sessionId: Session ID from initiate handshake
    • receiverAgentCallbackEndPoint: Callback endpoint of receiver
    • challenge: Challenge to sign
  • Returns: Boolean indicating success

verifySignature(sessionId, challenge, signature, did)

Verifies a signature from a handshake.

  • Parameters:
    • sessionId: Session ID
    • challenge: Challenge that was signed
    • signature: Signature to verify
    • did: DID of the signer
  • Returns: Boolean indicating if signature is valid

Utility Functions

generatePrivateKey()

Generates a new random Ethereum private key.

  • Returns: Private key string

generateChallenge(length)

Generates a random challenge string for authentication.

  • Parameters:
    • length: (Optional) Length of challenge, default is 10
  • Returns: Random string

Supported Networks

  • Polygon Amoy (Chain ID: 80002)
  • Hedera (Chain ID: 296)
  • OG (Chain ID: 16602)

Keywords

zkred

FAQs

Package last updated on 27 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts