Skip to content

Commit

Permalink
Add padding when creatin the salt before making the commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
javiesses committed Dec 12, 2019
1 parent 8b4bb1d commit 92f5848
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/app/tabs/registrar/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export const getRegisterData = (name, owner, secret, duration) => {
const dataOwner = owner.toLowerCase().slice(2);

// 32 bytes
let dataSecret = secret.slice(2);
const padding = 64 - dataSecret.length;
for (let i = 0; i < padding; i += 1) {
dataSecret += '0';
}
const dataSecret = secret.slice(2);

// 32 bytes
const dataDuration = numberToUint32(duration);
Expand Down
3 changes: 2 additions & 1 deletion src/app/tabs/registrar/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const commit = domain => async (dispatch) => {
dispatch(requestCommitRegistrar());

const randomBytes = window.crypto.getRandomValues(new Uint8Array(32));
const salt = `0x${Array.from(randomBytes).map(byte => byte.toString(16)).join('')}`;
const strSalt = Array.from(randomBytes).map(byte => byte.toString(16)).join('');
const salt = `0x${strSalt.padEnd(64, '0')}`;

const accounts = await window.ethereum.enable();
const currentAddress = accounts[0];
Expand Down

0 comments on commit 92f5848

Please sign in to comment.