Skip to content

nokitakaze/pedersen-hash.net

Repository files navigation

Pedersen-Hash.Net

Build status Test status codecov Nuget version Total nuget downloads

This project is a C# implementation of Pedersen Hash used in Tornado Cash encrypted notes.

Public Interface

  • PedersenHashGenerator.GetHexCommitmentFromPrivatePair(string commitmentSecret): string — Get hexed public commitment for hex commitment secret
  • PedersenHashGenerator.GetHexCommitmentFromPrivatePair(byte[] commitmentSecret): string — Get hexed public commitment for byte array commitment secret
  • PedersenHashGenerator.GetCommitmentFromPrivatePair(string commitmentSecret): byte[] — Get 32-bytes array with public commitment for hex commitment secret
  • PedersenHashGenerator.GetCommitmentFromPrivatePair(byte[] commitmentSecret): byte[] — Get 32-bytes array with public commitment for byte array commitment secret

Example

Check commitment

var commitment = PedersenHashGenerator.GetHexCommitmentFromPrivatePair("0xc0b94c09303630d49984ee319ef44beb1cd29eb6d4f1f7fb8955731d76d79a5e94e1676adba37f0c7110db02b3cdc526f960d4c2685da441597c7533aa3d");
const string expectedCommitment = "0x01cd97f5fb94b8bd45979703af68790dff36dfb13c8227d6b68349fac72ff949";

Console.WriteLine("{0}\t{1}", commitment, commitment == expectedCommitment);

Benchmark

License

Licensed under the GPL-3.0.

This software is provided "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Source code was transpiled from JavaScript code: