Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

fix: remove rendundant public key #181

Merged
merged 2 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/keys/ed25519-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -57,7 +56,7 @@ class Ed25519PrivateKey {
}

marshal () {
return uint8ArrayConcat([this._key, this._publicKey])
return this._key
}

get bytes () {
Expand Down
7 changes: 7 additions & 0 deletions test/keys/ed25519.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down