mirror of
https://github.com/emmansun/gmsm.git
synced 2025-05-12 12:06:18 +08:00
internal/bigmod: make CmpGeq public
This commit is contained in:
parent
91932efc27
commit
81b0c7f5ae
@ -155,7 +155,7 @@ func (x *Nat) SetBytes(b []byte, m *Modulus) (*Nat, error) {
|
|||||||
if err := x.setBytes(b, m); err != nil {
|
if err := x.setBytes(b, m); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if x.cmpGeq(m.nat) == yes {
|
if x.CmpGeq(m.nat) == yes {
|
||||||
return nil, errors.New("input overflows the modulus")
|
return nil, errors.New("input overflows the modulus")
|
||||||
}
|
}
|
||||||
return x, nil
|
return x, nil
|
||||||
@ -234,10 +234,10 @@ func (x *Nat) IsZero() choice {
|
|||||||
return zero
|
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.
|
// 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.
|
// Eliminate bounds checks in the loop.
|
||||||
size := len(x.limbs)
|
size := len(x.limbs)
|
||||||
xLimbs := x.limbs[:size]
|
xLimbs := x.limbs[:size]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user