internal/bigmod: make CmpGeq public

This commit is contained in:
Sun Yimin 2024-05-31 18:13:14 +08:00 committed by GitHub
parent 91932efc27
commit 81b0c7f5ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -155,7 +155,7 @@ func (x *Nat) SetBytes(b []byte, m *Modulus) (*Nat, error) {
if err := x.setBytes(b, m); err != nil {
return nil, err
}
if x.cmpGeq(m.nat) == yes {
if x.CmpGeq(m.nat) == yes {
return nil, errors.New("input overflows the modulus")
}
return x, nil
@ -234,10 +234,10 @@ func (x *Nat) IsZero() choice {
return zero
}
// cmpGeq returns 1 if x >= y, and 0 otherwise.
// CmpGeq returns 1 if x >= y, and 0 otherwise.
//
// Both operands must have the same announced length.
func (x *Nat) cmpGeq(y *Nat) choice {
func (x *Nat) CmpGeq(y *Nat) choice {
// Eliminate bounds checks in the loop.
size := len(x.limbs)
xLimbs := x.limbs[:size]