Another reco check error


#1

Hi,

reco check is throwing up this error:

error[E004]: the types Hasht (alias for struct{A ;B ;C ;D ;E ;F ;G ;H} ) and uint32 are incompatible.
–> /home/foolmarks/go/src/sha256reco-master/.reco-work/gopath/src/sha256/sha256.go:84:2

Is this error message pointing to line 84 of sha256.go?

thanks,
Mark.


#2

Yes, that does correspond to line 84. What is the statement there, if you can share it?


#3

function look like this:

func round(k uint32, w uint32, roundIn Hasht) Hasht {
var (
roundOut Hasht
T1 uint32
T2 uint32
)

T1 = k + sigma1(roundIn.E) + ch(roundIn.E, roundIn.F, roundIn.G) + roundIn.H + w
T2 = sigma0(roundIn.A) + maj(roundIn.A, roundIn.B, roundIn.C)   // LINE #84
roundOut.A = T1 + T2
roundOut.B = roundIn.A
roundOut.C = roundIn.B
roundOut.D = roundIn.C
roundOut.E = roundIn.D + T1
roundOut.F = roundIn.E
roundOut.G = roundIn.F
roundOut.H = roundIn.G

return roundOut

}

…line #84 is: T2 = sigma0(roundIn.A) + maj(roundIn.A, roundIn.B, roundIn.C)

roundIn is a Hasht type which is made up of 8 fields of uint32. T2 is also uint32.

The code compiles and runs OK as part of “normal” go program.


#4

It appears we have trouble parsing multiple var declarations. I’ve filed this as an issue with our compiler team. If you do the following it works:

func round(k uint32, w uint32, roundIn Hasht) Hasht {
	var roundOut Hasht
	var T1 uint32
	var T2 uint32

	T1 = k + sigma1(roundIn.E) + ch(roundIn.E, roundIn.F, roundIn.G) + roundIn.H + w
	T2 = sigma0(roundIn.A) + maj(roundIn.A, roundIn.B, roundIn.C)
	roundOut.A = T1 + T2
	roundOut.B = roundIn.A
	roundOut.C = roundIn.B
	roundOut.D = roundIn.C
	roundOut.E = roundIn.D + T1
	roundOut.F = roundIn.E
	roundOut.G = roundIn.F
	roundOut.H = roundIn.G

	return roundOut

}

#5

Doing the same thing in all my files leads to another error:

Error: error(s) found while checking /home/foolmarks/go/src/sha256reco-master/main.go

At the path: [“declarations”][1][“body”][5][“target”][“function”][“body”][3][“target”]invariant violated

…it happens when I change this:

var (
    mexpBuffer [64]uint32 // message expansion buffer 64x32bits
    tempVar sha256.PadBlkt
    roundOut sha256.Hasht
digest = sha256.Hasht{A: 0x6a09e667, B: 0xbb67ae85, C: 0x3c6ef372, D: 0xa54ff53a, E: 0x510e527f, F: 0x9b05688c, G: 0x1f83d9ab, H: 0x5be0cd19}
     k = [64]uint32{0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
		0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
		0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
		0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
		0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
		0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
		0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
		0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}

)

…to this:

var mexpBuffer [64]uint32 // message expansion buffer 64x32bits
	var tempVar sha256.PadBlkt
	var roundOut sha256.Hasht
	var digest = sha256.Hasht{A: 0x6a09e667, B: 0xbb67ae85, C: 0x3c6ef372, D: 0xa54ff53a, E: 0x510e527f, F: 0x9b05688c, G: 0x1f83d9ab, H: 0x5be0cd19}
	var k = [64]uint32{0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
		0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
		0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
		0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
		0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
		0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
		0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
		0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}

#6

I think that should be fixed by using the simple assign operator (:=) for digest & k.

digest := sha256.Hasht{...}
k := [64]uint32{...}

#7

Ok, that did it. Thanks Josh.