congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ECKey.sign
Code IndexAdd Tabnine to your IDE (free)

How to use
sign
method
in
io.yggdrash.common.crypto.ECKey

Best Java code snippets using io.yggdrash.common.crypto.ECKey.sign (Showing top 8 results out of 315)

origin: yggdrash/yggdrash

/**
 * Sign the hashed data by sha3().
 *
 * @param hashedData hashed data
 * @return signature as byte[65]
 */
public byte[] signHashedData(byte[] hashedData) {
  return key.sign(hashedData).toBinary();
}
origin: yggdrash/yggdrash

@Test
public void testVerifySignature6() throws SignatureException {
  // generate ECkey object with privateKey
  ECKey key = ECKey.fromPrivate(privateKey);
  // check public key with pubKey
  assertArrayEquals(pubKey, key.getPubKey());
  // generate messageHash with exampleMessage
  byte[] messageHash = HashUtil.sha3(exampleMessage.getBytes());
  // generate ECDSASignature with ECKey, messageHash
  ECDSASignature signature = key.sign(messageHash);
  // verify the sign message
  assertTrue(key.verify(messageHash, signature));
  // get public key with messageHash, ECDSASignature
  ECKey keyFromSig = ECKey.signatureToKey(messageHash, signature);
  byte[] pubKeyFromSig = keyFromSig.getPubKey();
  assertArrayEquals(pubKey, pubKeyFromSig);
  // verify the sign message
  assertTrue(keyFromSig.verify(messageHash, signature));
}
origin: yggdrash/yggdrash

/**
 * Sign the plain data.
 *
 * @param data plain data
 * @return signature as byte[65]
 */
public byte[] sign(byte[] data) {
  return key.sign(HashUtil.sha3(data)).toBinary();
}
origin: yggdrash/yggdrash

/**
 * Verified via https://etherchain.org/verify/signature
 */
@Test
public void testEthereumSignToHex() {
  ECKey key = ECKey.fromPrivate(privateKey);
  byte[] messageHash = HashUtil.sha3(exampleMessage.getBytes());
  ECDSASignature signature = key.sign(messageHash);
  String output = signature.toHex();
  log.debug("Signature\t: " + output + " (Hex, length: " + output.length() + ")");
  assertEquals(signatureHex, output);
}
origin: yggdrash/yggdrash

@Test
public void testEthereumSign() {
  ECKey key = ECKey.fromPrivate(privateKey);
  log.debug("Secret\t: " + Hex.toHexString(key.getPrivKeyBytes()));
  log.debug("Pubkey\t: " + Hex.toHexString(key.getPubKey()));
  log.debug("Data\t: " + exampleMessage);
  byte[] messageHash = HashUtil.sha3(exampleMessage.getBytes());
  ECDSASignature signature = key.sign(messageHash);
  String output = signature.toBase64();
  log.debug("Sign\t: " + output + " (Base64, length: " + output.length() + ")");
  assertEquals(sigBase64, output);
}
origin: yggdrash/yggdrash

@Test
public void testVerifySignature5() {
  ECKey key = ECKey.fromPrivate(privateKey);
  byte[] messageHash = HashUtil.sha3(exampleMessage.getBytes());
  ECDSASignature signature = key.sign(messageHash);
  assertTrue(key.verify(messageHash, signature));
}
origin: yggdrash/yggdrash

private void testProviderRoundTrip(Provider provider) {
  ECKey key = new ECKey(provider, secureRandom);
  String message = "The quick brown fox jumps over the lazy dog.";
  byte[] input = HashUtil.sha3(message.getBytes());
  ECDSASignature sig = key.sign(input);
  assertTrue(sig.validateComponents());
  assertTrue(key.verify(input, sig));
}
origin: yggdrash/yggdrash

@Test
public void testSignVerify() {
  ECKey key = ECKey.fromPrivate(privateKey);
  String message = "This is an example of a signed message.";
  byte[] input = HashUtil.sha3(message.getBytes());
  ECDSASignature sig = key.sign(input);
  assertTrue(sig.validateComponents());
  assertTrue(key.verify(input, sig));
}
io.yggdrash.common.cryptoECKeysign

Javadoc

Takes the keccak hash (32 bytes) of data and returns the ECDSA signature

Popular methods of ECKey

  • <init>
    Generates an entirely new keypair with the given SecureRandom object. BouncyCastle will be used as
  • doSign
    Signs the given hash and returns the R and S components as BigIntegers and put them in ECDSASignatur
  • fromPrivate
    Creates an ECKey given the private key only.
  • fromPublicOnly
    Creates an ECKey that cannot be used for signing, only verifying signatures, from the given encoded
  • getAddress
    Gets the address form of the public key.
  • getNodeId
    Generates the NodeID based on this key, that is the public key without first format byte
  • getPrivKeyBytes
    Returns a 32 byte array containing the private key, or null if the key is encrypted or public only
  • getPubKey
    Gets the encoded public key value.
  • isPubKeyCanonical
    Returns true if the given pubkey is canonical, i.e. the correct length taking into wallet compressio
  • recoverPubBytesFromSignature
    Given the components of a signature and a selector value, recover and return the public key that gen
  • signatureToKey
    Compute the key that signed the given signature.
  • verify
    Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key.
  • signatureToKey,
  • verify,
  • check,
  • computeAddress,
  • decompressKey,
  • equals,
  • extractPublicKey,
  • fromNodeId,
  • getPubKeyPoint

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • addToBackStack (FragmentTransaction)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now