CRYPTO NEWS

Problem with Solidity functions

I hope you are all well.

I have 2 functions. The "transferFrom function" allows a third party to send ether from an account which is owned by another address. The "approve" function is used to allow the third party to use the "transferFrom" function.

My problem is that when I want to use the "transferFrom" function it does not work and my web browser displays this error message: "MetaMask – RPC Error: Invalid parameters: must provide an Ethereum address." The addresses are Ethereum addresses.

Here are the functions:

 function transferFrom(address from, address to, uint value) public returns(bool) {       uint allowance = allowed[from][msg.sender];       require(allowance >= value, 'allowance too low');       require(balances[from] >= value, 'token balance too low');       allowed[from][msg.sender] -= value;       balances[from] -= value;       balances[to] += value;       emit Transfer(from, to, value);       return true;          }      function approve(address spender, uint value) public returns(bool) {       require(spender != msg.sender, 'spender must not be sender');       allowed[msg.sender][spender] = value;       emit Approval(msg.sender, spender, value);       return true;   

Would you have an idea on how to solve this problem please?

Thank you very much

Take care

Pierre

How would you explain this very simple add/modulo asymmetric encryption?

I am working on a presentation aimed at developers without a strong mathematical background (like me). I would like to explain how asymmetric encryption works with an non-fully-secure but working example. I found one on Stackoverflow based on addition and modulo: given a range from 1 to M given a and b where a+b =::Listen

I am working on a presentation aimed at developers without a strong mathematical background (like me). I would like to explain how asymmetric encryption works with an non-fully-secure but working example.

I found one on Stackoverflow based on addition and modulo:

  • given a range from 1 to M
  • given a and b where a+b = M
  • a is the public key, b is the private key
  • x is the clear data (just a number)
  • y is the encrypted data
  • y = (x + a) mod M
  • x = (y + b) mod M

Example :

M=10, a=3, b=7, x=4  
y = (4+3) mod 10 = 7  
(7 + 7) mod 10 = 4  

Say that an adversary knows the algorithm and a, y, M.
We suppose that adversary cannot guess b from a.
Reverse modulo has multiple results :

4 mod 3 = 1  
7 mod 3 = 1  
13 mod 3 = 1  

Meaning an adversary cannot easily find

x+a 

from

(x+a) mod M

Even this is really simple, and I "feel" the modulo "wrap-around" I could not find anyway to explain WHY this works :

y = (x + a) mod M
x = (y + b) mod M

Does anyone could try to explain it to me ?

Problem with Solidity functions

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