mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 09:41:03 +00:00
fix: dont add the redundant public key when marshalling
This commit is contained in:
parent
df0f27274d
commit
353a89e58b
@ -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 () {
|
||||||
|
@ -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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user