These are chat archives for Nethereum/Nethereum

20th
Sep 2018
Juan Blanco
@juanfranblanco
Sep 20 2018 06:21
@Ilchuk-Mihail there is a EthereumMessageSigner already https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Signer/EthereumMessageSigner.cs this does the prefix, the prefix is not taken into account in solidity so it is a simple sign as you are doing . You should not need to do a Web3.Sha3() either..
You can sign passing a byte array directly using HashAndSign
and if you pass a string it will be UTF8 encoded
so in Solidity you will recover using the hash of your string and the signature
@spied001 cool :)
Michael Ilchuk
@Ilchuk-Mihail
Sep 20 2018 11:58
@juanfranblanco Why Web3.Sha3(message) , returns hash without 0x ?
kirkilyduck
@kirkilyduck
Sep 20 2018 12:09
Is there an equivalent for solidity abi.encodePacked(variable1, variable2, variable3, ..) in nethereum.
Juan Blanco
@juanfranblanco
Sep 20 2018 12:40
@Ilchuk-Mihail the 0x does not change the value of the hex
@kirkilyduck check this issue Nethereum/Nethereum#420
it explains how to achieve it
kirkilyduck
@kirkilyduck
Sep 20 2018 13:25
@juanfranblanco thank you it works
Juan Blanco
@juanfranblanco
Sep 20 2018 13:28
awesome :)
kirkilyduck
@kirkilyduck
Sep 20 2018 14:55
Is it possible to sign a message with private key
public override string Sign(byte[] message, EthECKey key)
{
return base.Sign(HashPrefixedMessage(message), key);
}
web3.eth.sign(addr, dataToSign) does not need any private key
Juan Blanco
@juanfranblanco
Sep 20 2018 15:01
yeah
or MessageSigner
kirkilyduck
@kirkilyduck
Sep 20 2018 15:03
So I need private key of the address
EthereumMessageSigner ethSigner = new EthereumMessageSigner();
string signedMessage = ethSigner.Sign(HexByteConvertorExtensions.HexToByteArray(result), pStrOwnerAddr);
result = "0x2b7e4d7840909fee29bb94869ab2e00f9ba713b399068881a038f0d4146ffd6f"
pStrOwnerAddr = "0x26197c6386372c150b7dc8c8c18053675a2e3b97" (address[0] from ganache)
signedMessage = "0x7a15a06e9272bed153d1fae0c8d1ec88d23465b2c8b69eb0d73df39b9968873337b19118750e277dc9314995bbb6a0c32b9341dfd3e2138caea77e39fb6823481c"
but when I do the following in web3js
web3.eth.sign("0x26197c6386372c150b7dc8c8c18053675a2e3b97", "0x2b7e4d7840909fee29bb94869ab2e00f9ba713b399068881a038f0d4146ffd6f")
'0x78ec78c3aff924618506fe09b7df8c8fc1fa6cf60d17107e4796d6d5ff6bcc32454c5910b31efc29bc237d8fe956caf9d9a53bf4ac3fcf75ba70f200ca5e29a701'
the two results are not the same
kirkilyduck
@kirkilyduck
Sep 20 2018 15:08
am i doing something wrong here?
Juan Blanco
@juanfranblanco
Sep 20 2018 15:10
if you sign with it will use the prefix
sorry without syntax highlighting cannot see very well :)
are you using ganache to do the signing?
not geth?
also are you using your privatekey?
kirkilyduck
@kirkilyduck
Sep 20 2018 15:12
I am using ganache and not geth,
Juan Blanco
@juanfranblanco
Sep 20 2018 15:12
cannot see your privateKey there
kirkilyduck
@kirkilyduck
Sep 20 2018 15:12
I don't have privatekey from ganache
Juan Blanco
@juanfranblanco
Sep 20 2018 15:13
well without your private key
you cannot sign anything, without delegating it to ganache / geth / parity
also i don't know if ganache implements the prefix for signing i guess they do now
when you start ganache you get a list of privatekeys
also if you look at our testchains
you can start ganache with a privatekey
kirkilyduck
@kirkilyduck
Sep 20 2018 15:17
Yes now I got the privatekey of the 0th account and they are producing the same Sign
Is there a different way to handle this without jeopardizing the private key?
Juan Blanco
@juanfranblanco
Sep 20 2018 15:18
no
obviously you can delegate the signing to something else
but that is what you are doing here
"something else" can be an isolated Nethereum.Signer
or a hardware signer
kirkilyduck
@kirkilyduck
Sep 20 2018 15:19
I am not sure of getting the private key for an account in geth.
Juan Blanco
@juanfranblanco
Sep 20 2018 15:20
you can create your own account if you want or read the keystore files
kirkilyduck
@kirkilyduck
Sep 20 2018 15:20
I will figure out how to delegate it to an isolated Signer
this will help to understand how keys are managed / created etc
kirkilyduck
@kirkilyduck
Sep 20 2018 15:21
wow
thank you
this will help me
that might help you later on too ;)
kirkilyduck
@kirkilyduck
Sep 20 2018 16:01
Is there a way to get r,s,v parameters from signed message
what is derSig array here
public EthECDSASignature(byte[] derSig)
{
ECDSASignature = new ECDSASignature(derSig);
}
Twilight Punkster
@twilightpunkster
Sep 20 2018 18:25
Am I at the right place to bug people with Nethereum questions in Unity? I got some problems with getting things to work in 2018.2
Twilight Punkster
@twilightpunkster
Sep 20 2018 19:45
Nevermind, fixed it.
Agente del Caos
@Genzafel_twitter
Sep 20 2018 23:00

Hi, I'm having trouble to connect to a Private Azure Blockchain Consortium using Nethereum, but I'm having this error when consuming my service

Message: authentication needed: password or unlock

Trying to use RpcClient and AuthenticationHeaderValue, anyone has any idea why is not working?