dariogriffo / sha3.net

C# port of Keccak, known as SHA3
MIT License
46 stars 5 forks source link

keccak256 c# not match solidity #39

Closed borisgr04 closed 7 months ago

borisgr04 commented 7 months ago

Hi @dariogriffo `cs

using (var shaAlg = Sha3.Sha3256()) { var hash = shaAlg.ComputeHash(Encoding.UTF8.GetBytes("11")); return hash.ToHex(false); } ` //result 4410fc15c5a3cde7a2b5366a41dbc95e6547a6021efdff98cfcd5e875e8c3c70

function Insert(string memory transactionId)public pure returns (bytes32) { bytes32 id = keccak256(bytes(transactionId)); return id; } result 0x7880aec93413f117ef14bd4e6d130875ab2c7d7d55a064fac3c2f7bd51516380

Then this result not match

dariogriffo commented 7 months ago

Hi boris, since .net added support for sha3 I'm no longer maintaining this library Look at this https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.sha3_256?view=net-8.0

borisgr04 commented 7 months ago

Thank you

Try the native dotnet

Obtener Outlook para iOShttps://aka.ms/o0ukef


De: Dario Griffo @.> Enviado: Thursday, April 11, 2024 1:38:10 PM Para: dariogriffo/sha3.net @.> Cc: Boris González Rivera @.>; Author @.> Asunto: Re: [dariogriffo/sha3.net] keccak256 c# not match solidity (Issue #39)

Hi boris, since .net added support for sha3 I'm no longer maintaining this library Look at this https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.sha3_256?view=net-8.0

— Reply to this email directly, view it on GitHubhttps://github.com/dariogriffo/sha3.net/issues/39#issuecomment-2050293329, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAS4TI7EWFXAWG4KZHTQRPLY43KBFAVCNFSM6AAAAABGCYZXIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJQGI4TGMZSHE. You are receiving this because you authored the thread.Message ID: @.***>

dariogriffo commented 7 months ago

Also checked my lib here https://emn178.github.io/online-tools/sha3_256.html result matches https://github.com/dariogriffo/sha3.net/issues/39#issuecomment-2050412466

try 11 there and then go to

https://dotnetfiddle.net/dV1faZ

https://dotnetfiddle.net/ on the left select net6 install the sha3 package and run the following


using System;
using SHA3.Net;

public class Program
{
    public static void Main()
    {
        using (var shaAlg = Sha3.Sha3256())
{   
    var data = shaAlg.ComputeHash(System.Text.Encoding.UTF8.GetBytes("11"));
            string hex = BitConverter.ToString(data).Replace("-", string.Empty).ToLowerInvariant();
            Console.WriteLine(hex);
}
    }
}
borisgr04 commented 7 months ago

Hi,

I required this behavior, but your nuget the result is 4410fc15c5a3cde7a2b5366a41dbc95e6547a6021efdff98cfcd5e875e8c3c70.

I required that result match with solity.

Keccak-256 - Online Tools (emn178.github.io)https://emn178.github.io/online-tools/keccak_256.html

[cid:5210fe5e-cd75-4030-8162-26ec3854cd85]

Ing. Boris González Rivera B&A Systems Construimos Soluciones

MÓVIL: 318-8780177

Por nuestra seguridad: Si decide reenviar este correo, colabore con dos tareas

  1. Borre todas las direcciones que aparezcan en el contenido del correo, incluyendo esta cuesta.
  2. Envie sus direcciones como copia oculta CCO

En cumplimiento de la Ley 527_99 ARTICULO 10. Los mensajes de datos ser??n admisibles como medios de prueba y su fuerza probatoria es la otorgada en las disposiciones del Cap??tulo VIII del T??tulo XIII, Secci??n Tercera, Libro Segundo del C??digo de Procedimiento Civil. En toda actuaci??n administrativa o judicial, no se negar?? eficacia, validez o fuerza obligatoria y probatoria a todo tipo de informaci??n en forma de un mensaje de datos, por el s??lo hecho que se trate de un mensaje de datos o en raz??n de no haber sido presentado en su forma original.

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


De: Dario Griffo @.> Enviado: jueves, 11 de abril de 2024 2:51 p. m. Para: dariogriffo/sha3.net @.> Cc: Boris González Rivera @.>; Author @.> Asunto: Re: [dariogriffo/sha3.net] keccak256 c# not match solidity (Issue #39)

Also checked my lib here https://emn178.github.io/online-tools/sha3_256.html result matches try 11 there and then go to https://dotnetfiddle.net/ on the left select net6 install the sha3 package and run the following

using System; using SHA3.Net;

public class Program { public static void Main() { using (var shaAlg = Sha3.Sha3256()) { var data = shaAlg.ComputeHash(System.Text.Encoding.UTF8.GetBytes("11")); string hex = BitConverter.ToString(data).Replace("-", string.Empty).ToLowerInvariant(); Console.WriteLine(hex); } } }

— Reply to this email directly, view it on GitHubhttps://github.com/dariogriffo/sha3.net/issues/39#issuecomment-2050412466, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAS4TI3DJ53TQFJQBUXTE5LY43SV7AVCNFSM6AAAAABGCYZXIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJQGQYTENBWGY. You are receiving this because you authored the thread.Message ID: @.***>