From 116d36ddbf2e253f9481f644cb5cc71b49caf8fd Mon Sep 17 00:00:00 2001 From: Kaoutar Date: Fri, 5 Jul 2024 11:47:23 +0200 Subject: [PATCH] add code comment Signed-off-by: Kaoutar --- token/core/zkatdlog/crypto/common/array.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/token/core/zkatdlog/crypto/common/array.go b/token/core/zkatdlog/crypto/common/array.go index bd8890ed9..f787a2429 100644 --- a/token/core/zkatdlog/crypto/common/array.go +++ b/token/core/zkatdlog/crypto/common/array.go @@ -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" @@ -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