File tree 3 files changed +6
-9
lines changed
3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
10
10
github.com/decred/dcrd/crypto/blake256 v1.0.0 /go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc =
11
11
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc =
12
12
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 =
13
14
github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is =
14
15
github.com/gtank/merlin v0.1.1 /go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s =
15
16
github.com/kr/pretty v0.2.1 /go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI =
Original file line number Diff line number Diff line change @@ -15,18 +15,15 @@ import (
15
15
)
16
16
17
17
// 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.
19
18
// 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.
20
20
func GetAESKey (privateBytes []byte ) ([]byte , error ) {
21
21
if len (privateBytes ) == 0 {
22
22
return nil , fmt .Errorf ("bytes is empty" )
23
23
}
24
24
25
- // Use a SHA-256 hash of the denom string as the salt
26
- salt := sha256 .Sum256 ([]byte ("aes key derivation salt" ))
27
-
28
25
// 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" ))
30
27
31
28
// Allocate a 32-byte array for the AES key
32
29
aesKey := make ([]byte , 32 )
Original file line number Diff line number Diff line change @@ -47,12 +47,11 @@ func (teg TwistedElGamal) GetH() curves.Point {
47
47
return teg .curve .Point .Hash (bytes )
48
48
}
49
49
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.
50
52
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
-
54
53
// 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" ))
56
55
57
56
// Generate 64 bytes of randomness from HKDF output
58
57
var scalarBytes [64 ]byte
You can’t perform that action at this time.
0 commit comments