I had priv and pub keys the wrong way round, refactored. Most related variable names don't make much sense right now
more fixing after refactor