import * as crypto from 'crypto' ; param { Uint8Array } left param { Uint8Array } right returns { boolean } export function equals ( left , right ) { if ( left . length !== right . length ) { return false ; } let d = 0 ; let i ; for ( i = 0 ; i < left . length ; i ++ ) { d |= left [ i ] ^ right [ i ] ; } return d === 0 ; } param { Uint8Array } left param { Uint8Array } right returns { boolean } export function hmac_equals ( left , right ) { return equals ( crypto . createHmac ( 'sha256' , hmacKey ) . update ( left ) . digest ( ) , crypto . createHmac ( 'sha256' , hmacKey ) . update ( right ) . digest ( ) ) ; } const hmacKey = crypto . randomBytes ( 32 ) ;