Package org.ethereum.crypto

Examples of org.ethereum.crypto.ECKey.verify()


    public void testVerifySignature1() {
      ECKey key = ECKey.fromPublicOnly(pubKey);
        BigInteger r = new BigInteger("28157690258821599598544026901946453245423343069728565040002908283498585537001");
        BigInteger s = new BigInteger("30212485197630673222315826773656074299979444367665131281281249560925428307087");
        ECDSASignature sig = ECDSASignature.fromComponents(r.toByteArray(), s.toByteArray(), (byte) 28);
        key.verify(HashUtil.sha3(exampleMessage.getBytes()), sig);
    }
   
    @Test
    public void testVerifySignature2() {
        BigInteger r = new BigInteger("c52c114d4f5a3ba904a9b3036e5e118fe0dbb987fe3955da20f2cd8f6c21ab9c", 16);
View Full Code Here


    try {
      ECKey key = ECKey.signatureToKey(HashUtil.sha3(rawtx), sig.toBase64());
      System.out.println("Signature public key\t: " + Hex.toHexString(key.getPubKey()));
      System.out.println("Sender is\t\t: " + Hex.toHexString(key.getAddress()));
      assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(key.getAddress()));
      key.verify(HashUtil.sha3(rawtx), sig);
    } catch (SignatureException e) {
      fail();
    }
    }
View Full Code Here

    @Test
    public void testSignVerify() {
      ECKey key = ECKey.fromPrivate(privateKey);
      String message = new String("This is an example of a signed message.");
      ECDSASignature output = key.doSign(message.getBytes());
      assertTrue(key.verify(message.getBytes(), output));
    }
     
  @Test
  public void testIsPubKeyCanonicalCorect() {
    // Test correct prefix 4, right length 65
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.