org.bitcoin.x6763.crypto.ecdsa.signers
Class ECDSASignature

java.lang.Object
  extended by org.bitcoin.x6763.crypto.ecdsa.signers.ECDSASignature
All Implemented Interfaces:
ECConstants

public class ECDSASignature
extends java.lang.Object
implements ECConstants

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);
 
 

Author:
Bouncy Castle contributors - http://www.bouncycastle.org/contributors.html, x6763

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

ECDSASignature

public ECDSASignature(ECKey key)
Creates a new ECDSASignature object, for either signing data, or verifying a signature

Parameters:
key - the key to be used for signing (PrivateKey) or signature verification (PublicKey)
Method Detail

sign

public static byte[] sign(byte[] message,
                          PrivateKey privateKey)
Generates an ECDSA signature

Parameters:
message - an array of bytes to be signed
privateKey - the private key to sign the message
Returns:
an array of bytes of the DER-encoded signature

verify

public static boolean verify(byte[] message,
                             byte[] signature,
                             PublicKey publicKey)
Verifies a signature

Parameters:
message - an array of bytes of the data that was signed
signature - the signature to be verified
publicKey - the public key to use for verifying the signature
Returns:
True if the signature is valid, or False if it is invalid

sign

public byte[] sign(byte[] message)
Generates an ECDSA signature

Parameters:
message - an array of bytes to be signed
Returns:
an array of bytes of the DER-encoded signature

verify

public boolean verify(byte[] message,
                      byte[] sig)
Verifies a signature

Parameters:
message - an array of bytes of the data that was signed
sig - the signature to be verified
Returns:
True if the signature is valid, or False if it is invalid