Git Product home page Git Product logo

Comments (1)

markkurossi avatar markkurossi commented on May 23, 2024

I created the test values with Go's crypto/sha256 and hmac packages:

package main

import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"

	"crypto/hmac"
)

func main() {
	key, err := hex.DecodeString("b598163d740b0973b8b312881bfe6601e031d33d9f15be97b0cc8898ae570932fd755ced0af309f7625f531ab01cdc0ba7130ae14b561b905f53777255174170")
	if err != nil {
		fmt.Print(err)
		return
	}
	fmt.Printf("key : %x\n", key)

	// 32 bytes of message
	msg := []byte("Hello, world!...................")
	fmt.Printf("msg : %x\n", msg)

	mac := hmac.New(sha256.New, key[:])
	mac.Write(msg)
	sum := mac.Sum(nil)
	fmt.Printf("sum : %x\n", sum)
}

and they return the same values as the MPC program:

key : b598163d740b0973b8b312881bfe6601e031d33d9f15be97b0cc8898ae570932fd755ced0af309f7625f531ab01cdc0ba7130ae14b561b905f53777255174170
msg : 48656c6c6f2c20776f726c64212e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e
sum : 60d27dbd14f1e351f20069171fead00ef557d17ac9a41d02baa488ca4b90171a

I checked the site you linked. It looks like it uses the key as ASCII string i.e. it is not decoding it as a hex-encoded value. With the values above, it gives me 5474050a2f93194eb8ad2a077417f5a51ad73181e9225ba512388539ad6da9cb.

If I change the sample Go program to create the key as:

key = []byte("b598163d740b0973b8b312881bfe6601e031d33d9f15be97b0cc8898ae570932fd755ced0af309f7625f531ab0")

I get the same result as the online tool:

key : 623539383136336437343062303937336238623331323838316266653636303165303331643333643966313562653937623063633838393861653537303933326664373535636564306166333039663736323566353331616230
msg : 48656c6c6f2c20776f726c64212e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e
sum : 5474050a2f93194eb8ad2a077417f5a51ad73181e9225ba512388539ad6da9cb

from mpc.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.