Skip to content

Commit

Permalink
Fix canonicalized raw secret key export length.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Jan 26, 2025
1 parent 871ed71 commit fba631e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# @digitalbazaar/ed25519-multikey ChangeLog

## 1.3.1 - 2025-mm-dd

### Fixed
- Fix canonicalized raw secret key export length.

## 1.3.0 - 2024-10-02

### Added
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ async function _createKeyPairInterface({keyPair}) {
if(secretKey) {
if(canonicalize && secretKey.length > SECRET_KEY_SIZE) {
result.secretKey = secretKey.subarray(0, SECRET_KEY_SIZE).slice();
} else {
result.secretKey = secretKey;
}
result.secretKey = secretKey;
}
return result;
}
Expand Down
11 changes: 11 additions & 0 deletions test/Ed25519Multikey.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ describe('Ed25519Multikey', () => {
expect(exported).to.have.property('id', 'did:ex:123#test-id');
expect(exported).to.have.property('type', 'Multikey');
});

it('should export raw private key w/canonical length', async () => {
const keyPair = await Ed25519Multikey.generate({
id: 'did:ex:123#test-id'
});
const exported = await keyPair.export({
raw: true, secretKey: true, canonicalize: true
});
expect(exported).to.have.property('secretKey');
expect(exported.secretKey.length).to.equal(32);
});
});

describe('from', () => {
Expand Down

0 comments on commit fba631e

Please sign in to comment.