These are chat archives for Nethereum/Nethereum

16th
May 2017
Juan Blanco
@juanfranblanco
May 16 2017 08:07 UTC
@mtbitcoin that is the same as concatenating the strings
(isnt it? you make me doubt now)
@olibd checking on it
Matt.Tan
@mtbitcoin
May 16 2017 08:14 UTC
@juanfranblanco yes. sort of. This is the equivalent in web3.js
var hash2 = web3.sha3("0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae" + "0x0d57c7d8b54ebf963f94cded8a57a1b109ac7465ada218575473648bf373b90d".slice(2), { encoding: 'hex' })
Juan Blanco
@juanfranblanco
May 16 2017 08:15 UTC
@olibd same issue if using the simplified method
I cannot see the issue on your contract code (cannot read the byte code ;) )
@mtbitcoin I see it now, that will be handy, the encoding specially as it will use the bytes, instead of a string (UTF)
Matt.Tan
@mtbitcoin
May 16 2017 08:20 UTC
i am try to do the following but its not working
Dim Name_hash As Byte() = "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae".HexToByteArray.Concat("0x0d57c7d8b54ebf963f94cded8a57a1b109ac7465ada218575473648bf373b90d".HexToByteArray)
Andres G. Aragoneses
@knocte
May 16 2017 08:20 UTC
vb.net? omg x-D
Matt.Tan
@mtbitcoin
May 16 2017 08:22 UTC
:smile:
Juan Blanco
@juanfranblanco
May 16 2017 08:23 UTC
beauty of .net c#, vb.net, f#, boo, ironpython... j# (whatever happen to that)
@mtbitcoin Ill have a look
Matt.Tan
@mtbitcoin
May 16 2017 08:25 UTC
yes , it all goes through the IL and comes out the same (similar) :-) ... that is the the pure beauty of .NET
FYI only, the above is for the ENS. To get the the nameHash by just only knowing the LabelHash, we can Sha3(root.Registrar + label) = NameHash
@mtbitcoin but to workout the name hash does not work the same by splitting using the .
Matt.Tan
@mtbitcoin
May 16 2017 11:21 UTC
@juanfranblanco there is 2 ways to to get the name hash. The first way is like you have ensUtil.GetEnsNameHash("myname.eth");
But the second way is the end user can provide you just with the label hash for a particular registrar (.eth). And by using the label hash we can then generate the namehash using sha3(root.Registrar, labelhash)
and when we have the namehash we can use the namehash has to lookup the resolver info.
To lookup the ENS resolver info requires either the GetEnsNameHash(myname.eth) or the NameHash
Juan Blanco
@juanfranblanco
May 16 2017 11:25 UTC
ah got you
so that will be..
 var byteInput = (node + GetEnsLabelHash(labels[i])).HexToByteArray();
                    node = kecckak.CalculateHash(byteInput).ToHex();
where node is the register hash
as a string
and the label is the string i.e "name"
if we are concatenating
we have both hashes it will be
Juan Blanco
@juanfranblanco
May 16 2017 11:31 UTC
var byteInput = (node + label).HexToByteArray();
node = kecckak.CalculateHash(byteInput).ToHex();
so in your example
it will be better to do.. (I don't know why it does not work)
var byteInput = ("0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae" + "0d57c7d8b54ebf963f94cded8a57a1b109ac7465ada218575473648bf373b90d").HexToByteArray();
node = kecckak.CalculateHash(byteInput).ToHex();
Matt.Tan
@mtbitcoin
May 16 2017 11:55 UTC
brilliant! thanks Juan
Juan Blanco
@juanfranblanco
May 16 2017 11:56 UTC
I am adding an overload now to sha3 to do the same
 public string CalculateHashFromHex(params string[] hexValues)
        {
            var joinedHex = String.Join("", hexValues.Select(x => x.RemoveHexPrefix()).ToArray());
            return CalculateHash(joinedHex.HexToByteArray()).ToHex();
        }
Juan Blanco
@juanfranblanco
May 16 2017 12:39 UTC
tested with yours ^^^ Ill check in shortly
@mtbitcoin ^^
Matt.Tan
@mtbitcoin
May 16 2017 17:58 UTC
+1
olibd
@olibd
May 16 2017 19:18 UTC
@juanfranblanco its odd, how much gas are you supplying? With 3905820 here the simplified method works
Juan Blanco
@juanfranblanco
May 16 2017 22:01 UTC
@olibd passing that gas it works both ways
I might have been blind as the original call seem to use less gas than supplied
as usual.. not enough gas