Skip to content

Commit

Permalink
Use sjcl npm module, delete sjcl code
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Clark committed May 12, 2015
1 parent d56e70b commit 9a50258
Show file tree
Hide file tree
Showing 219 changed files with 42 additions and 39,732 deletions.
49 changes: 4 additions & 45 deletions Gulpfile.js
Expand Up @@ -5,62 +5,21 @@ var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var filelog = require('gulp-filelog');
var cleanDest = require('gulp-clean-dest');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var webpack = require('webpack');
var bump = require('gulp-bump');
var react = require('gulp-react');
var flow = require('gulp-flowtype');
var argv = require('yargs').argv;
// var header = require('gulp-header');

var pkg = require('./package.json');

var sjclSrc = [
'src/js/sjcl/core/sjcl.js',
'src/js/sjcl/core/aes.js',
'src/js/sjcl/core/bitArray.js',
'src/js/sjcl/core/codecString.js',
'src/js/sjcl/core/codecHex.js',
'src/js/sjcl/core/codecBase64.js',
'src/js/sjcl/core/codecBytes.js',
'src/js/sjcl/core/sha256.js',
'src/js/sjcl/core/sha512.js',
'src/js/sjcl/core/sha1.js',
'src/js/sjcl/core/ccm.js',
// 'src/js/sjcl/core/cbc.js',
// 'src/js/sjcl/core/ocb2.js',
'src/js/sjcl/core/hmac.js',
'src/js/sjcl/core/pbkdf2.js',
'src/js/sjcl/core/random.js',
'src/js/sjcl/core/convenience.js',
'src/js/sjcl/core/bn.js',
'src/js/sjcl/core/ecc.js',
'src/js/sjcl/core/srp.js',
'src/js/sjcl-custom/sjcl-ecc-pointextras.js',
'src/js/sjcl-custom/sjcl-secp256k1.js',
'src/js/sjcl-custom/sjcl-ripemd160.js',
'src/js/sjcl-custom/sjcl-extramath.js',
'src/js/sjcl-custom/sjcl-montgomery.js',
'src/js/sjcl-custom/sjcl-validecc.js',
'src/js/sjcl-custom/sjcl-ecdsa-canonical.js',
'src/js/sjcl-custom/sjcl-ecdsa-der.js',
'src/js/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js',
'src/js/sjcl-custom/sjcl-jacobi.js'
];

function logPluginError(error) {
gutil.log(error.toString());
}

gulp.task('concat-sjcl', function() {
return gulp.src(sjclSrc)
.pipe(concat('sjcl.js'))
.pipe(gulp.dest('./build/'));
});

gulp.task('build', ['concat-sjcl'], function(callback) {
gulp.task('build', function(callback) {
webpack({
cache: true,
entry: './src/js/ripple/index.js',
Expand All @@ -79,7 +38,7 @@ gulp.task('build-min', ['build'], function() {
.pipe(gulp.dest('./build/'));
});

gulp.task('build-debug', ['concat-sjcl'], function(callback) {
gulp.task('build-debug', function(callback) {
webpack({
cache: true,
entry: './src/js/ripple/index.js',
Expand All @@ -104,7 +63,7 @@ function buildUseError(cons) {
.replace(new RegExp('<CONS>', 'g'), cons);
}

gulp.task('build-core', ['concat-sjcl'], function(callback) {
gulp.task('build-core', function(callback) {
webpack({
entry: [
'./src/js/ripple/remote.js'
Expand Down Expand Up @@ -194,4 +153,4 @@ gulp.task('version-beta', function() {
.pipe(gulp.dest('./'));
});

gulp.task('default', ['concat-sjcl', 'build', 'build-debug', 'build-min']);
gulp.task('default', ['build', 'build-debug', 'build-min']);
4 changes: 4 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"lodash": "^3.1.0",
"lru-cache": "~2.5.0",
"ripple-wallet-generator": "^1.0.3",
"sjcl": "^1.0.2",
"ws": "~0.7.1"
},
"devDependencies": {
Expand All @@ -30,7 +31,6 @@
"gulp": "~3.8.10",
"gulp-bump": "~0.1.13",
"gulp-clean-dest": "^0.1.0",
"gulp-concat": "~2.4.3",
"gulp-filelog": "^0.4.1",
"gulp-flowtype": "^0.4.1",
"gulp-plumber": "^0.6.6",
Expand All @@ -48,7 +48,7 @@
},
"scripts": {
"build": "node_modules/.bin/gulp",
"pretest": "node_modules/.bin/gulp concat-sjcl",
"postinstall": "cd node_modules/sjcl; ./configure --with-all --compress=none; make",
"test": "./node_modules/.bin/istanbul test -x build/sjcl.js -x src/js/jsbn/* ./node_modules/mocha/bin/_mocha -- --reporter ${MOCHA_REPORTER:=spec} --timeout 10000 --slow 500 test/*-test.js",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc'; fi; eslint --reset -c eslintrc src/js/ripple/*.js",
Expand Down
5 changes: 2 additions & 3 deletions src/js/ripple/utils.js
Expand Up @@ -157,8 +157,7 @@ exports.toTimestamp = toTimestamp;
exports.fromTimestamp = fromTimestamp;
exports.getMantissaDecimalString = getMantissaDecimalString;

// Going up three levels is needed to escape the src-cov folder used for the
// test coverage stuff.
exports.sjcl = require('../../../build/sjcl');
exports.sjcl = require('sjcl');
require('../sjcl-custom');

// vim:sw=2:sts=2:ts=8:et
10 changes: 10 additions & 0 deletions src/js/sjcl-custom/index.js
@@ -0,0 +1,10 @@
require('./sjcl-ecc-pointextras.js');
require('./sjcl-secp256k1.js');
require('./sjcl-ripemd160.js');
require('./sjcl-extramath.js');
require('./sjcl-montgomery.js');
require('./sjcl-validecc.js');
require('./sjcl-ecdsa-canonical.js');
require('./sjcl-ecdsa-der.js');
require('./sjcl-ecdsa-recoverablepublickey.js');
require('./sjcl-jacobi.js');
1 change: 1 addition & 0 deletions src/js/sjcl-custom/sjcl-ecc-pointextras.js
@@ -1,3 +1,4 @@
var sjcl = require('sjcl');
/**
* Check that the point is valid based on the method described in
* SEC 1: Elliptic Curve Cryptography, section 3.2.2.1:
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-ecdsa-canonical.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.ecc.ecdsa.secretKey.prototype.canonicalizeSignature = function(rs) {
var w = sjcl.bitArray,
R = this._curve.r,
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-ecdsa-der.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.ecc.ecdsa.secretKey.prototype.signDER = function(hash, paranoia) {
return this.encodeDER(this.sign(hash, paranoia));
};
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-ecdsa-recoverablepublickey.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

/**
* This module uses the public key recovery method
* described in SEC 1: Elliptic Curve Cryptography,
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-extramath.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.bn.ZERO = new sjcl.bn(0);

/** [ this / that , this % that ] */
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-jacobi.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.bn.prototype.jacobi = function (that) {
var a = this;
that = new sjcl.bn(that);
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-montgomery.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.bn.prototype.invDigit = function ()
{
var radixMod = 1 + this.radixMask;
Expand Down
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-ripemd160.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

/** @fileOverview Javascript RIPEMD-160 implementation.
*
* @author Artem S Vybornov <vybornov@gmail.com>
Expand Down
4 changes: 3 additions & 1 deletion src/js/sjcl-custom/sjcl-secp256k1.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

// ----- for secp256k1 ------

sjcl.ecc.point.prototype.toBytesCompressed = function () {
Expand Down Expand Up @@ -73,4 +75,4 @@ sjcl.ecc.pointJac.prototype.doubl = function () {
// since then, sjcl has been updated to support k256
// this override exist to keep supporting the old c256 with k256 behavior
// this will be removed in future release
sjcl.ecc.curves.c256 = sjcl.ecc.curves.k256;
sjcl.ecc.curves.c256 = sjcl.ecc.curves.k256;
2 changes: 2 additions & 0 deletions src/js/sjcl-custom/sjcl-validecc.js
@@ -1,3 +1,5 @@
var sjcl = require('sjcl');

sjcl.ecc.ecdsa.secretKey.prototype.sign = function(hash, paranoia, k_for_testing) {
var R = this._curve.r,
l = R.bitLength();
Expand Down
2 changes: 0 additions & 2 deletions src/js/sjcl/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions src/js/sjcl/.travis.yml

This file was deleted.

93 changes: 0 additions & 93 deletions src/js/sjcl/Makefile

This file was deleted.

21 changes: 0 additions & 21 deletions src/js/sjcl/README.md

This file was deleted.

32 changes: 0 additions & 32 deletions src/js/sjcl/README/COPYRIGHT

This file was deleted.

0 comments on commit 9a50258

Please sign in to comment.