Module io.github.mmm.crypto.bc
Class SignatureEcBc
- java.lang.Object
-
- io.github.mmm.binary.BinaryType
-
- io.github.mmm.crypto.CryptoBinary
-
- io.github.mmm.crypto.asymmetric.sign.SignatureBinary
-
- io.github.mmm.crypto.asymmetric.sign.ec.bc.SignatureEcBc
-
- All Implemented Interfaces:
Binary
,Streamable
- Direct Known Subclasses:
SignatureEcBcPlain
,SignatureEcBcWithRecoveryId
public abstract class SignatureEcBc extends SignatureBinary
SignatureBinary
for ECDSA based onBouncyCastle
.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from class io.github.mmm.binary.BinaryType
data
-
Fields inherited from interface io.github.mmm.binary.Binary
EMPTY_BYTE_ARRAY
-
-
Constructor Summary
Constructors Constructor Description SignatureEcBc(CryptoEllipticCurveBc curve, byte[] data)
The constructor.SignatureEcBc(CryptoEllipticCurveBc curve, byte[] data, BigInteger r, BigInteger s)
The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static byte
calculateRecoveryIndex(byte[] message, CryptoEllipticCurveBc curve, BigInteger r, BigInteger s, org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey publicKey)
protected static byte[]
createData(int head, BigInteger r, BigInteger s)
protected void
deserialize()
protected CryptoEllipticCurveBc
getCurve()
protected int
getHead()
BigInteger
getR()
BigInteger
getS()
protected org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey
recoverPublicKey(byte[] message, byte recoveryIndex)
protected static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey
recoverPublicKey(byte[] message, CryptoEllipticCurveBc curve, BigInteger r, BigInteger s, byte recoveryIndex)
-
Methods inherited from class io.github.mmm.binary.BinaryType
asStream, equals, format, formatBase64, formatHex, getData, getData, getDataByte, getLength, getMaxLength, getMinLength, hashCode, isZeros, parseBase64, parseHex, save, toBytes, toBytes, toInt, toLong, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.binary.Binary
formatBase64, formatHex
-
-
-
-
Constructor Detail
-
SignatureEcBc
public SignatureEcBc(CryptoEllipticCurveBc curve, byte[] data, BigInteger r, BigInteger s)
The constructor.- Parameters:
curve
- theelliptic curve
.data
- thebinary data
.r
- - seegetR()
.s
- - seegetS()
.
-
SignatureEcBc
public SignatureEcBc(CryptoEllipticCurveBc curve, byte[] data)
The constructor.- Parameters:
curve
- theelliptic curve
.data
- thebinary data
.
-
-
Method Detail
-
getHead
protected int getHead()
- Returns:
- number of bytes reserved at the beginning (header) of the
binary
data.
-
deserialize
protected void deserialize()
-
createData
protected static byte[] createData(int head, BigInteger r, BigInteger s)
- Parameters:
head
- the number of bytes reserved at the beginning.r
- the valuer
.s
- the values
.- Returns:
- the
binary data
.
-
getR
public BigInteger getR()
- Returns:
- r
-
getS
public BigInteger getS()
- Returns:
- s
-
getCurve
protected CryptoEllipticCurveBc getCurve()
- Returns:
- the
elliptic curve
.
-
recoverPublicKey
protected org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey recoverPublicKey(byte[] message, byte recoveryIndex)
- Parameters:
message
- the payload (typically hash of message) that was signed when this signature was created.recoveryIndex
- the recovery index for public key recovery.- Returns:
- the recovered public key.
-
calculateRecoveryIndex
protected static byte calculateRecoveryIndex(byte[] message, CryptoEllipticCurveBc curve, BigInteger r, BigInteger s, org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey publicKey)
- Parameters:
message
- the payload (typically hash of message) that was signed when this signature was created.curve
- theelliptic curve
.r
- valueR
.s
- valueS
.publicKey
- thepublic key
corresponding to the private key that was used to sign themessage
.- Returns:
- the
recovery index
.
-
recoverPublicKey
protected static org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey recoverPublicKey(byte[] message, CryptoEllipticCurveBc curve, BigInteger r, BigInteger s, byte recoveryIndex)
- Parameters:
message
- the payload (typically hash of message) that was signed when this signature was created.curve
- theelliptic curve
.r
- valueR
.s
- valueS
.recoveryIndex
- therecovery index
for public key recovery.- Returns:
- the recovered public key.
-
-