github.com/cloudflare/circl@v1.5.0/dh/sidh/internal/common/params.go (about)

     1  package common
     2  
     3  import "fmt"
     4  
     5  // Keeps mapping: SIDH prime field ID to domain parameters
     6  var sidhParams = make(map[uint8]SidhParams)
     7  
     8  // Params returns domain parameters corresponding to finite field and identified by
     9  // `id` provided by the caller. Function panics in case `id` wasn't registered earlier.
    10  func Params(id uint8) *SidhParams {
    11  	if val, ok := sidhParams[id]; ok {
    12  		return &val
    13  	}
    14  	panic("sidh: SIDH Params ID unregistered")
    15  }
    16  
    17  // Registers SIDH parameters for particular field.
    18  func Register(id uint8, p *SidhParams) {
    19  	if _, ok := sidhParams[id]; ok {
    20  		msg := fmt.Sprintf("sidh: Field with id %d already registered", id)
    21  		panic(msg)
    22  	}
    23  	sidhParams[id] = *p
    24  }