Examples of ECKey


Examples of com.nimbusds.jose.jwk.ECKey

      "SsUdaQkAgDPrwQrJmbnX9cwlGfP-HqHZR1\","+
      "\"d\":\"AAhRON2r9cqXX1hg-RoI6R1tX5p2rUAYdmpHZoC1XNM56KtscrX6zb"+
      "KipQrCW9CGZH3T4ubpnoTKLDYJ_fF3_rJt\""+
      "}";

    ECKey jwk = ECKey.parse(json);

    String jws = "eyJhbGciOiJFUzUxMiIsImtpZCI6ImJpbGJvLmJhZ2dpbnNAaG9iYml0b24uZX"+
      "hhbXBsZSJ9"+
      "."+
      "SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IH"+
      "lvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBk"+
      "b24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcm"+
      "UgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4"+
      "."+
      "AE_R_YZCChjn4791jSQCrdPZCNYqHXCTZH0-JZGYNlaAjP2kqaluUIIUnC9qvb"+
      "u9Plon7KRTzoNEuT4Va2cmL1eJAQy3mtPBu_u_sDDyYjnAMDxXPn7XrT0lw-kv"+
      "AD890jl8e2puQens_IEKBpHABlsbEPX6sFY8OcGDqoRuBomu9xQ2";

    JWSObject jwsObject = JWSObject.parse(jws);

    assertEquals(JWSAlgorithm.ES512, jwsObject.getHeader().getAlgorithm());
    assertEquals("bilbo.baggins@hobbiton.example", jwsObject.getHeader().getKeyID());

    JWSVerifier verifier = new ECDSAVerifier(jwk.getX().decodeToBigInteger(), jwk.getY().decodeToBigInteger());

    assertTrue(jwsObject.verify(verifier));

    assertEquals("SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IH" +
      "lvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBk" +
View Full Code Here

Examples of java.security.interfaces.ECKey

        Security.insertProviderAt((Provider) o, 1);
    }

    private static String getSignatureAlgorithm(Key key) {
        if ("EC".equals(key.getAlgorithm())) {
            ECKey ecKey = (ECKey) key;
            int curveSize = ecKey.getParams().getOrder().bitLength();
            if (curveSize <= 256) {
                return "SHA256withECDSA";
            } else if (curveSize <= 384) {
                return "SHA384withECDSA";
            } else {
View Full Code Here

Examples of java.security.interfaces.ECKey

                // a key we are not able to handle.
        } else if (key instanceof RSAKey) {
            RSAKey pubk = (RSAKey)key;
            size = pubk.getModulus().bitLength();
        } else if (key instanceof ECKey) {
            ECKey pubk = (ECKey)key;
            size = pubk.getParams().getOrder().bitLength();
        } else if (key instanceof DSAKey) {
            DSAKey pubk = (DSAKey)key;
            size = pubk.getParams().getP().bitLength();
        } else if (key instanceof DHKey) {
            DHKey pubk = (DHKey)key;
            size = pubk.getParams().getP().bitLength();
        }   // Otherwise, it may be a unextractable key of PKCS#11, or
            // a key we are not able to handle.

        return size;
    }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

  public Account() {
  }

    public void init(){
        this.ecKey = new ECKey(Utils.getRandom());
        address = this.ecKey.getAddress();
    }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

        String expected = "f87302f870808b00d3c21bcecceda10000009479b08ad8787060333663d19704909ee7b1903e588609184e72a000824255801ca00f410a70e42b2c9854a8421d32c87c370a2b9fff0a27f9f031bb4443681d73b5a018a7dc4c4f9dee9f3dc35cb96ca15859aa27e219a8e4a8547be6bd3206979858";

        BigInteger value = new BigInteger("1000000000000000000000000");

        byte[] privKey = HashUtil.sha3("cat".getBytes());
        ECKey ecKey = ECKey.fromPrivate(privKey);

        byte[] gasPrice=  Hex.decode("09184e72a000");
        byte[] gas =      Hex.decode("4255");

        Transaction tx = new Transaction(null, value.toByteArray(),
                ecKey.getAddress(),  gasPrice, gas, null);

        tx.sign(privKey);
        tx.getEncoded();

        Set<Transaction> txs = new HashSet<>(Arrays.asList(tx));
View Full Code Here

Examples of org.ethereum.crypto.ECKey

    Assert.assertEquals(1866897155, ECKey.fromPrivate(privateKey).hashCode());
  }

  @Test
  public void testECKey() {
    ECKey key = new ECKey();
    assertTrue(key.isPubKeyCanonical());
    assertNotNull(key.getPubKey());
    assertNotNull(key.getPrivKeyBytes());
    log.debug(Hex.toHexString(key.getPrivKeyBytes()) + " :Generated privkey");
    log.debug(Hex.toHexString(key.getPubKey()) + " :Generated pubkey");
  }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

    log.debug(Hex.toHexString(key.getPubKey()) + " :Generated pubkey");
  }

  @Test
  public void testFromPrivateKey() {
    ECKey key = ECKey.fromPrivate(privateKey).decompress();
    assertTrue(key.isPubKeyCanonical());
    assertTrue(key.hasPrivKey());
    assertArrayEquals(pubKey, key.getPubKey());
  }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

    assertArrayEquals(pubKey, key.getPubKey());
  }

  @Test(expected=IllegalArgumentException.class)
  public void testPrivatePublicKeyBytesNoArg() {
    new ECKey(null, null);
    fail("Expecting an IllegalArgumentException for using only null-parameters");
  }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

    fail("Expecting an IllegalArgumentException for using only null-parameters");
  }

  @Test
  public void testIsPubKeyOnly() {
    ECKey key = ECKey.fromPublicOnly(pubKey);
    assertTrue(key.isPubKeyCanonical());
    assertTrue(key.isPubKeyOnly());
    assertArrayEquals(key.getPubKey(), pubKey);
  }
View Full Code Here

Examples of org.ethereum.crypto.ECKey

    assertArrayEquals(compressedPubKey, pubFromPriv);
  }

  @Test
  public void testGetAddress() {
    ECKey key = ECKey.fromPublicOnly(pubKey);
    assertArrayEquals(Hex.decode(address), key.getAddress());
  }
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.