fix: dont add the redundant public key when marshalling

This commit is contained in:
Jacob Heun 2020-07-18 13:46:51 +02:00
parent df0f27274d
commit 353a89e58b
No known key found for this signature in database
GPG Key ID: CA5A94C15809879F
2 changed files with 7 additions and 1 deletions

View File

@ -55,7 +55,7 @@ class Ed25519PrivateKey {
} }
marshal () { marshal () {
return Buffer.concat([Buffer.from(this._key), Buffer.from(this._publicKey)]) return Buffer.from(this._key)
} }
get bytes () { get bytes () {

View File

@ -9,6 +9,7 @@ chai.use(dirtyChai)
const crypto = require('../../src') const crypto = require('../../src')
const ed25519 = crypto.keys.supportedKeys.ed25519 const ed25519 = crypto.keys.supportedKeys.ed25519
const { privateKeyLength } = require('../../src/keys/ed25519')
const fixtures = require('../fixtures/go-key-ed25519') const fixtures = require('../fixtures/go-key-ed25519')
const testGarbage = require('../helpers/test-garbage-error-handling') const testGarbage = require('../helpers/test-garbage-error-handling')
@ -154,5 +155,10 @@ describe('ed25519', function () {
const sig = await key.sign(fixtures.redundantPubKey.data) const sig = await key.sign(fixtures.redundantPubKey.data)
expect(sig).to.eql(fixtures.redundantPubKey.signature) 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)
})
}) })
}) })