From afcffc8115c8833edfe2a942d05547f418be5585 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Fri, 7 Aug 2020 17:16:00 +0200 Subject: [PATCH] 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 --- src/keys/ed25519-class.js | 3 +-- test/keys/ed25519.spec.js | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/keys/ed25519-class.js b/src/keys/ed25519-class.js index 6b0b319c..23050084 100644 --- a/src/keys/ed25519-class.js +++ b/src/keys/ed25519-class.js @@ -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 () { diff --git a/test/keys/ed25519.spec.js b/test/keys/ed25519.spec.js index 8cc8fd5c..7104654e 100644 --- a/test/keys/ed25519.spec.js +++ b/test/keys/ed25519.spec.js @@ -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)