SendingNetwork
  • OVERVIEW
    • Getting Started
    • FAQs
  • Network Instructional Articles
    • Basics
      • Introducing the Edge, WatchDog, and Guardian Nodes
      • Overview
      • Messaging Solution
      • Privacy Solution
      • Rich Communication Solution
      • Multi-Platform Solution
      • Decentralized Identity
      • Multiple Chat Modes
      • How It Works
      • Token Utility
      • The Team
    • Key Concepts
      • Decentralized Identity
      • Social Graphs
      • Edge Node
  • SDK Documentation
    • Glossary
    • JavaScript client SDK
      • DID
      • User
      • Message
      • Room
      • Contact
      • Social Graph
    • iOS client SDK
      • Push
      • DID
      • User
      • Message
      • Room
      • Contact
    • Android client SDK
      • User
      • Room
    • Java SDK
      • DID
      • Room
      • Message
    • Node.js SDK
      • DID
      • Room
      • Message
    • Unreal SDK
      • DID
      • User
      • Message
      • Room
    • Unity SDK
      • DID
      • Room
      • Message
    • Website chat widget SDK
      • Customization
      • DID
      • User
      • Room
      • Message
      • Other
    • Bot SDKs
      • Golang Bot SDK
        • DID
        • User
        • Room
        • Message
    • Extensible Message Interface
    • Push Notifications
    • Flutter SDK
      • DID
      • User
      • Message
      • Room
    • PHP SDK
      • DID
      • Room
      • User
    • Developer Key
  • Acquisition Kit
    • Social Boost Development Instructions
  • WatchDog Agent
    • WatchDog Agent Guide
    • WatchDog Agent Deployment Tutorial
      • Linux Deployment Tutorial
    • One-Click Deployment
  • Edge Node
    • Edge Node Deployment Tutorial
    • VPS Setup Guide
      • Google Cloud Platform (GCP)
      • Amazon Web Services (AWS)
      • Contabo
    • Check Node Stats with Auto-Reply Bot in SendingMe App
    • Alpha-3 Testnet FAQs
  • delegation node
    • Delegation Node Deployment Tutorial
  • Private Delegation Node
  • Use Cases
    • Wallet-to-Wallet Messaging
    • Dapp Notifications
    • Identity Verification
    • Gamer Acquisition
    • Cross-platform Trading
Powered by GitBook
On this page
  • Create Developer Key
  • Use Developer Key
  • Ethereum ECDSA Signature
  • Login Flow Example
  1. SDK Documentation

Developer Key

To access SendingNetwork's developer resources, developers are kindly requested to initiate the process by requesting a developer key through email. This key is essential for unlocking access to all the Edge Network features and capabilities.

This guide shows how to create and use your Developer Key for accessing the Edge Network.

Create Developer Key

To obtain a developer key and unlock our platform's potential, please follow these steps:

  1. Send an email to developer@sending.network with the subject line: "Developer Key Request".

  2. In the email, kindly provide your name and a brief overview of your project, outlining its purpose and scope.

Our team will promptly review your request and provide you with the necessary developer key to accelerate your integration process.

Use Developer Key

SendingNetwork recommends securely storing the developer key on your self-controlled server and developing a backend API to access the server for signature retrieval during login.

Kindly establish a secure key server for the proper management of your developer key. Additionally, it is necessary to develop a backend API to receive a challenge from the client and return the Ethereum ECDSA signature from your key server. Please

The key verification process occurs during user login, and the workflow is as follows:

  1. Check existing DIDs linked to the current wallet address.

  2. Get login message using one of the DIDs or the wallet address if no DID is found.

  3. Request a message signature with the developer key.

  4. Request a message signature with the user wallet account.

  5. Login by sending both signatures to the SDN server.

Ethereum ECDSA Signature

The server uses the Ethereum ECDSA algorithm for signing. Below is an example code in Golang:

package main

import (
	"github.com/ethereum/go-ethereum/accounts"
	"github.com/ethereum/go-ethereum/common/hexutil"
	"github.com/ethereum/go-ethereum/crypto"
)

func main() {
	// replace with your private key (hex encoding)
	keyHex := "81a36f13408b99c59f604e75c2614e6df97c6afb10ba728ad7c7dc423d4b2f4b"
	// message to be signed
	message := "hello"
	privateKey, _ := crypto.HexToECDSA(keyHex)
	messageHash := accounts.TextHash([]byte(message))
	signature, _ := crypto.Sign(messageHash, privateKey)
	signatureHex := hexutil.Encode(signature)
	println(signatureHex)
}

Login Flow Example

Check out the code snippet below that gives you a glimpse of how a regular login works, with the added step of verifying the developer key. The example is given in JavaScript, please refer to the specific sdk for more information.

import ethers from "ethers";
import crypto from "crypto";
import sdk from "sendingnetwork-js-sdk";
import request from "request";


const login = (base_url) => {    // Pass the server URL as input value
    const prefix = 'did:pkh:eip155:1:';
    var privateKey = '';
    if (privateKey == '') {
      var id = crypto.randomBytes(32).toString('hex');
      privateKey = '0x' + id;
      console.log('SAVE BUT DO NOT SHARE THIS:', privateKey);
    }
    var client = sdk.createClient({
      baseUrl: base_url,
      request: request,
    });
    var wallet = new Wallet(privateKey);
    const address = wallet.address;
    const { data } = await client.getDIDList(`${address}`);
    let [did] = data;
    if (!did) {
      const {
        did: newDid,
        message: cMessage,
        updated: cUpdated,
      } = await client.createDID(`${prefix}${address}`);
      did = newDid;
      let signature = await wallet.signMessage(cMessage);
      await client.saveDID(newDid, {
        signature,
        operation: 'create',
        updated: cUpdated,
        address: `${prefix}${address}`,
      });
    }
    const { message: lMessage, updated } = await client.preDIDLogin(did);
    // request signature with wallet account
    let sign = await wallet.signMessage(lMessage);
    
    // request signature with server developer key
    let serverSign = await serverSignMessage(lMessage);
    
    let identifier = {
      did,
      token: sign,
      app_token: serverSign,
    };

    let deviceId = localStorage.getItem('mx_device_id') || null;

    let loginParams = {
      type: 'm.login.did.identity',
      updated,
      identifier,
      device_id: deviceId,
    };

    const { access_token, user_id, device_id } = await client.DIDLogin(
      loginParams,
    );
};
PreviousUserNextSocial Boost Development Instructions

Last updated 1 year ago