Skip to content

Commit

Permalink
Better var name
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed Jun 11, 2024
1 parent fe5e218 commit dd2435a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions encrypt/ecies/ecies.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func Encrypt(group kyber.Group, public kyber.Point, message []byte, hash func()
// ephemeral key for every ECIES encryption and thus have a fresh
// HKDF-derived key for AES-GCM, the nonce for AES-GCM can be an arbitrary
// (even static) value. We derive it here simply via HKDF as well.)
l := 32 + 12
buf, err := deriveKey(hash, dh, l)
keyNonceLen := 32 + 12
buf, err := deriveKey(hash, dh, keyNonceLen)
if err != nil {
return nil, err
}
key := buf[:32]
nonce := buf[32:l]
nonce := buf[32:keyNonceLen]

// Encrypt message using AES-GCM
aes, err := aes.NewCipher(key)
Expand Down Expand Up @@ -91,13 +91,13 @@ func Decrypt(group kyber.Group, private kyber.Scalar, ctx []byte, hash func() ha

// Compute shared DH key and derive the symmetric key and nonce via HKDF
dh := group.Point().Mul(private, R)
length := 32 + 12
buf, err := deriveKey(hash, dh, length)
keyNonceLen := 32 + 12
buf, err := deriveKey(hash, dh, keyNonceLen)
if err != nil {
return nil, err
}
key := buf[:32]
nonce := buf[32:length]
nonce := buf[32:keyNonceLen]

// Decrypt message using AES-GCM
aes, err := aes.NewCipher(key)
Expand Down

0 comments on commit dd2435a

Please sign in to comment.