Duplicate of function from lib/verify.js?