mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 11:51:07 +00:00
fix: remove rendundant public key (#181)
* fix: remove rendundant public key BREAKING CHANGE: The private ed25519 key will no longer include the redundant public key * chore: fix lint
This commit is contained in:
parent
a0f387aeab
commit
afcffc8115
@ -5,7 +5,6 @@ const protobuf = require('protons')
|
||||
const multibase = require('multibase')
|
||||
const errcode = require('err-code')
|
||||
const uint8ArrayEquals = require('uint8arrays/equals')
|
||||
const uint8ArrayConcat = require('uint8arrays/concat')
|
||||
|
||||
const crypto = require('./ed25519')
|
||||
const pbm = protobuf(require('./keys.proto'))
|
||||
@ -57,7 +56,7 @@ class Ed25519PrivateKey {
|
||||
}
|
||||
|
||||
marshal () {
|
||||
return uint8ArrayConcat([this._key, this._publicKey])
|
||||
return this._key
|
||||
}
|
||||
|
||||
get bytes () {
|
||||
|
@ -157,6 +157,13 @@ describe('ed25519', function () {
|
||||
expect(ok).to.eql(true)
|
||||
})
|
||||
|
||||
it('does not include the redundant public key when marshalling privatekey', async () => {
|
||||
const key = await crypto.keys.unmarshalPrivateKey(fixtures.redundantPubKey.privateKey)
|
||||
const bytes = key.marshal()
|
||||
expect(bytes.length).to.equal(64)
|
||||
expect(bytes.slice(32)).to.eql(key.public.marshal())
|
||||
})
|
||||
|
||||
it('verifies with data from go with redundant public key', async () => {
|
||||
const key = crypto.keys.unmarshalPublicKey(fixtures.redundantPubKey.publicKey)
|
||||
const ok = await key.verify(fixtures.redundantPubKey.data, fixtures.redundantPubKey.signature)
|
||||
|
Loading…
x
Reference in New Issue
Block a user