Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

@authmesh/core

P-256 ECDSA crypto primitives for amesh --- device-bound M2M authentication.

Install

npm install @authmesh/core

What's inside

  • signMessage / verifyMessage --- P-256 ECDSA signing and verification (raw r||s, 64 bytes)
  • buildCanonicalString --- deterministic request canonicalization (method, path, timestamp, nonce, body)
  • InMemoryNonceStore --- replay detection with configurable TTL
  • computeHmac / verifyHmac --- HMAC-SHA256 for allow list integrity
  • hkdfDerive --- HKDF-SHA256 key derivation
  • ephemeralEcdh --- P-256 ECDH for handshake tunnel encryption

Most users should use @authmesh/sdk instead --- it wraps these primitives into a simple amesh.fetch() / amesh.verify() API.

Usage

import { signMessage, verifyMessage, buildCanonicalString } from '@authmesh/core';

const canonical = buildCanonicalString('POST', '/api/orders', timestamp, nonce, body);
const signature = signMessage(privateKey, new TextEncoder().encode(canonical));
const valid = verifyMessage(signature, new TextEncoder().encode(canonical), publicKey);

License

MIT