Add writeSignedAP

This pull request contains the implementation of writeSignedAP
and all of the supporting tests.