ArkForgeLabs / ArkForgeLabs/Astra

Add Argon2, BCrypto, and SCrypto to crypto library

Open
#168 1 comment 0 reactions 1 assignee Claimed by @ElhamAryanpur View on GitHub
enhancement good first issue
Dominant language
Lua
Stars
186
Forks
15
PR merge metrics
No merged PRs in 30d

Description

### 📌 Summary

The current `crypto` module in Astra provides cryptographic hash functions such as SHA2 and SHA3 (256/512). However, these functions are not suitable for password storage because they are fast and do not include built-in protections against brute-force attacks.

This proposal requests the addition of a dedicated password hashing API using modern, secure algorithms such as **bcrypt**, **scrypt**, or **Argon2**.

---

### 🚨 Current Problem

Using:

```lua id="zq2k0a"
crypto.hash("sha2_512", password)
```

or even with manual salting:

```lua id="c9m1qf"
crypto.hash("sha2_512", password .. salt)
```

is insecure for password storage because:

* The hashing process is too fast (enabling GPU/ASIC brute-force attacks)
* No built-in work factor / cost parameter
* Salt must be implemented manually (error-prone)
* Does not follow modern security best practices

---

### 🎯 Proposed Solution

Introduce a dedicated API for password hashing:

```lua id="p8k3sd"
crypto.password_hash("MY_PASSWORD")
```

And a verification function:

```lua id="v3n9lx"
crypto.password_verify("MY_PASSWORD", stored_hash)
```

---

### 🔐 Suggested Algorithms

The implementation should support or evaluate:

* **Argon2 (preferred)**: modern standard, winner of the Password Hashing Competition
* **bcrypt**: widely adopted and battle-tested
* **scrypt**: strong alternative with memory-hard properties

---

### ⚙️ Optional Enhancements

Allow configurable parameters for advanced usage:

```lua id="k2j8qv"
crypto.password_hash("password", {
algorithm = "argon2id",
memory = 65536,
iterations = 3,
parallelism = 1
})
```

---

### 📦 Benefits

* Strong protection against brute-force attacks
* Alignment with OWASP and NIST recommendations
* Prevents insecure ad-hoc implementations by developers
* Centralizes secure authentication best practices
* Improves overall framework security posture

---

### 📚 References

* OWASP Password Storage Cheat Sheet
* NIST SP 800-63B Digital Identity Guidelines
* Argon2 Password Hashing Competition Winner

---

### ⚠️ Important Note

This functionality should be clearly separated from `crypto.hash`, since SHA2/SHA3 remain appropriate for non-password use cases such as data integrity, checksums, and general cryptographic hashing.

---

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.