Try   HackMD

The details of FHE-DKSAP with AA

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

The technical details of FHE-DKSAP can be found as follows:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

The details of the "recover" function implementation:
The implementation of signing requires two components: the data to be signed and the account executing the signing. The signing process can be achieved using web3.eth.sign(). The specific code is:

let msg = web3.sha3('today is 20171026')
let signature = web3.eth.sign(address, msg)

Here, we used the address account to sign the message 'today is 20171026'. The returned value signature is

0x125a275046b65a96f11fdb7cd1072054e67526a76f54b1622fde4e4592d6fe2d5bf664ace77da52c6f94f08a56077e5d7a80048f70c38a92169205df3c9c43ea1b

According to the ECDSA algorithm:

let r = signature.slice(0, 66)
let s = '0x' + signature.slice(66, 130)
let v = '0x' + signature.slice(130, 132)
v = web3.toDecimal(v)

In the verification process, we use the function of ecrecover, it takes the hash value of the data and parameters such as r/s/v as inputs and returns the address of the account that performed the signature. Thus, we just need to obtain the signing address through the contract and compare it with our actual address. If the addresses match, it means the verification is successful. The code of the contract can be found as follows:

contract Auth {      
    function verify( bytes32 hash, uint8 v, bytes32 r, bytes32 s) constant returns(address retAddr) {
      bytes memory prefix = "\x19Ethereum Signed Message:\n32";
      bytes32 prefixedHash = sha3(prefix, hash);
      return ecrecover(prefixedHash, v, r, s);
    }
}

Deploy this smart contract to a private chain, obtain the contract's address and ABI (Application Binary Interface), which will be used for the subsequent code to interact with the contract.

const contract=web3.eth.contract(abi).at('0x2e2A4cD2869862492C744307310847466c008257');
console.log(contract.verify(msg, v, r, s));
console.log(address)

Finally, we can get the result:

0xe0803904cbfce8e07745e1b404de43ce6f1e43bc
0xe0803904cbfce8e07745e1b404de43ce6f1e43bc

We can see that the address used to implement the signature is consistent with the address returned after verification, and the signature passes verification.