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

Commit

Permalink
fix: remove rendundant public key (#181)
Browse files Browse the repository at this point in the history
* fix: remove rendundant public key

BREAKING CHANGE: The private ed25519 key will no longer include the redundant public key

* chore: fix lint
  • Loading branch information
jacobheun committed Aug 7, 2020
1 parent a0f387a commit afcffc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit afcffc8

Please sign in to comment.