Protocol Demo P-256 ECDH → MAC Comparison Part 3 of 4 · Server Verification

DID Auth: server

Server side: recomputes the MAC from its own private key and compares it with the MAC sent by the client.

For explaining a protocol only. Do not use this in a real service. The keys shown are public demo keys.

Open in app Download .ncw

DID Auth: server

Overview & Cryptographic Context

This workflow is Part 3 of the four-part DID Auth learning suite (Key Pairs → Client → Server → End-to-End Demo). Upon receiving the client's 65-byte P-256 public key and 8-byte response Received MAC, the server performs ECDH using its own 32-byte Server Private Key and the Client Public Key.

By the commutativity of scalar multiplication on elliptic curves ([dserver]Qclient = [dserver · dclient]G = [dclient]Qserver), the server derives the exact same 32-byte shared secret, splits SHA-256(Z) into the same 16-byte AES key and 16-byte IV, encrypts its 32-byte challenge Nonce, slices the expected 8-byte MAC, and compares it against Received MAC using a Value Comparator.

Pipeline Architecture & Wiring Flow

ECDH (P-256) ──► SHA-256 → Key / IV ──► AES-128-CBC → Expected MAC (8B) ──► Value Comparator (== Received MAC) ──► Verified (true)
  1. Shared Secret Reconstruction (ECDH Key Agreement): Computes the 32-byte P-256 shared secret from Server Private Key and Client Public Key.
  2. Expected MAC Recomputation (SHA-256 → Byte Slicer × 2 → AES-128-CBC → Byte Slicer): Reconstructs the 8-byte MAC 39b415c1dfeb8f52 over the 32-byte challenge Nonce.
  3. Constant-Time Verdict (Value Comparator): Compares the recomputed 8-byte slice (a) with Received MAC (b) using operator == and outputs Verified = true.

Nodes & Configuration

NodeNode Role & Key ParametersCount
Workflow InputSupplies Server Private Key, Client Public Key, Nonce, and Received MAC1
ECDH Key Agreementcurve = "p256", format = "raw_x"1
Cryptographic Hashalgorithm = "SHA-256"1
Byte SlicerThree instances: Key (0, 16), IV (16, 16), and MAC (-16, 8)3
AES EncryptLabeled AES-128-CBC; configured with mode = "CBC", padding = "None"1
Value ComparatorLabeled MAC matches; configured with operator = "=="1
Workflow OutputEmits boolean verdict Verified1

Node reference →

Inputs, Outputs & Test Vector Verification

Verification Source: independent implementation: Node crypto (reference/did-auth/did-auth.mjs), no published vector

Inputs

NameTypeValue (Hex)
Server Private Keybytes (32 B)a4b87f7821ada85b4e7f63618924b4c3f3bbb78cddcab485a7ee6f15fdfc7261
Client Public Keybytes (65 B)0415dc193b8e2a688d603303e85ec8fcc15dcba44ef2156a128c386b66b4f5e1d2188e7ca9d0385c02e72c6899f2771e86bb017a2d2903d89a2892c2199aec8f4d
Noncebytes (32 B)000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
Received MACbytes (8 B)39b415c1dfeb8f52

Expected Outputs

NameTypeValue
Verifiedbooltrue