* Split core lib into multiple files * Refactor data encoding methods * Refactor data masking process * Improve qr code generation process * Increase minimum required node version to 0.10 * Add linter * Add tests and tests coverage * Update travis config to fix compilation issues * Add examples folder * Add missing license tag in package.json * Update build script and add sourcemap support * Publish only strictly needed files on npm * Update readme
29 lines
932 B
JavaScript
29 lines
932 B
JavaScript
var test = require('tap').test
|
|
var Poly = require('core/polynomial')
|
|
|
|
test('Generator polynomial', function (t) {
|
|
var result = Poly.generateECPolynomial(0)
|
|
t.ok(Buffer.isBuffer(result), 'Should return a buffer')
|
|
t.deepEqual(result, new Buffer([1]), 'Should return coeff [1] for polynomial of degree 0')
|
|
|
|
for (var e = 2; e <= 68; e++) {
|
|
t.equal(Poly.generateECPolynomial(e).length, e + 1, 'Should return a number of coefficients equal to (degree + 1)')
|
|
}
|
|
|
|
t.end()
|
|
})
|
|
|
|
test('Polynomial', function (t) {
|
|
var p1 = [0, 1, 2, 3, 4]
|
|
var p2 = [5, 6]
|
|
|
|
var result = Poly.mul(p1, p2)
|
|
t.ok(Buffer.isBuffer(result), 'Should return a buffer')
|
|
t.equal(result.length, 6, 'Should return correct number of coefficients')
|
|
|
|
result = Poly.mod(p1, Poly.generateECPolynomial(2))
|
|
t.ok(Buffer.isBuffer(result), 'Should return a buffer')
|
|
t.equal(result.length, 2, 'Should return correct number of coefficients')
|
|
|
|
t.end()
|
|
})
|