Compare commits

...

4 Commits

Author SHA1 Message Date
David Dias
e7c11a8e01 chore: release version v0.10.2 2017-09-06 08:30:10 +01:00
David Dias
9bb96dc2bf chore: update contributors 2017-09-06 08:30:09 +01:00
David Dias
957fdd37e9 fix: use regular protocol-buffers until protobufjs is fixed (#109) 2017-09-06 08:29:45 +01:00
Friedel Ziegelmayer
83257bc4bd feat(deps): upgrade to aegir@12 and browserify-aes@1.0.8 2017-09-05 15:28:43 +02:00
27 changed files with 75 additions and 572 deletions

View File

@@ -13,16 +13,11 @@ matrix:
script:
- npm run lint
- npm run test
- npm run coverage
- make test
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
after_success:
- npm run coverage-publish
addons:
firefox: 'latest'
apt:

View File

@@ -1,3 +1,18 @@
<a name="0.10.2"></a>
## [0.10.2](https://github.com/libp2p/js-libp2p-crypto/compare/v0.10.1...v0.10.2) (2017-09-06)
### Bug Fixes
* use regular protocol-buffers until protobufjs is fixed ([#109](https://github.com/libp2p/js-libp2p-crypto/issues/109)) ([957fdd3](https://github.com/libp2p/js-libp2p-crypto/commit/957fdd3))
### Features
* **deps:** upgrade to aegir@12 and browserify-aes@1.0.8 ([83257bc](https://github.com/libp2p/js-libp2p-crypto/commit/83257bc))
<a name="0.10.1"></a>
## [0.10.1](https://github.com/libp2p/js-libp2p-crypto/compare/v0.10.0...v0.10.1) (2017-09-05)

View File

@@ -22,5 +22,6 @@ curves.forEach((curve) => {
}, { defer: true })
})
suite.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})
suite
.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})

View File

@@ -22,8 +22,9 @@ async.waterfall([
setup(cipher, hash, secret)
}))
suite.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})
suite
.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})
})
function setup (cipher, hash, secret) {

View File

@@ -37,5 +37,6 @@ suite.add('sign and verify', (d) => {
defer: true
})
suite.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})
suite
.on('cycle', (event) => console.log(String(event.target)))
.run({async: true})

View File

@@ -2,6 +2,10 @@ machine:
node:
version: stable
post:
test:
- npm run coverage -- --upload
dependencies:
pre:
- google-chrome --version

View File

@@ -1,6 +1,6 @@
{
"name": "libp2p-crypto",
"version": "0.10.1",
"version": "0.10.2",
"description": "Crypto primitives for libp2p",
"main": "src/index.js",
"browser": {
@@ -10,17 +10,16 @@
"./src/keys/rsa.js": "./src/keys/rsa-browser.js"
},
"scripts": {
"lint": "aegir-lint",
"build": "aegir-build",
"lint": "aegir lint",
"build": "aegir build",
"build-proto": "pbjs --wrap commonjs --target static-module src/keys/keys.proto > src/keys/keys.proto.js",
"test": "aegir-test",
"test:node": "aegir-test --env node",
"test:browser": "aegir-test --env browser",
"release": "aegir-release",
"release-minor": "aegir-release --type minor",
"release-major": "aegir-release --type major",
"coverage": "aegir-coverage",
"coverage-publish": "aegir-coverage publish"
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser -t webworker",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage --ignore src/keys/keys.proto.js"
},
"keywords": [
"IPFS",
@@ -33,19 +32,18 @@
"dependencies": {
"asn1.js": "^4.9.1",
"async": "^2.5.0",
"browserify-aes": "^1.0.6",
"browserify-aes": "^1.0.8",
"keypair": "^1.0.1",
"libp2p-crypto-secp256k1": "~0.2.2",
"multihashing-async": "~0.4.6",
"pem-jwk": "^1.5.1",
"protobufjs": "^6.8.0",
"protocol-buffers": "^3.2.1",
"rsa-pem-to-jwk": "^1.1.3",
"safe-buffer": "^5.1.1",
"tweetnacl": "^1.0.0",
"webcrypto-shim": "github:dignifiedquire/webcrypto-shim#master"
},
"devDependencies": {
"aegir": "^11.0.2",
"aegir": "^12.0.5",
"benchmark": "^2.1.4",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
@@ -79,4 +77,4 @@
"greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>",
"nikuda <nikuda@gmail.com>"
]
}
}

View File

@@ -1,7 +1,6 @@
'use strict'
const nodeify = require('../nodeify')
const Buffer = require('safe-buffer').Buffer
const crypto = require('../webcrypto.js')()
const lengths = require('./lengths')

View File

@@ -3,7 +3,6 @@
const webcrypto = require('../webcrypto.js')()
const nodeify = require('../nodeify')
const BN = require('asn1.js').bignum
const Buffer = require('safe-buffer').Buffer
const util = require('../util')
const toBase64 = util.toBase64

View File

@@ -1,10 +1,10 @@
'use strict'
const multihashing = require('multihashing-async')
const Buffer = require('safe-buffer').Buffer
const protobuf = require('protocol-buffers')
const crypto = require('./ed25519')
const pbm = require('./keys.proto.js')
const pbm = protobuf(require('./keys.proto'))
class Ed25519PublicKey {
constructor (key) {
@@ -21,11 +21,10 @@ class Ed25519PublicKey {
}
get bytes () {
const msg = pbm.PublicKey.create({
return pbm.PublicKey.encode({
Type: pbm.KeyType.Ed25519,
Data: this.marshal()
})
return Buffer.from(pbm.PublicKey.encode(msg).finish())
}
equals (key) {
@@ -64,12 +63,10 @@ class Ed25519PrivateKey {
}
get bytes () {
const msg = pbm.PrivateKey.create({
return pbm.PrivateKey.encode({
Type: pbm.KeyType.Ed25519,
Data: this.marshal()
})
return Buffer.from(pbm.PrivateKey.encode(msg).finish())
}
equals (key) {

View File

@@ -2,7 +2,6 @@
const nacl = require('tweetnacl')
const setImmediate = require('async/setImmediate')
const Buffer = require('safe-buffer').Buffer
exports.publicKeyLength = nacl.sign.publicKeyLength
exports.privateKeyLength = nacl.sign.secretKeyLength

View File

@@ -1,6 +1,7 @@
'use strict'
const keysPBM = require('./keys.proto.js')
const protobuf = require('protocol-buffers')
const keysPBM = protobuf(require('./keys.proto'))
exports = module.exports
@@ -49,7 +50,7 @@ exports.generateKeyPairFromSeed = (type, seed, bits, cb) => {
// representative object
exports.unmarshalPublicKey = (buf) => {
const decoded = keysPBM.PublicKey.decode(buf)
const data = Buffer.from(decoded.Data)
const data = decoded.Data
switch (decoded.Type) {
case keysPBM.KeyType.RSA:
@@ -81,7 +82,7 @@ exports.marshalPublicKey = (key, type) => {
// representative object
exports.unmarshalPrivateKey = (buf, callback) => {
const decoded = keysPBM.PrivateKey.decode(buf)
const data = Buffer.from(decoded.Data)
const data = decoded.Data
switch (decoded.Type) {
case keysPBM.KeyType.RSA:

View File

@@ -1,7 +1,6 @@
'use strict'
const whilst = require('async/whilst')
const Buffer = require('safe-buffer').Buffer
const hmac = require('../hmac')
const cipherMap = {

View File

@@ -1,15 +0,0 @@
enum KeyType {
RSA = 0;
Ed25519 = 1;
Secp256k1 = 2;
}
message PublicKey {
required KeyType Type = 1;
required bytes Data = 2;
}
message PrivateKey {
required KeyType Type = 1;
required bytes Data = 2;
}

View File

@@ -1,488 +1,15 @@
/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/
"use strict";
'use strict'
var $protobuf = require("protobufjs/minimal");
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
/**
* KeyType enum.
* @exports KeyType
* @enum {string}
* @property {number} RSA=0 RSA value
* @property {number} Ed25519=1 Ed25519 value
* @property {number} Secp256k1=2 Secp256k1 value
*/
$root.KeyType = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "RSA"] = 0;
values[valuesById[1] = "Ed25519"] = 1;
values[valuesById[2] = "Secp256k1"] = 2;
return values;
})();
$root.PublicKey = (function() {
/**
* Properties of a PublicKey.
* @exports IPublicKey
* @interface IPublicKey
* @property {KeyType} Type PublicKey Type
* @property {Uint8Array} Data PublicKey Data
*/
/**
* Constructs a new PublicKey.
* @exports PublicKey
* @classdesc Represents a PublicKey.
* @constructor
* @param {IPublicKey=} [properties] Properties to set
*/
function PublicKey(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* PublicKey Type.
* @member {KeyType}Type
* @memberof PublicKey
* @instance
*/
PublicKey.prototype.Type = 0;
/**
* PublicKey Data.
* @member {Uint8Array}Data
* @memberof PublicKey
* @instance
*/
PublicKey.prototype.Data = $util.newBuffer([]);
/**
* Creates a new PublicKey instance using the specified properties.
* @function create
* @memberof PublicKey
* @static
* @param {IPublicKey=} [properties] Properties to set
* @returns {PublicKey} PublicKey instance
*/
PublicKey.create = function create(properties) {
return new PublicKey(properties);
};
/**
* Encodes the specified PublicKey message. Does not implicitly {@link PublicKey.verify|verify} messages.
* @function encode
* @memberof PublicKey
* @static
* @param {IPublicKey} message PublicKey message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
PublicKey.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.Type);
writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.Data);
return writer;
};
/**
* Encodes the specified PublicKey message, length delimited. Does not implicitly {@link PublicKey.verify|verify} messages.
* @function encodeDelimited
* @memberof PublicKey
* @static
* @param {IPublicKey} message PublicKey message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
PublicKey.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a PublicKey message from the specified reader or buffer.
* @function decode
* @memberof PublicKey
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {PublicKey} PublicKey
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
PublicKey.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.PublicKey();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.Type = reader.int32();
break;
case 2:
message.Data = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
if (!message.hasOwnProperty("Type"))
throw $util.ProtocolError("missing required 'Type'", { instance: message });
if (!message.hasOwnProperty("Data"))
throw $util.ProtocolError("missing required 'Data'", { instance: message });
return message;
};
/**
* Decodes a PublicKey message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof PublicKey
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {PublicKey} PublicKey
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
PublicKey.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a PublicKey message.
* @function verify
* @memberof PublicKey
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
PublicKey.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
switch (message.Type) {
default:
return "Type: enum value expected";
case 0:
case 1:
case 2:
break;
}
if (!(message.Data && typeof message.Data.length === "number" || $util.isString(message.Data)))
return "Data: buffer expected";
return null;
};
/**
* Creates a PublicKey message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof PublicKey
* @static
* @param {Object.<string,*>} object Plain object
* @returns {PublicKey} PublicKey
*/
PublicKey.fromObject = function fromObject(object) {
if (object instanceof $root.PublicKey)
return object;
var message = new $root.PublicKey();
switch (object.Type) {
case "RSA":
case 0:
message.Type = 0;
break;
case "Ed25519":
case 1:
message.Type = 1;
break;
case "Secp256k1":
case 2:
message.Type = 2;
break;
}
if (object.Data != null)
if (typeof object.Data === "string")
$util.base64.decode(object.Data, message.Data = $util.newBuffer($util.base64.length(object.Data)), 0);
else if (object.Data.length)
message.Data = object.Data;
return message;
};
/**
* Creates a plain object from a PublicKey message. Also converts values to other types if specified.
* @function toObject
* @memberof PublicKey
* @static
* @param {PublicKey} message PublicKey
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
PublicKey.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.Type = options.enums === String ? "RSA" : 0;
object.Data = options.bytes === String ? "" : [];
}
if (message.Type != null && message.hasOwnProperty("Type"))
object.Type = options.enums === String ? $root.KeyType[message.Type] : message.Type;
if (message.Data != null && message.hasOwnProperty("Data"))
object.Data = options.bytes === String ? $util.base64.encode(message.Data, 0, message.Data.length) : options.bytes === Array ? Array.prototype.slice.call(message.Data) : message.Data;
return object;
};
/**
* Converts this PublicKey to JSON.
* @function toJSON
* @memberof PublicKey
* @instance
* @returns {Object.<string,*>} JSON object
*/
PublicKey.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
return PublicKey;
})();
$root.PrivateKey = (function() {
/**
* Properties of a PrivateKey.
* @exports IPrivateKey
* @interface IPrivateKey
* @property {KeyType} Type PrivateKey Type
* @property {Uint8Array} Data PrivateKey Data
*/
/**
* Constructs a new PrivateKey.
* @exports PrivateKey
* @classdesc Represents a PrivateKey.
* @constructor
* @param {IPrivateKey=} [properties] Properties to set
*/
function PrivateKey(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* PrivateKey Type.
* @member {KeyType}Type
* @memberof PrivateKey
* @instance
*/
PrivateKey.prototype.Type = 0;
/**
* PrivateKey Data.
* @member {Uint8Array}Data
* @memberof PrivateKey
* @instance
*/
PrivateKey.prototype.Data = $util.newBuffer([]);
/**
* Creates a new PrivateKey instance using the specified properties.
* @function create
* @memberof PrivateKey
* @static
* @param {IPrivateKey=} [properties] Properties to set
* @returns {PrivateKey} PrivateKey instance
*/
PrivateKey.create = function create(properties) {
return new PrivateKey(properties);
};
/**
* Encodes the specified PrivateKey message. Does not implicitly {@link PrivateKey.verify|verify} messages.
* @function encode
* @memberof PrivateKey
* @static
* @param {IPrivateKey} message PrivateKey message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
PrivateKey.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.Type);
writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.Data);
return writer;
};
/**
* Encodes the specified PrivateKey message, length delimited. Does not implicitly {@link PrivateKey.verify|verify} messages.
* @function encodeDelimited
* @memberof PrivateKey
* @static
* @param {IPrivateKey} message PrivateKey message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
PrivateKey.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a PrivateKey message from the specified reader or buffer.
* @function decode
* @memberof PrivateKey
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {PrivateKey} PrivateKey
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
PrivateKey.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.PrivateKey();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.Type = reader.int32();
break;
case 2:
message.Data = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
if (!message.hasOwnProperty("Type"))
throw $util.ProtocolError("missing required 'Type'", { instance: message });
if (!message.hasOwnProperty("Data"))
throw $util.ProtocolError("missing required 'Data'", { instance: message });
return message;
};
/**
* Decodes a PrivateKey message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof PrivateKey
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {PrivateKey} PrivateKey
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
PrivateKey.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a PrivateKey message.
* @function verify
* @memberof PrivateKey
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
PrivateKey.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
switch (message.Type) {
default:
return "Type: enum value expected";
case 0:
case 1:
case 2:
break;
}
if (!(message.Data && typeof message.Data.length === "number" || $util.isString(message.Data)))
return "Data: buffer expected";
return null;
};
/**
* Creates a PrivateKey message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof PrivateKey
* @static
* @param {Object.<string,*>} object Plain object
* @returns {PrivateKey} PrivateKey
*/
PrivateKey.fromObject = function fromObject(object) {
if (object instanceof $root.PrivateKey)
return object;
var message = new $root.PrivateKey();
switch (object.Type) {
case "RSA":
case 0:
message.Type = 0;
break;
case "Ed25519":
case 1:
message.Type = 1;
break;
case "Secp256k1":
case 2:
message.Type = 2;
break;
}
if (object.Data != null)
if (typeof object.Data === "string")
$util.base64.decode(object.Data, message.Data = $util.newBuffer($util.base64.length(object.Data)), 0);
else if (object.Data.length)
message.Data = object.Data;
return message;
};
/**
* Creates a plain object from a PrivateKey message. Also converts values to other types if specified.
* @function toObject
* @memberof PrivateKey
* @static
* @param {PrivateKey} message PrivateKey
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
PrivateKey.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.Type = options.enums === String ? "RSA" : 0;
object.Data = options.bytes === String ? "" : [];
}
if (message.Type != null && message.hasOwnProperty("Type"))
object.Type = options.enums === String ? $root.KeyType[message.Type] : message.Type;
if (message.Data != null && message.hasOwnProperty("Data"))
object.Data = options.bytes === String ? $util.base64.encode(message.Data, 0, message.Data.length) : options.bytes === Array ? Array.prototype.slice.call(message.Data) : message.Data;
return object;
};
/**
* Converts this PrivateKey to JSON.
* @function toJSON
* @memberof PrivateKey
* @instance
* @returns {Object.<string,*>} JSON object
*/
PrivateKey.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
return PrivateKey;
})();
module.exports = $root;
module.exports = `enum KeyType {
RSA = 0;
Ed25519 = 1;
Secp256k1 = 2;
}
message PublicKey {
required KeyType Type = 1;
required bytes Data = 2;
}
message PrivateKey {
required KeyType Type = 1;
required bytes Data = 2;
}`

View File

@@ -1,7 +1,6 @@
'use strict'
const nodeify = require('../nodeify')
const Buffer = require('safe-buffer').Buffer
const webcrypto = require('../webcrypto.js')()
@@ -18,11 +17,11 @@ exports.generateKey = function (bits, callback) {
true,
['sign', 'verify']
)
.then(exportKey)
.then((keys) => ({
privateKey: keys[0],
publicKey: keys[1]
})), callback)
.then(exportKey)
.then((keys) => ({
privateKey: keys[0],
publicKey: keys[1]
})), callback)
}
// Takes a jwk key

View File

@@ -1,9 +1,10 @@
'use strict'
const multihashing = require('multihashing-async')
const protobuf = require('protocol-buffers')
const crypto = require('./rsa')
const pbm = require('./keys.proto.js')
const pbm = protobuf(require('./keys.proto'))
class RsaPublicKey {
constructor (key) {
@@ -20,11 +21,10 @@ class RsaPublicKey {
}
get bytes () {
const msg = pbm.PublicKey.create({
return pbm.PublicKey.encode({
Type: pbm.KeyType.RSA,
Data: this.marshal()
})
return Buffer.from(pbm.PublicKey.encode(msg).finish())
}
encrypt (bytes) {
@@ -75,11 +75,10 @@ class RsaPrivateKey {
}
get bytes () {
const msg = pbm.PrivateKey.create({
return pbm.PrivateKey.encode({
Type: pbm.KeyType.RSA,
Data: this.marshal()
})
return Buffer.from(pbm.PrivateKey.encode(msg).finish())
}
equals (key) {

View File

@@ -1,7 +1,6 @@
'use strict'
const BN = require('asn1.js').bignum
const Buffer = require('safe-buffer').Buffer
// Convert a BN.js instance to a base64 encoded string without padding
// Adapted from https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#appendix-C
@@ -11,8 +10,8 @@ exports.toBase64 = function toBase64 (bn, len) {
return s
.replace(/(=*)$/, '') // Remove any trailing '='s
.replace(/\+/g, '-') // 62nd char of encoding
.replace(/\//g, '_') // 63rd char of encoding
.replace(/\+/g, '-') // 62nd char of encoding
.replace(/\//g, '_') // 63rd char of encoding
}
// Convert a base64 encoded string to a BN.js instance

View File

@@ -7,7 +7,6 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const series = require('async/series')
const Buffer = require('safe-buffer').Buffer
const crypto = require('../../src')
const fixtures = require('./../fixtures/aes')

View File

@@ -1,7 +1,5 @@
'use strict'
const Buffer = require('safe-buffer').Buffer
module.exports = {
curve: 'P-256',
bob: {

View File

@@ -1,7 +1,5 @@
'use strict'
const Buffer = require('safe-buffer').Buffer
module.exports = {
// These were generated in a gore (https://github.com/motemen/gore) repl session:
//

View File

@@ -1,7 +1,5 @@
'use strict'
const Buffer = require('safe-buffer').Buffer
module.exports = {
private: {
hash: Buffer.from([

View File

@@ -1,7 +1,5 @@
'use strict'
const Buffer = require('safe-buffer').Buffer
module.exports = [{
cipher: 'AES-256',
hash: 'SHA256',

View File

@@ -1,9 +1,6 @@
'use strict'
const Buffer = require('safe-buffer').Buffer
module.exports = {
// protobuf marshaled key pair generated with libp2p-crypto-secp256k1
// and marshaled with libp2p-crypto.marshalPublicKey / marshalPrivateKey
pbmPrivateKey: Buffer.from('08021220e0600103010000000100000000000000be1dc82c2e000000e8d6030301000000', 'hex'),

View File

@@ -2,7 +2,6 @@
/* eslint-env mocha */
'use strict'
const Buffer = require('safe-buffer').Buffer
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect

View File

@@ -5,7 +5,6 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const Buffer = require('safe-buffer').Buffer
const crypto = require('../../src')
const ed25519 = crypto.keys.supportedKeys.ed25519

View File

@@ -5,7 +5,6 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const Buffer = require('safe-buffer').Buffer
const crypto = require('../../src')
const rsa = crypto.keys.supportedKeys.rsa