Class ECDSASignature


  • public class ECDSASignature
    extends java.lang.Object
    Original Code https://github.com/web3j/web3j/blob/master/crypto/src/main/java/org/web3j/crypto/Sign.java

    Transaction signing logic.

    Adapted from the BitcoinJ ECKey implementation.

    • Constructor Summary

      Constructors 
      Constructor Description
      ECDSASignature​(Bytes privateKey)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte findRecoveryId​(java.math.BigInteger[] sig, byte[] message)
      Returns the recovery ID, a byte with value between 0 and 3, inclusive, that specifies which of 4 possible curve points was used to sign a message.
      java.math.BigInteger[] generateSignature​(byte[] message)
      generate a signature for the given message using the key we were initialised with
      byte[] recoverableSerialize​(java.math.BigInteger[] sig, byte[] message)
      Serialize the result of `generateSignature` and recovery id
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ECDSASignature

        public ECDSASignature​(Bytes privateKey)
    • Method Detail

      • recoverableSerialize

        public byte[] recoverableSerialize​(java.math.BigInteger[] sig,
                                           byte[] message)
        Serialize the result of `generateSignature` and recovery id
        Parameters:
        sig - the R and S components of the signature, wrapped.
        message - Hash of the data that was signed.
        Returns:
        32 bytes for R + 32 bytes for S + 1 byte for recovery id
      • generateSignature

        public java.math.BigInteger[] generateSignature​(byte[] message)
        generate a signature for the given message using the key we were initialised with
        Parameters:
        message - Hash of the data that was signed.
        Returns:
        the R and S components of the signature, wrapped.
      • findRecoveryId

        public byte findRecoveryId​(java.math.BigInteger[] sig,
                                   byte[] message)
        Returns the recovery ID, a byte with value between 0 and 3, inclusive, that specifies which of 4 possible curve points was used to sign a message. This value is also referred to as "v".
        Parameters:
        sig - the R and S components of the signature, wrapped.
        message - Hash of the data that was signed.
        Returns:
        recId Which possible key to recover.
        Throws:
        java.lang.RuntimeException - if no recovery ID can be found.