Skip to content

Commit

Permalink
refactor: add privatekey offset variable for better naming
Browse files Browse the repository at this point in the history
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
  • Loading branch information
ivaylonikolov7 committed Aug 7, 2024
1 parent 6508cc0 commit 710799e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cryptography/src/EcdsaPrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ export default class EcdsaPrivateKey {
const bytes = new Uint8Array(derPrefixBytes.length + 32);
const privateKey = this._keyPair.privateKey.subarray(0, 32);
const leadingZeroes = 32 - privateKey.length;
const privateKeyOffset = derPrefixBytes.length + leadingZeroes;
bytes.set(derPrefixBytes, 0);
bytes.set(privateKey, derPrefixBytes.length + leadingZeroes);
bytes.set(privateKey, privateKeyOffset);
return bytes;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/cryptography/src/Ed25519PrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ export default class Ed25519PrivateKey {
const bytes = new Uint8Array(derPrefixBytes.length + 32);
const privateKey = this._keyPair.secretKey.subarray(0, 32);
const leadingZeroes = 32 - privateKey.length;
const privateKeyOffset = derPrefixBytes.length + leadingZeroes;

bytes.set(derPrefixBytes, 0);
bytes.set(privateKey, derPrefixBytes.length + leadingZeroes);
bytes.set(privateKey, privateKeyOffset);

return bytes;
}
Expand Down

0 comments on commit 710799e

Please sign in to comment.