CRYPTO NEWS

Basic Mapping Question

Very basic question but would appreciate any help understanding this. I don’t quite understand the logic behind the += operator within the below mapping. Please see below code

function getBalance() public view returns(uint) {         return address(this).balance;     }      function sendMoney() public payable {         balanceReceived[msg.sender] += msg.value;     } 

How can you logically add and assign and have – balanceReceived [msg.sender] = balanceReceived [msg.sender] + msg.value?

I am sure I am looking at this the wrong way but the balanceRecieved [msg.sender] is a address so how can you add that to a uint value of msg.value?

How does this libgcrypt elgamal decryption work?

libgcrypt elgamal decryption introduces a random prime to perform decryption. Can anyone explain to my how this is working? I have posted the edited source code showing just the relevant operations. skey->p is the prime modulus, skey->x is the secret key of the receiver, and the encrypted message is (a,b). I don’t understand the introduction::Listen

libgcrypt elgamal decryption introduces a random prime to perform decryption. Can anyone explain to my how this is working? I have posted the edited source code showing just the relevant operations. skey->p is the prime modulus, skey->x is the secret key of the receiver, and the encrypted message is (a,b). I don’t understand the introduction of r to perform the decryption here. I would have thought t1=a^x mod p would have been sufficient. then the message could be calculated as b*t1^-1 mod p

/* We need a random number of about the prime size.  The random
     number merely needs to be unpredictable; thus we use level 0.  */
  _gcry_mpi_randomize (r, nbits, GCRY_WEAK_RANDOM);

  /* t1 = r^x mod p */
  mpi_powm (t1, r, skey->x, skey->p);

  /* t2 = (a * r)^-x mod p */
  mpi_mulm (t2, a, r, skey->p);

  mpi_powm (t2, t2, skey->x, skey->p);

  mpi_invm (t2, t2, skey->p);

  /* t1 = (t1 * t2) mod p*/
  mpi_mulm (t1, t1, t2, skey->p);


  mpi_mulm (output, b, t1, skey->p);

Basic Mapping Question

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