Skip to main content
added 5 characters in body
Source Link
nick carraway
  • 1.1k
  • 1
  • 9
  • 23

If you're trying to decrypt data on-chain, I recommend using a hashing function on your data appended to a random ethereum address for entropy. Here's how:

  1. Post hashed data inside your given data variable on-chain. For all intents and purposes, this data is encrypted, as nobody but you knows the hash inputs that generated this hash output.
  2. This data is a hash made by: web3.utils.soliditySha3([realData, randomAddress]) off-chain inside Web3js. You keep both these inputs a secret from the blockchain.
  3. When you want to decrypt this hash, post the realData and randomAddress to a smart contract. Hash them on-chain using solidity's keccak256 function. keccak256(abi.encodePacked(uint256 realData, address randomAddress)).
  4. If the on-chain hash matches the data variable, then this data has effectively been decrypted.

Originally I wrote my answer using only signatures but that was wrong. You cannot use a signature function for this (it also costs more gas anyway). For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you want to make sure the hash came from an authorized user, use a mapping object to store the hashes based on a msg.sender variable. msg.sender is effectively a signature as it is.

If you're trying to decrypt data on-chain, I recommend using a hashing function on your data appended to a random ethereum address for entropy. Here's how:

  1. Post hashed data inside your given data variable on-chain. For all intents and purposes, this data is encrypted, as nobody but you knows the hash inputs that generated this hash output.
  2. This data is a hash made by: web3.utils.soliditySha3([realData, randomAddress]) off-chain inside Web3js. You keep both these inputs a secret from the blockchain.
  3. When you want to decrypt this hash, post the realData and randomAddress to a smart contract. Hash them on-chain using solidity's keccak256 function. keccak256(abi.encodePacked(uint256 realData, address randomAddress)).
  4. If the on-chain hash matches the data variable, then this data has effectively been decrypted.

Originally I wrote my answer using signatures but that was wrong. You cannot use a signature function for this (it also costs more gas anyway). For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you want to make sure the hash came from an authorized user, use a mapping object to store the hashes based on a msg.sender variable. msg.sender is effectively a signature as it is.

If you're trying to decrypt data on-chain, I recommend using a hashing function on your data appended to a random ethereum address for entropy. Here's how:

  1. Post hashed data inside your given data variable on-chain. For all intents and purposes, this data is encrypted, as nobody but you knows the hash inputs that generated this hash output.
  2. This data is a hash made by: web3.utils.soliditySha3([realData, randomAddress]) off-chain inside Web3js. You keep both these inputs a secret from the blockchain.
  3. When you want to decrypt this hash, post the realData and randomAddress to a smart contract. Hash them on-chain using solidity's keccak256 function. keccak256(abi.encodePacked(uint256 realData, address randomAddress)).
  4. If the on-chain hash matches the data variable, then this data has effectively been decrypted.

Originally I wrote my answer using only signatures but that was wrong. You cannot use a signature function for this (it also costs more gas anyway). For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you want to make sure the hash came from an authorized user, use a mapping object to store the hashes based on a msg.sender variable. msg.sender is effectively a signature as it is.

added 120 characters in body
Source Link
nick carraway
  • 1.1k
  • 1
  • 9
  • 23

You can useIf you're trying to decrypt data on-chain, I recommend using a signaturehashing function on your data appended to a random ethereum address for thisentropy. Here's how:

  1. Post a signature to a blockchainhashed data inside your given data variable on-chain. Nobody knows who signedFor all intents and purposes, this signature or whatdata is encrypted, as nobody but you knows the hash inputs that generated this hash output.
  2. This data containsis a hash made by: web3.utils.soliditySha3([realData, randomAddress]) off-chain inside Web3js. You keep both these inputs a secret from the blockchain.
  3. WheneverWhen you want to   decrypt this signature, provide the address that signed ithash, as well as the data it contains. As long aspost the address you signed it with is new (i.erealData and randomAddress to a smart contract. randomlyHash them on-generated), the data remains hidden until this timechain using solidity's keccak256 function. keccak256(abi.encodePacked(uint256 realData, address randomAddress)).
  4. Do the validation ofIf the signature on-chain so your smart contracts can respond to a correctly decryptedhash matches the (i.e. proven signature) valuedata variable, then this data has effectively been decrypted.
 

Because Web3 is constantly changing, look into the Open-Zeppelin SignatureBouncer.sol contracts, as well as their tests in Web3 for working Solidity/Javascript codeOriginally I wrote my answer using signatures but that was wrong. There are about 10,000 badYou cannot use a signature signing examples on Google because of the changes to Web3 and solidityfunction for this (it also costs more gas anyway).

  For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you want to make sure the hash came from an authorized user, use a mapping object to store the hashes based on a msg.sender variable. msg.sender is effectively a signature as it is.

You can use a signature function for this. Here's how:

  1. Post a signature to a blockchain. Nobody knows who signed this signature or what the data contains.
  2. Whenever you want to decrypt this signature, provide the address that signed it, as well as the data it contains. As long as the address you signed it with is new (i.e. randomly-generated), the data remains hidden until this time.
  3. Do the validation of the signature on-chain so your smart contracts can respond to a correctly decrypted (i.e. proven signature) value.

Because Web3 is constantly changing, look into the Open-Zeppelin SignatureBouncer.sol contracts, as well as their tests in Web3 for working Solidity/Javascript code. There are about 10,000 bad signature signing examples on Google because of the changes to Web3 and solidity.

  For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you're trying to decrypt data on-chain, I recommend using a hashing function on your data appended to a random ethereum address for entropy. Here's how:

  1. Post hashed data inside your given data variable on-chain. For all intents and purposes, this data is encrypted, as nobody but you knows the hash inputs that generated this hash output.
  2. This data is a hash made by: web3.utils.soliditySha3([realData, randomAddress]) off-chain inside Web3js. You keep both these inputs a secret from the blockchain.
  3. When you want to   decrypt this hash, post the realData and randomAddress to a smart contract. Hash them on-chain using solidity's keccak256 function. keccak256(abi.encodePacked(uint256 realData, address randomAddress)).
  4. If the on-chain hash matches the data variable, then this data has effectively been decrypted.
 

Originally I wrote my answer using signatures but that was wrong. You cannot use a signature function for this (it also costs more gas anyway). For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

If you want to make sure the hash came from an authorized user, use a mapping object to store the hashes based on a msg.sender variable. msg.sender is effectively a signature as it is.

added 154 characters in body
Source Link
nick carraway
  • 1.1k
  • 1
  • 9
  • 23

You can use a signature function for this. Here's how:

  1. Post a signature to a blockchain. Nobody knows who signed this signature or what the data contains.
  2. Whenever you want to decrypt this signature, provide the address that signed it, as well as the data it contains. As long as the address you signed it with is new (i.e. randomly-generated), the data remains hidden until this time.
  3. Do the validation of the signature on-chain so your smart contracts can respond to a correctly decrypted (i.e. proven signature) value.

Because Web3 is constantly changing, look into the Open-Zeppelin SignatureBouncer.sol contracts, as well as their tests in Web3 for working Solidity/Javascript code. There are about 10,000 bad signature signing examples on Google because of the changes to Web3 and solidity.

For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

You can use a signature function for this. Here's how:

  1. Post a signature to a blockchain. Nobody knows who signed this signature or what the data contains.
  2. Whenever you want to decrypt this signature, provide the address that signed it, as well as the data it contains. As long as the address you signed it with is new (i.e. randomly-generated), the data remains hidden until this time.
  3. Do the validation of the signature on-chain so your smart contracts can respond to a correctly decrypted (i.e. proven signature) value.

Because Web3 is constantly changing, look into the Open-Zeppelin SignatureBouncer.sol contracts, as well as their tests in Web3 for working Solidity/Javascript code. There are about 10,000 bad signature signing examples on Google because of the changes to Web3 and solidity.

You can use a signature function for this. Here's how:

  1. Post a signature to a blockchain. Nobody knows who signed this signature or what the data contains.
  2. Whenever you want to decrypt this signature, provide the address that signed it, as well as the data it contains. As long as the address you signed it with is new (i.e. randomly-generated), the data remains hidden until this time.
  3. Do the validation of the signature on-chain so your smart contracts can respond to a correctly decrypted (i.e. proven signature) value.

Because Web3 is constantly changing, look into the Open-Zeppelin SignatureBouncer.sol contracts, as well as their tests in Web3 for working Solidity/Javascript code. There are about 10,000 bad signature signing examples on Google because of the changes to Web3 and solidity.

For more information: https://crypto.stackexchange.com/questions/43894/asymmetry-between-public-key-and-private-key-digital-signatures-use-the-private

Post Undeleted by nick carraway
Post Deleted by nick carraway
added 109 characters in body
Source Link
nick carraway
  • 1.1k
  • 1
  • 9
  • 23
Loading
Source Link
nick carraway
  • 1.1k
  • 1
  • 9
  • 23
Loading