question: public byte [ ] encodeToBitcoin ( ) { try { ByteArrayOutputStream bos = derByteStream ( ) ; bos . write ( sighashFlags ) ; return bos . toByteArray ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
target:  What we get back from the signer are the two components of a signature, r and s. To get a flat byte stream of the type used by Bitcoin we have to encode them using DER encoding, which is just a way to pack the two components into a structure, and then we append a byte to the end for the sighash flags.