|
@ -1,5 +1,18 @@ |
|
|
package keccak |
|
|
package keccak |
|
|
|
|
|
|
|
|
|
|
|
var roundConstantsU64 = []uint64{ |
|
|
|
|
|
0x0000000000000001, 0x0000000000008082, 0x800000000000808A, |
|
|
|
|
|
0x8000000080008000, 0x000000000000808B, 0x0000000080000001, |
|
|
|
|
|
0x8000000080008081, 0x8000000000008009, 0x000000000000008A, |
|
|
|
|
|
0x0000000000000088, 0x0000000080008009, 0x000000008000000A, |
|
|
|
|
|
0x000000008000808B, 0x800000000000008B, 0x8000000000008089, |
|
|
|
|
|
0x8000000000008003, 0x8000000000008002, 0x8000000000000080, |
|
|
|
|
|
0x000000000000800A, 0x800000008000000A, 0x8000000080008081, |
|
|
|
|
|
0x8000000000008080, 0x0000000080000001, 0x8000000080008008, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var roundConstants = u64ArrayToBits(roundConstantsU64) |
|
|
|
|
|
|
|
|
func theta(a [25 * 64]bool) [25 * 64]bool { |
|
|
func theta(a [25 * 64]bool) [25 * 64]bool { |
|
|
var c0, c1, c2, c3, c4, d [64]bool |
|
|
var c0, c1, c2, c3, c4, d [64]bool |
|
|
var r [25 * 64]bool |
|
|
var r [25 * 64]bool |
|
@ -216,3 +229,9 @@ func chi(a [25 * 64]bool) [25 * 64]bool { |
|
|
copy(r[24*64:25*64], xor(a[24*64:25*64], and(xorSingle(c0[:]), c1[:]))) |
|
|
copy(r[24*64:25*64], xor(a[24*64:25*64], and(xorSingle(c0[:]), c1[:]))) |
|
|
return r |
|
|
return r |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func iot(a [25 * 64]bool, r int) [25 * 64]bool { |
|
|
|
|
|
// iota
|
|
|
|
|
|
copy(a[0:64], xor(a[0:64], roundConstants[r*64:r*64+64])) |
|
|
|
|
|
return a |
|
|
|
|
|
} |