From 353a89e58b61e066b6359f13b8b9a64e1523bce2 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Sat, 18 Jul 2020 13:46:51 +0200 Subject: [PATCH] fix: dont add the redundant public key when marshalling --- src/keys/ed25519-class.js | 2 +- test/keys/ed25519.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/keys/ed25519-class.js b/src/keys/ed25519-class.js index 7136cd7..8933d1b 100644 --- a/src/keys/ed25519-class.js +++ b/src/keys/ed25519-class.js @@ -55,7 +55,7 @@ class Ed25519PrivateKey { } marshal () { - return Buffer.concat([Buffer.from(this._key), Buffer.from(this._publicKey)]) + return Buffer.from(this._key) } get bytes () { diff --git a/test/keys/ed25519.spec.js b/test/keys/ed25519.spec.js index 8a7d77c..ecc511c 100644 --- a/test/keys/ed25519.spec.js +++ b/test/keys/ed25519.spec.js @@ -9,6 +9,7 @@ chai.use(dirtyChai) const crypto = require('../../src') const ed25519 = crypto.keys.supportedKeys.ed25519 +const { privateKeyLength } = require('../../src/keys/ed25519') const fixtures = require('../fixtures/go-key-ed25519') const testGarbage = require('../helpers/test-garbage-error-handling') @@ -154,5 +155,10 @@ describe('ed25519', function () { const sig = await key.sign(fixtures.redundantPubKey.data) expect(sig).to.eql(fixtures.redundantPubKey.signature) }) + + it('doesnt include the redundant public key when marshalling', async () => { + const key = await crypto.keys.unmarshalPrivateKey(fixtures.redundantPubKey.privateKey) + expect(key.marshal()).to.have.length(privateKeyLength) + }) }) })