com.google.bitcoin.core
Class ECKey.ECDSASignature

java.lang.Object
  extended by com.google.bitcoin.core.ECKey.ECDSASignature
Direct Known Subclasses:
TransactionSignature
Enclosing class:
ECKey

public static class ECKey.ECDSASignature
extends Object

Groups the two components that make up a signature, and provides a way to encode to DER form, which is how ECDSA signatures are represented when embedded in other data structures in the Bitcoin protocol. The raw components can be useful for doing further EC maths on them.


Field Summary
 BigInteger r
          The two components of the signature.
 BigInteger s
          The two components of the signature.
 
Constructor Summary
ECKey.ECDSASignature(BigInteger r, BigInteger s)
          Constructs a signature with the given components.
 
Method Summary
static ECKey.ECDSASignature decodeFromDER(byte[] bytes)
           
protected  ByteArrayOutputStream derByteStream()
           
 byte[] encodeToDER()
          DER is an international standard for serializing data structures which is widely used in cryptography.
 void ensureCanonical()
          Will automatically adjust the S component to be less than or equal to half the curve order, if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

public BigInteger r
The two components of the signature.


s

public BigInteger s
The two components of the signature.

Constructor Detail

ECKey.ECDSASignature

public ECKey.ECDSASignature(BigInteger r,
                            BigInteger s)
Constructs a signature with the given components. Does NOT automatically canonicalise the signature.

Method Detail

ensureCanonical

public void ensureCanonical()
Will automatically adjust the S component to be less than or equal to half the curve order, if necessary. This is required because for every signature (r,s) the signature (r, -s (mod N)) is a valid signature of the same message. However, we dislike the ability to modify the bits of a Bitcoin transaction after it's been signed, as that violates various assumed invariants. Thus in future only one of those forms will be considered legal and the other will be banned.


encodeToDER

public byte[] encodeToDER()
DER is an international standard for serializing data structures which is widely used in cryptography. It's somewhat like protocol buffers but less convenient. This method returns a standard DER encoding of the signature, as recognized by OpenSSL and other libraries.


decodeFromDER

public static ECKey.ECDSASignature decodeFromDER(byte[] bytes)

derByteStream

protected ByteArrayOutputStream derByteStream()
                                       throws IOException
Throws:
IOException


Copyright © 2014. All rights reserved.