1
0
mirror of https://github.com/henrydcase/nobs.git synced 2024-11-25 08:31:21 +00:00
nobs/dh/sidh/common/params.go
Henry Case 55957bbf5e
sike: move common (#32)
* makes common reusable
* exports some more symbols from common
2020-05-16 18:51:34 +00:00

25 lines
678 B
Go

package common
import "fmt"
// Keeps mapping: SIDH prime field ID to domain parameters
var sidhParams = make(map[uint8]SidhParams)
// Params returns domain parameters corresponding to finite field and identified by
// `id` provieded by the caller. Function panics in case `id` wasn't registered earlier.
func Params(id uint8) *SidhParams {
if val, ok := sidhParams[id]; ok {
return &val
}
panic("sidh: SIDH Params ID unregistered")
}
// Registers SIDH parameters for particular field.
func Register(id uint8, p *SidhParams) {
if _, ok := sidhParams[id]; ok {
msg := fmt.Sprintf("sidh: Field with id %d already registered", id)
panic(msg)
}
sidhParams[id] = *p
}