Skip to content

Commit

Permalink
fix lint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jbsv committed Mar 30, 2024
1 parent 8add5d7 commit 13fb29c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 74 deletions.
8 changes: 4 additions & 4 deletions server/test/admin/smc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ func encodePublickey(pk kyber.Point) string {
return hex.EncodeToString(pkbuff)
}

func encodeSecret(secret []byte) string {
return hex.EncodeToString(secret)
}
// func encodeSecret(secret []byte) string {
// return hex.EncodeToString(secret)
// }

func decodeReencrypted(xhatencstring string) (kyber.Point, error) {
xhatencbuff, err := hex.DecodeString(xhatencstring)
if err != nil {
return nil, err
}

var xhatenc kyber.Point
xhatenc := suite.Point()
err = xhatenc.UnmarshalBinary(xhatencbuff)
if err != nil {
return nil, err
Expand Down
140 changes: 70 additions & 70 deletions server/test/user/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,76 +150,76 @@ func RegistrationDelete(docid registry.RegistrationID) error {
// ---------------------------------------------------------------------------
// The following functions are used to encrypt and decrypt the registration

func encryptRegistrationData(data registry.RegistrationData, symKey []byte) (
registry.EncryptedData,
error,
) {
// Convert the struct to a byte array
buf := new(bytes.Buffer)

// encrypt the data.Name
err := binary.Write(buf, binary.LittleEndian, data.Name)
if err != nil {
return registry.EncryptedData{}, err
}

encName, err := key.Encrypt(symKey, buf.Bytes())
if err != nil {
return registry.EncryptedData{}, err
}

// encrypt the data.Passport
err = binary.Write(buf, binary.LittleEndian, data.Name)
if err != nil {
return registry.EncryptedData{}, err
}

encPassport, err := key.Encrypt(symKey, buf.Bytes())
if err != nil {
return registry.EncryptedData{}, err
}

// encrypt the data.Role
err = binary.Write(buf, binary.LittleEndian, data.Role)
if err != nil {
return registry.EncryptedData{}, err
}

encRole, err := key.Encrypt(symKey, buf.Bytes())
if err != nil {
return registry.EncryptedData{}, err
}

// encrypt the data.Picture
err = binary.Write(buf, binary.LittleEndian, data.Picture)
if err != nil {
return registry.EncryptedData{}, err
}

encPicture, err := key.Encrypt(symKey, buf.Bytes())
if err != nil {
return registry.EncryptedData{}, err
}

// encrypt the data.Registered
err = binary.Write(buf, binary.LittleEndian, data.Registered)
if err != nil {
return registry.EncryptedData{}, err
}

encRegistered, err := key.Encrypt(symKey, buf.Bytes())
if err != nil {
return registry.EncryptedData{}, err
}

return registry.EncryptedData{
Name: encName,
Passport: encPassport,
Picture: encPicture,
Role: encRole,
Registered: encRegistered,
}, nil
}
// func encryptRegistrationData(data registry.RegistrationData, symKey []byte) (
// registry.EncryptedData,
// error,
// ) {
// // Convert the struct to a byte array
// buf := new(bytes.Buffer)
//
// // encrypt the data.Name
// err := binary.Write(buf, binary.LittleEndian, data.Name)
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// encName, err := key.Encrypt(symKey, buf.Bytes())
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// // encrypt the data.Passport
// err = binary.Write(buf, binary.LittleEndian, data.Name)
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// encPassport, err := key.Encrypt(symKey, buf.Bytes())
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// // encrypt the data.Role
// err = binary.Write(buf, binary.LittleEndian, data.Role)
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// encRole, err := key.Encrypt(symKey, buf.Bytes())
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// // encrypt the data.Picture
// err = binary.Write(buf, binary.LittleEndian, data.Picture)
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// encPicture, err := key.Encrypt(symKey, buf.Bytes())
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// // encrypt the data.Registered
// err = binary.Write(buf, binary.LittleEndian, data.Registered)
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// encRegistered, err := key.Encrypt(symKey, buf.Bytes())
// if err != nil {
// return registry.EncryptedData{}, err
// }
//
// return registry.EncryptedData{
// Name: encName,
// Passport: encPassport,
// Picture: encPicture,
// Role: encRole,
// Registered: encRegistered,
// }, nil
// }

func decryptRegistrationData(encrypted registry.EncryptedData, symKey []byte) (
registry.RegistrationData,
Expand Down

0 comments on commit 13fb29c

Please sign in to comment.