Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ECDSA and Denom dependencies #7

Merged
merged 5 commits into from
Dec 10, 2024
Merged

Remove ECDSA and Denom dependencies #7

merged 5 commits into from
Dec 10, 2024

Conversation

mj850
Copy link
Contributor

@mj850 mj850 commented Dec 8, 2024

This library is meant to be a general purpose cryptography library.

Currently we generate keys based on ecdsa private keys, and denoms, which are things that are specific to the use case of the CT Module we are building. However, those should not be the concerns of this library.

This allows the library to be used more flexibly without having a dependency on private keys and denoms.

return ecdsa.GenerateKey(secp256k1.S256(), rand.Reader)
// GenerateKey generates a new private bytes object used to dervie the keypair.
func GenerateKey() *[]byte {
result := []byte(time.Now().String())

Check warning

Code scanning / CodeQL

Calling the system time Warning test

Calling the system time may be a possible source of non-determinism
@mj850 mj850 changed the title Remove ECDSA dependency Remove ECDSA and Denom dependencies Dec 8, 2024
pkg/encryption/aes.go Outdated Show resolved Hide resolved

// Use a SHA-256 hash of the denom string as the salt
salt := sha256.Sum256([]byte(denom))
salt := sha256.Sum256([]byte("aes key derivation salt"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, if making salt effectively global, makes key generation less secure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this actually doesn't actually add any security. Replaced to nil.

In our case we are going to pass the hashed, then signed denom as the privateBytes, so I think it should be good enough.

Added a comment to explain that the user is responsible for ensuring that the secret passed in (privateBytes) are salted or hashed beforehand.

@mj850 mj850 merged commit b20fa09 into main Dec 10, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants