Skip to content

stratum: password authentication#139

Closed
1ma wants to merge 2 commits intoOCEAN-xyz:masterfrom
1ma:stratum_auth
Closed

stratum: password authentication#139
1ma wants to merge 2 commits intoOCEAN-xyz:masterfrom
1ma:stratum_auth

Conversation

@1ma
Copy link
Copy Markdown

@1ma 1ma commented Jul 20, 2025

Implements #138

TODO: Act on the value of T_DATUM_MINER_DATA.authorized wherever it needs to be taken into account (not sure yet, currently it's not used anywhere).

Clients are now kicked after an unsuccessful authentication attempt, and when we send them work if they're not authenticated already (I think this could happen if the client simply sends a mining.subscribe and then fails to send a mining.authorize).

@1ma 1ma force-pushed the stratum_auth branch 2 times, most recently from a88329f to 9fc8abf Compare July 21, 2025 12:28
@1ma 1ma marked this pull request as ready for review July 21, 2025 12:35
@luke-jr luke-jr added the enhancement New feature or request label Jul 22, 2025
@1ma 1ma requested a review from luke-jr August 29, 2025 15:50
Comment on lines +1462 to +1463
password = json_array_get(params_obj, 1);
password_s = json_string_value(password);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
password = json_array_get(params_obj, 1);
password_s = json_string_value(password);
password_s = json_string_value(json_array_get(params_obj, 1));

// do not send jobs to unauthorized clients
if (!m->authorized) {
// give unauthorized clients a bit of grace period to get authorization
usleep(1000000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will delay other clients too!

@1ma
Copy link
Copy Markdown
Author

1ma commented Feb 10, 2026

I started working on this because I wanted to expose my DATUM gateway to the internet and felt a bit uneasy (and also for completeness sake of the Sv1 protocol and to learn a bit about the DATUM codebase).

However once it dawned on me that Sv1 is an unauthenticated plaintext protocol I didn't see the point of password authentication anymore. For my use case it's much more robust to run with datum.pool_pass_full_users = false and datum.pool_pass_workers = true so that anyone who finds my public DATUM endpoint can only send free hash to my payout address.

If this sort of thing where to be seriously attempted it should be a BIP-310 extension and the mining rig would need to take a shared secret in the config to do HMAC authentication of JSON-RPC messages, or a public key to be able to do proper DH key exchange with the Sv1 server and fully encrypt the session. But both of these require updates in mining firmware, so I don't think it's in scope of the DATUM gateway.

@1ma 1ma closed this Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants