Package foundation.icon.icx.crypto
Class ECDSASignature
- java.lang.Object
-
- foundation.icon.icx.crypto.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.javaTransaction 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 withbyte[]
recoverableSerialize(java.math.BigInteger[] sig, byte[] message)
Serialize the result of `generateSignature` and recovery id
-
-
-
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.
-
-