Separated out zk algorithm