Class Index | File Index

Classes


Class KJUR.crypto.ECDSA

class for EC key generation, ECDSA signing and verifcation
Defined in: ecdsa-modified-1.0.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
class for EC key generation, ECDSA signing and verifcation

CAUTION: Most of the case, you don't need to use this class except for generating an EC key pair.

Method Summary
Method Attributes Method Name and Description
<static>  
KJUR.crypto.ECDSA.asn1SigToConcatSig(asn1Hex)
convert hexadecimal ASN.1 encoded signature to concatinated signature
<static>  
KJUR.crypto.ECDSA.biRSSigToASN1Sig(biR, biS)
convert R and S BigInteger object of signature to ASN.1 encoded signature
<static>  
KJUR.crypto.ECDSA.concatSigToASN1Sig(concatSig)
convert hexadecimal concatinated signature to ASN.1 encoded signature
<static>  
KJUR.crypto.ECDSA.generateKeyPairHex()
generate a EC key pair
<static>  
KJUR.crypto.ECDSA.hexRSSigToASN1Sig(hR, hS)
convert hexadecimal R and S value of signature to ASN.1 encoded signature
<static>  
KJUR.crypto.ECDSA.parseSigHex(sigHex)
parse ASN.1 DER encoded ECDSA signature
<static>  
KJUR.crypto.ECDSA.parseSigHexInHexRS(sigHex)
parse ASN.1 DER encoded ECDSA signature
<static>  
KJUR.crypto.ECDSA.signHex(hashHex, privHex)
signing to message hash
<static>  
KJUR.crypto.ECDSA.verifyHex(hashHex, sigHex, pubkeyHex)
verifying signature with message hash and public key
Class Detail
KJUR.crypto.ECDSA()
class for EC key generation, ECDSA signing and verifcation

CAUTION: Most of the case, you don't need to use this class except for generating an EC key pair. Please use KJUR.crypto.Signature class instead.

This class was originally developped by Stefan Thomas for Bitcoin JavaScript library. (See https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/ecdsa.js) Currently this class supports following named curves and their aliases.

  • secp256r1, NIST P-256, P-256, prime256v1 (*)
  • secp256k1 (*)
  • secp384r1, NIST P-384, P-384 (*)

Method Detail
<static> {String} KJUR.crypto.ECDSA.asn1SigToConcatSig(asn1Hex)
convert hexadecimal ASN.1 encoded signature to concatinated signature
Parameters:
{String} asn1Hex
hexadecimal string of ASN.1 encoded ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} r-s concatinated format of ECDSA signature value

<static> {String} KJUR.crypto.ECDSA.biRSSigToASN1Sig(biR, biS)
convert R and S BigInteger object of signature to ASN.1 encoded signature
Parameters:
{BigInteger} biR
BigInteger object of R field of ECDSA signature value
{BigInteger} biS
BIgInteger object of S field of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

<static> {String} KJUR.crypto.ECDSA.concatSigToASN1Sig(concatSig)
convert hexadecimal concatinated signature to ASN.1 encoded signature
Parameters:
{String} concatSig
r-s concatinated format of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

<static> {Array} KJUR.crypto.ECDSA.generateKeyPairHex()
generate a EC key pair
var ec = KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var keypair = ec.generateKeyPairHex();
var pubhex = keypair.ecpubhex; // hexadecimal string of EC private key (=d)
var prvhex = keypair.ecprvhex; // hexadecimal string of EC public key
Since:
ecdsa-modified 1.0.1
Returns:
{Array} associative array of hexadecimal string of private and public key

<static> {String} KJUR.crypto.ECDSA.hexRSSigToASN1Sig(hR, hS)
convert hexadecimal R and S value of signature to ASN.1 encoded signature
Parameters:
{String} hR
hexadecimal string of R field of ECDSA signature value
{String} hS
hexadecimal string of S field of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{String} hexadecimal string of ASN.1 encoded ECDSA signature value

<static> {Array} KJUR.crypto.ECDSA.parseSigHex(sigHex)
parse ASN.1 DER encoded ECDSA signature
var ec = KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sig = ec.parseSigHex('30...');
var biR = sig.r; // BigInteger object for 'r' field of signature.
var biS = sig.s; // BigInteger object for 's' field of signature.
Parameters:
{String} sigHex
hexadecimal string of ECDSA signature value
Since:
ecdsa-modified 1.0.1
Returns:
{Array} associative array of signature field r and s of BigInteger

<static> {Array} KJUR.crypto.ECDSA.parseSigHexInHexRS(sigHex)
parse ASN.1 DER encoded ECDSA signature
var ec = KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sig = ec.parseSigHexInHexRS('30...');
var hR = sig.r; // hexadecimal string for 'r' field of signature.
var hS = sig.s; // hexadecimal string for 's' field of signature.
Parameters:
{String} sigHex
hexadecimal string of ECDSA signature value
Since:
ecdsa-modified 1.0.3
Returns:
{Array} associative array of signature field r and s in hexadecimal

<static> {String} KJUR.crypto.ECDSA.signHex(hashHex, privHex)
signing to message hash
var ec = KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var sigValue = ec.signHex(hash, prvKey);
Parameters:
{String} hashHex
hexadecimal string of hash value of signing message
{String} privHex
hexadecimal string of EC private key
Since:
ecdsa-modified 1.0.1
Returns:
{String} hexadecimal string of ECDSA signature

<static> {Boolean} KJUR.crypto.ECDSA.verifyHex(hashHex, sigHex, pubkeyHex)
verifying signature with message hash and public key
var ec = KJUR.crypto.ECDSA({'curve': 'secp256r1'});
var result = ec.verifyHex(msgHashHex, sigHex, pubkeyHex);
Parameters:
{String} hashHex
hexadecimal string of hash value of signing message
{String} sigHex
hexadecimal string of signature value
{String} pubkeyHex
hexadecimal string of public key
Since:
ecdsa-modified 1.0.1
Returns:
{Boolean} true if the signature is valid, otherwise false

© 2012 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0