Skip to content

Commit ddf40bc

Browse files
committed
update comments
1 parent 929548d commit ddf40bc

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1010
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
1111
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
1212
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
13+
github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
1314
github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
1415
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
1516
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=

pkg/encryption/aes.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ import (
1515
)
1616

1717
// GetAESKey derives a 32-byte AES key using the provided bytes.
18-
// The bytes can be anything, but we strongly suggest using something that is private to the use, such as the ecdas Private Key or a signed message.
1918
// It employs HKDF with SHA-256, using the private key bytes.
19+
// No additional salt is added here so ensure that the privateBytes are already salted or hashed.
2020
func GetAESKey(privateBytes []byte) ([]byte, error) {
2121
if len(privateBytes) == 0 {
2222
return nil, fmt.Errorf("bytes is empty")
2323
}
2424

25-
// Use a SHA-256 hash of the denom string as the salt
26-
salt := sha256.Sum256([]byte("aes key derivation salt"))
27-
2825
// Create an HKDF reader using SHA-256
29-
hkdf := hkdf.New(sha256.New, privateBytes, salt[:], []byte("aes key derivation"))
26+
hkdf := hkdf.New(sha256.New, privateBytes, nil, []byte("aes key derivation"))
3027

3128
// Allocate a 32-byte array for the AES key
3229
aesKey := make([]byte, 32)

pkg/encryption/elgamal/common.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ func (teg TwistedElGamal) GetH() curves.Point {
4747
return teg.curve.Point.Hash(bytes)
4848
}
4949

50+
// Creates an el gamal private key from the provided bytes.
51+
// No additional salt is added here so ensure that the privateBytes are already salted or hashed.
5052
func (teg TwistedElGamal) getPrivateKeyFromBytes(privateBytes []byte) (curves.Scalar, error) {
51-
// Hash the denom to get a salt.
52-
salt := sha256.Sum256([]byte("elgamal scalar derivation salt"))
53-
5453
// Create an HKDF reader using SHA-256
55-
hkdf := hkdf.New(sha256.New, privateBytes, salt[:], []byte("elgamal scalar derivation"))
54+
hkdf := hkdf.New(sha256.New, privateBytes, nil, []byte("elgamal scalar derivation"))
5655

5756
// Generate 64 bytes of randomness from HKDF output
5857
var scalarBytes [64]byte

0 commit comments

Comments
 (0)