CRYPTO NEWS

How to sign and verify data with ethereumjs-utils?

In my contract I’m verifying if some data was correctly signed by the owner. It looks like this:

require(     owner() ==         ecrecover(keccak256(abi.encodePacked(this, aCustomId)), v, r, s),         "owner should sign aCustomId"     ); 

Which means i should be retrieving v, r, s from a backend, which I currently do like this:

import * as ethUtil from 'ethereumjs-util';  const hash = soliditySha3(   'myContractAddress',   '11111', ); const signature = ethUtil.ecsign(     ethUtil.toBuffer(hash),     wallet.getPrivateKey(), );  return {       r: ethUtil.bufferToHex(signature.r),       s: ethUtil.bufferToHex(signature.s),       v: signature.v,       aCustomId: 11111, }; // return the v, r, s 

however, it seems like it’s not correct as I keep getting "owner should sign aCustomId".

How can i create the correct hash so my v,r,s parameters are correct for recovering later ?

I’m using solidity version 0.6.12

The contract is called something like this:

myContract.methods     .someMethod(         11111,         vValueAsInt,         "sValue",         "rValue",     )     .send({ from: account }, function(         error: any,         transactionHash: any     ) {         console.log(transactionHash);         console.log(error);     }); 

How to break up plaintext for RSA?

Given a plaintext of length 20 over the latin alphabet {A, B, . . . , Z} and the RSA key (n, e) with n = 77. Find a way to break up the plaintext in as little as possible blocks of information, each of which can be encrypted by the RSA algorithm using the::Listen

Given a plaintext of length 20 over the latin alphabet {A, B, . . . , Z} and the
RSA key (n, e) with n = 77. Find a way to break up the plaintext
in as little as possible blocks of information, each of which can be encrypted by
the RSA algorithm using the given key.

My question is,

  1. What are the possibilities for a plaintext (length 20). Is it $26^{20}$ or $26 nPr 20$?

I think, since we have 26 characters we are in the sense writing as 20 characters, then a permutation should be what is needed since we essentially write all possible ways 26 length can be ‘expressed’ into 20 length (permuting).

  1. What is a way to break it up? Taking $log_{77}{P}$ seems like a way. Is there any other way? Even with $log_{77}{P}$, how do I actually proceed to encrypting?

How to sign and verify data with ethereumjs-utils?

Shopping cart
There are no products in the cart!
Continue shopping
0