Bug 799734 - browser id crypto library

This is a significantly reworked version of some old code, taking into account the old review comments.  There's more `static` than I would like, but I'm not a huge "factory" fan either.