/
math.go
33 lines (26 loc) · 625 Bytes
/
math.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package bridge
import (
"github.com/hyperledger/fabric-amcl/amcl/FP256BN"
"github.com/hyperledger/fabric/idemix"
)
// Big encapsulate an amcl big integer
type Big struct {
E *FP256BN.BIG
}
func (b *Big) Bytes() ([]byte, error) {
return idemix.BigToBytes(b.E), nil
}
// Ecp encapsulate an amcl elliptic curve point
type Ecp struct {
E *FP256BN.ECP
}
func (o *Ecp) Bytes() ([]byte, error) {
var res []byte
res = append(res, idemix.BigToBytes(o.E.GetX())...)
res = append(res, idemix.BigToBytes(o.E.GetY())...)
return res, nil
}