Constellation Network
IntroductionFundamentalsFor DevelopersNode Validators
  • Index
  • Concepts
    • Architecture
  • IntegrationNet
  • API Reference
    • DAG4.js
      • Intro to dag4.js
      • Interacting with Wallets
      • Connecting to the Network
      • Sending Transactions
      • Message Signing
      • Metagraph Tokens
      • Dag4.js Example Apps
    • Hypergraph APIs
  • Metagraph APIs
  • Block Explorer APIs
  • Integration Guides
    • Transaction Signing
    • Delegated Staking
Powered by GitBook

Main

  • Website
  • Get DAG
  • Explore Projects
  • Partners

Socials

  • Telegram
  • Discord
  • X (Twitter)

Tools

  • Wallet
  • DAG Explorer
  • Coingecko

© 2025 CONSTELLATION NETWORK

On this page

Was this helpful?

Export as PDF
  1. API Reference
  2. DAG4.js

Message Signing

PreviousSending TransactionsNextMetagraph Tokens

Last updated 1 month ago

Was this helpful?

Sign an arbitrary message

The dag4-keystore package can be used to sign messages using a private key. Messages are signed using secp256k1 which generates a deterministic and canonical ECDSA signature that can be verified with a public key. This example code is not intended to be used to sign transactions.

const privKey = dag4.keyStore.generatePrivateKey();
const pubKey = dag4.keyStore.getPublicKeyFromPrivate(privateKey);

const signature = await dag4.keyStore.sign(privKey, message);

const verified = dag4.keyStore.verify(pubKey, message, signature);

if (verified) {
  console.log('Signature verified');
} else {
  console.log('Signature invalid');
}
​