Skip to content

Commit 94004f7

Browse files
committed
add NewZrFromUInt64 to instantiate a new Zr directly from a uint64
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 7fdf255 commit 94004f7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

driver/common/curve.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (c *CurveBase) NewZrFromInt(i int64) driver.Zr {
6565
return &BaseZr{Int: *big.NewInt(i), Modulus: c.Modulus}
6666
}
6767

68+
func (c *CurveBase) NewZrFromUInt64(i uint64) driver.Zr {
69+
return &BaseZr{Int: *new(big.Int).SetUint64(i), Modulus: c.Modulus}
70+
}
71+
6872
func (c *CurveBase) NewRandomZr(rng io.Reader) driver.Zr {
6973
bi, err := rand.Int(rng, &c.Modulus)
7074
if err != nil {

driver/math.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Curve interface {
3030
NewG2() G2
3131
NewZrFromBytes(b []byte) Zr
3232
NewZrFromInt(i int64) Zr
33+
NewZrFromUInt64(i uint64) Zr
3334
NewG1FromBytes(b []byte) G1
3435
NewG1FromCompressed(b []byte) G1
3536
NewG2FromBytes(b []byte) G2

math.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ func (c *Curve) NewZrFromInt(i int64) *Zr {
483483
return &Zr{zr: c.c.NewZrFromInt(i), curveID: c.curveID}
484484
}
485485

486+
func (c *Curve) NewZrFromUInt64(i uint64) *Zr {
487+
return &Zr{zr: c.c.NewZrFromUInt64(i), curveID: c.curveID}
488+
}
489+
486490
func (c *Curve) NewG2() *G2 {
487491
return &G2{g2: c.c.NewG2(), curveID: c.curveID}
488492
}

0 commit comments

Comments
 (0)