import * as crypto from "@node-lightning/crypto" ; import { KeyType } from "./KeyType" ; /**
 * Constructs a number of keys from the shared secret. Keys are generated by
 * computing an HMAC (with SHA256 as hashing algorithm) using the appropriate
 * key-type (i.e. rho, mu, um, or pad) as HMAC-key and the 32-byte shared secret
 * as the message. The resulting HMAC is then returned as the key.
 */ export function generateKey ( type , ss ) { let key ; switch ( type ) { case KeyType . rho : key = Buffer . from ( "72686f" , "hex" ) ; break ; case KeyType . mu : key = Buffer . from ( "6d75" , "hex" ) ; break ; case KeyType . um : key = Buffer . from ( "756d" , "hex" ) ; break ; case KeyType . pad : key = Buffer . from ( "706164" , "hex" ) ; break ; } return crypto . hmac ( key , ss ) ; }