Skip to content

Commit

Permalink
add code comment
Browse files Browse the repository at this point in the history
Signed-off-by: Kaoutar <[email protected]>
  • Loading branch information
KElkhiyaoui committed Jul 23, 2024
1 parent 6a3113d commit 116d36d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions token/core/zkatdlog/crypto/common/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SPDX-License-Identifier: Apache-2.0
package common

import (
"bytes"
"encoding/hex"
"encoding/json"

math "github.com/IBM/mathlib"
"github.com/pkg/errors"
Expand All @@ -23,16 +23,16 @@ type G1Array []*math.G1

// Bytes serialize an array of G1 elements
func (a *G1Array) Bytes() ([]byte, error) {
raw := make([][]byte, 2*len([]*math.G1(*a)))
raw := make([][]byte, len([]*math.G1(*a)))
for i, e := range []*math.G1(*a) {
if e == nil {
return nil, errors.Errorf("failed to marshal array of G1")
}
st := hex.EncodeToString(e.Bytes())
raw[2*i] = []byte(st)
raw[2*i+1] = []byte(Separator)
raw[i] = []byte(st)
}
return json.Marshal(raw)
// join the serialization of the group elements with the predefined separator.
return bytes.Join(raw, []byte(Separator)), nil
}

// GetG1Array takes a series of G1 elements and returns the corresponding array
Expand Down

0 comments on commit 116d36d

Please sign in to comment.