From f051b0b714b98d560b7dbe38009396dc68d3d3e9 Mon Sep 17 00:00:00 2001 From: "Andrew Chaney (netuoso)" Date: Thu, 21 Jun 2018 12:08:04 -0500 Subject: [PATCH 1/3] small fix when sending STM1111111111111111111111111111111114T1Anm to disable witness --- src/auth/ecc/src/key_public.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/auth/ecc/src/key_public.js b/src/auth/ecc/src/key_public.js index 57233188..30024220 100644 --- a/src/auth/ecc/src/key_public.js +++ b/src/auth/ecc/src/key_public.js @@ -20,10 +20,20 @@ class PublicKey { } static fromBuffer(buffer) { - return new PublicKey(ecurve.Point.decodeFrom(secp256k1, buffer)); - } - - toBuffer(compressed = this.Q.compressed) { + if ( + buffer.toString("hex") === + "000000000000000000000000000000000000000000000000000000000000000000" + ) + return new PublicKey(null); + return new PublicKey(Point.decodeFrom(secp256k1, buffer)); + } + + toBuffer(compressed = this.Q ? this.Q.compressed : null) { + if (this.Q === null) + return Buffer.from( + "000000000000000000000000000000000000000000000000000000000000000000", + "hex" + ); return this.Q.getEncoded(compressed); } From ea40b3ad21c027e24a5ec74f3083cf989025f5f1 Mon Sep 17 00:00:00 2001 From: "Andrew Chaney (netuoso)" Date: Thu, 21 Jun 2018 13:16:23 -0500 Subject: [PATCH 2/3] Fix typo that removed call to ecurve --- src/auth/ecc/src/key_public.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/ecc/src/key_public.js b/src/auth/ecc/src/key_public.js index 30024220..81791b08 100644 --- a/src/auth/ecc/src/key_public.js +++ b/src/auth/ecc/src/key_public.js @@ -25,7 +25,7 @@ class PublicKey { "000000000000000000000000000000000000000000000000000000000000000000" ) return new PublicKey(null); - return new PublicKey(Point.decodeFrom(secp256k1, buffer)); + return new PublicKey(ecurve.Point.decodeFrom(secp256k1, buffer)); } toBuffer(compressed = this.Q ? this.Q.compressed : null) { From 7418a74e744d0eedcfc5894332118072d62bece7 Mon Sep 17 00:00:00 2001 From: roadscape Date: Tue, 17 Jul 2018 14:42:42 -0500 Subject: [PATCH 3/3] add null key tests --- test/KeyFormats.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/KeyFormats.js b/test/KeyFormats.js index 530e2fee..a96b7d97 100644 --- a/test/KeyFormats.js +++ b/test/KeyFormats.js @@ -70,6 +70,16 @@ var test = function(key) { var address = Address.fromPublic(public_key, true, 56); assert.equal(key.Compressed_PTS, address.toString()); }); + + it("null hex to pubkey", function() { + var public_key = PublicKey.fromHex(key.null_hex); + assert.equal(key.null_address, public_key.toPublicKeyString()); + }); + + it("null pubkey to hex", function() { + var public_key = PublicKey.fromString(key.null_address); + assert.equal(key.null_hex, public_key.toHex()); + }); }); }; @@ -87,6 +97,9 @@ test({ Uncompressed_BTC: "STMLAFmEtM8as1mbmjVcj5dphLdPguXquimn", Compressed_BTC: "STMANNTSEaUviJgWLzJBersPmyFZBY4jJETY", Uncompressed_PTS: "STMEgj7RM6FBwSoccGaESJLC3Mi18785bM3T", - Compressed_PTS: "STMD5rYtofD6D4UHJH6mo953P5wpBfMhdMEi" + Compressed_PTS: "STMD5rYtofD6D4UHJH6mo953P5wpBfMhdMEi", + // https://github.com/steemit/steem-js/issues/267 + null_hex: "000000000000000000000000000000000000000000000000000000000000000000", + null_address: "STM1111111111111111111111111111111114T1Anm" });