Skip to content

Commit

Permalink
Fix signature overflow
Browse files Browse the repository at this point in the history
(cherry picked from commit 3ae40ee)
  • Loading branch information
ikonovalov committed May 30, 2017
1 parent c36c163 commit 8611fe3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd-ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = {
.then(ecTag => {
let account = ecTag.partyAddress;
console.log(`Decrypting tag... Party account ${account}.`);
let password = ask.password({ignoreConfig: true});
let password = 'dlheu0' || ask.password({ignoreConfig: true});
const selfKeyPair = fileForce.unlockKeys(account, password);
return {
selfKeyPair: selfKeyPair,
Expand Down
8 changes: 5 additions & 3 deletions lib/libfileforce.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ class FileForce extends EventEmitter {
let ipfsHash = rootBlock.hash;

let mHashArray = multihash.fromB58String(ipfsHash); // it still include first 2 bytes for a schema
let signature = libcrypto.sign(mHashArray, ownerKeyPair.privateKey);
let truncated256b = mHashArray.slice(2);
let signature = libcrypto.sign(truncated256b, ownerKeyPair.privateKey);
let tag = {
algorithm: encryptionParams.algorithm,
iv: encryptionParams.iv,
Expand Down Expand Up @@ -308,11 +309,12 @@ class FileForce extends EventEmitter {
recoveryParam: tag.signature.v
};
let message = multihash.fromB58String(tag.ipfs);
let recoveredPublicKey = libcrypto.recovery(signature, message);
let truncated256b = message.slice(2);
let recoveredPublicKey = libcrypto.recovery(signature, truncated256b);
let recoveredAddress = libcrypto.publicToAddress(recoveredPublicKey);

if (!providedPublicKey) {
let signatureValidation = libcrypto.verify(signature, message, recoveredPublicKey);
let signatureValidation = libcrypto.verify(signature, truncated256b, recoveredPublicKey);
resolve({
authorPublicKey: ethUtils.bufferToHex(Buffer.from(recoveredPublicKey)),
authorAddress: recoveredAddress,
Expand Down

0 comments on commit 8611fe3

Please sign in to comment.