Skip to content

Extension of cryptographic JavaScipt library JSBN to support EC point compression.

Notifications You must be signed in to change notification settings

kaielvin/jsbn-ec-point-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

jsbn-ec-point-compression

Extension of JSBN (http://www-cs-students.stanford.edu/~tjw/jsbn/) to support compression and decompression of elliptic curve points.

Like the original JSBN, the extension has been ported loosely from BouncyCastle's Java EC code.

Dependencies from the JSBN library are : jsbn.js, jsbn2.js, rng.js and ec.js.

Usage

var curve = getSECCurveByName("secp256r1").getCurve(); // from sec.js

var compressed = "028bd9aaec3783a891b4d4707004b265715651a6a78f6a43b30c2b51d0b63052d8";
var decompressed = curve.decodePointHex(compressed); // of type ECPointFp
compressed = curve.encodeCompressedPointHex(decompressed);
decompressed = curve.decodePointHex(compressed);

console.log(compressed);
console.log(curve.encodePointHex(decompressed)); // uncompressed hex encoding

Output :

028bd9aaec3783a891b4d4707004b265715651a6a78f6a43b30c2b51d0b63052d8
048bd9aaec3783a891b4d4707004b265715651a6a78f6a43b30c2b51d0b63052d8306c2f9a7c4cc6965b0701d0a22b5c00fc812322385b0ac91483a34d7bd88724

License

http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE

About

Extension of cryptographic JavaScipt library JSBN to support EC point compression.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published