File: hash.go

package info (click to toggle)
golang-github-cloudflare-circl 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,064 kB
  • sloc: asm: 20,492; ansic: 1,292; makefile: 68
file content (18 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package group

import (
	"math/big"

	"github.com/cloudflare/circl/expander"
)

// HashToField generates a set of elements {u1,..., uN} = Hash(b) where each
// u in GF(p) and L is the security parameter.
func HashToField(u []big.Int, b []byte, e expander.Expander, p *big.Int, L uint) {
	count := uint(len(u))
	bytes := e.Expand(b, count*L)
	for i := range u {
		j := uint(i) * L
		u[i].Mod(u[i].SetBytes(bytes[j:j+L]), p)
	}
}