Skip to content

Commit

Permalink
Merge pull request #125 from casper-ecosystem/hotfix/mixed-case-pks
Browse files Browse the repository at this point in the history
casper-js-sdk 2.7.1
  • Loading branch information
hoffmannjan authored Nov 18, 2021
2 parents 34587d7 + 236e72e commit 1c78106
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to casper-js-sdk.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.7.1

### Fixed

- Added support for mixed case hex representation of public keys introduced in `casper-node` `1.4.2`.

## 2.7.0

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "casper-js-sdk",
"version": "2.7.0",
"version": "2.7.1",
"license": "Apache 2.0",
"description": "SDK to interact with the Casper blockchain",
"homepage": "https://github.com/casper-ecosystem/casper-js-sdk#README.md",
Expand Down
8 changes: 8 additions & 0 deletions src/lib/CLValue/PublicKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ describe('CLPublicKey', () => {

const badFn = () => CLPublicKey.fromHex('1');
expect(badFn).to.throw('Asymmetric key error: too short');

// Check mixed case pubkeys
const goodFn = () =>
CLPublicKey.fromHex(
'0115C9b40c06fF99B0cBadf1140B061B5dBF92103E66a6330fbCc7768f5219C1ce'
);

expect(goodFn).to.not.throw();
});

it('CLPublicKey.fromEd25519() return proper value', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CLValue/PublicKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class CLPublicKey extends CLValue {
if (publicKeyHex.length < 2) {
throw new Error('Asymmetric key error: too short');
}
if (!/^0(1[0-9a-f]{64}|2[0-9a-f]{66})$/.test(publicKeyHex)) {
if (!/^0(1[0-9a-fA-F]{64}|2[0-9a-fA-F]{66})$/.test(publicKeyHex)) {
throw new Error('Invalid public key');
}
const publicKeyHexBytes = decodeBase16(publicKeyHex);
Expand Down

0 comments on commit 1c78106

Please sign in to comment.