|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bitcoin.x6763.crypto.ecdsa.signers.ECDSASignature
public class ECDSASignature
The ECDSASignature class provides methods for creating ECDSA signatures and verifying ECDSA signatures.
There are two ways this class can be used.
The first way is to use the static sign
and verify
methods, each of which accept a PrivateKey
and PublicKey
respectively:
byte[] sig = ECDSASignature.sign(data, privateKey);
boolean valid = ECDSASignature.verify(data, sig, publicKey);
The second way is to instantiate an ECDSASignature object with either a
PrivateKey
or PublicKey
object and use the
sign
and verify
methods:
ECDSASignature signer = new ECDSASignature(privateKey);
byte[] sig = signer.sign(data);
ECDSASignature verifier = new ECDSASignature(publicKey);
boolean valid = verifier.verify(data, sig);
Field Summary |
---|
Fields inherited from interface org.bitcoin.x6763.crypto.ecdsa.math.ECConstants |
---|
FOUR, ONE, THREE, TWO, ZERO |
Constructor Summary | |
---|---|
ECDSASignature(ECKey key)
Creates a new ECDSASignature object, for either signing data, or verifying a signature |
Method Summary | |
---|---|
byte[] |
sign(byte[] message)
Generates an ECDSA signature |
static byte[] |
sign(byte[] message,
PrivateKey privateKey)
Generates an ECDSA signature |
boolean |
verify(byte[] message,
byte[] sig)
Verifies a signature |
static boolean |
verify(byte[] message,
byte[] signature,
PublicKey publicKey)
Verifies a signature |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ECDSASignature(ECKey key)
key
- the key to be used for signing (PrivateKey) or signature
verification (PublicKey)Method Detail |
---|
public static byte[] sign(byte[] message, PrivateKey privateKey)
message
- an array of bytes to be signedprivateKey
- the private key to sign the message
public static boolean verify(byte[] message, byte[] signature, PublicKey publicKey)
message
- an array of bytes of the data that was signedsignature
- the signature to be verifiedpublicKey
- the public key to use for verifying the signature
public byte[] sign(byte[] message)
message
- an array of bytes to be signed
public boolean verify(byte[] message, byte[] sig)
message
- an array of bytes of the data that was signedsig
- the signature to be verified
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |