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:
Jacob Heun 2020-08-07 17:16:00 +02:00 committed by GitHub
parent a0f387aeab
commit afcffc8115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -5,7 +5,6 @@ const protobuf = require('protons')
const multibase = require('multibase') const multibase = require('multibase')
const errcode = require('err-code') const errcode = require('err-code')
const uint8ArrayEquals = require('uint8arrays/equals') const uint8ArrayEquals = require('uint8arrays/equals')
const uint8ArrayConcat = require('uint8arrays/concat')
const crypto = require('./ed25519') const crypto = require('./ed25519')
const pbm = protobuf(require('./keys.proto')) const pbm = protobuf(require('./keys.proto'))
@ -57,7 +56,7 @@ class Ed25519PrivateKey {
} }
marshal () { marshal () {
return uint8ArrayConcat([this._key, this._publicKey]) return this._key
} }
get bytes () { get bytes () {

View File

@ -157,6 +157,13 @@ describe('ed25519', function () {
expect(ok).to.eql(true) 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 () => { it('verifies with data from go with redundant public key', async () => {
const key = crypto.keys.unmarshalPublicKey(fixtures.redundantPubKey.publicKey) const key = crypto.keys.unmarshalPublicKey(fixtures.redundantPubKey.publicKey)
const ok = await key.verify(fixtures.redundantPubKey.data, fixtures.redundantPubKey.signature) const ok = await key.verify(fixtures.redundantPubKey.data, fixtures.redundantPubKey.signature)