Skip to content

Commit f2c44f7

Browse files
committed
fix(sdk-coin-apt): strip hex prefix from public key
TICKET: COIN-3052
1 parent a3bb3ce commit f2c44f7

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

modules/sdk-coin-apt/src/lib/transaction/transaction.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ export abstract class Transaction extends BaseTransaction {
174174

175175
const feePayerAuthenticator = authenticator.fee_payer.authenticator as AccountAuthenticatorEd25519;
176176
const feePayerSignature = Buffer.from(feePayerAuthenticator.signature.toUint8Array());
177-
this.addFeePayerSignature({ pub: feePayerAuthenticator.public_key.toString() }, feePayerSignature);
177+
this.addFeePayerSignature(
178+
{ pub: utils.stripHexPrefix(feePayerAuthenticator.public_key.toString()) },
179+
feePayerSignature
180+
);
178181
} catch (e) {
179182
console.error('invalid signed transaction', e);
180183
throw new Error('invalid signed transaction');

modules/sdk-coin-apt/src/lib/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export class Utils implements BaseUtils {
4343

4444
/** @inheritdoc */
4545
isValidPublicKey(key: string): boolean {
46-
key = this.stripHexPrefix(key);
4746
return isValidEd25519PublicKey(key);
4847
}
4948

modules/sdk-coin-apt/test/unit/apt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('APT:', function () {
6666

6767
it('is valid pub', function () {
6868
// with 0x prefix
69-
basecoin.isValidPub('0x9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07').should.equal(true);
69+
basecoin.isValidPub('0x9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07').should.equal(false);
7070
// without 0x prefix
7171
basecoin.isValidPub('9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07').should.equal(true);
7272
});

modules/sdk-coin-apt/test/unit/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('Aptos util library', function () {
4444

4545
it('is valid public key', function () {
4646
// with 0x prefix
47-
should.equal(true, utils.isValidPublicKey('0x9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07'));
47+
should.equal(false, utils.isValidPublicKey('0x9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07'));
4848
// without 0x prefix
4949
should.equal(true, utils.isValidPublicKey('9b4e96086d111500259f9b38680b0509a405c1904da18976455a20c691d3bb07'));
5050
});

0 commit comments

Comments
 (0)