コード例 #1
0
 @Test
 public void testSignatureCreation() throws WrongSignatureException {
   byte[] abcMessage =
       new byte[] {
         24, 66, 105, 116, 99, 111, 105, 110, 32, 83, 105, 103, 110, 101, 100, 32, 77, 101, 115,
         115, 97, 103, 101, 58, 10, 3, 97, 98, 99
       };
   String message = "abc";
   byte[] msg = Signatures.formatMessageForSigning(message);
   Assert.assertArrayEquals(abcMessage, msg);
   SignedMessage signed2 = privKey.signMessage(message, new TestNonRandomSource());
   assertEquals(privKey.getPublicKey(), signed2.getPublicKey());
   String sigStr = signed2.getBase64Signature();
   System.out.println(sigStr);
   PublicKey recoverFromSignature = SignedMessage.recoverFromSignature(message, sigStr);
   assertEquals(privKey.getPublicKey(), recoverFromSignature);
 }
コード例 #2
0
 @BeforeClass
 public static void createFixtures() {
   address = Address.fromString("16F9yVJYb267n8rq5sDCU2xmDpxNajUfLV");
   NetworkParameters network = NetworkParameters.productionNetwork;
   privKey =
       new InMemoryPrivateKey("KxrnQTQKTZv2y75BUUVFPrFFjWyjaEy8hqYXEkvdMMfgrGoo6XHB", network);
   Assert.assertEquals(network, address.getNetwork());
   Assert.assertEquals(privKey.getPublicKey().toAddress(network), address);
 }