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

Session key auth #296

Merged
merged 40 commits into from
Sep 22, 2022
Merged

Session key auth #296

merged 40 commits into from
Sep 22, 2022

Conversation

Orland0x
Copy link
Contributor

@Orland0x Orland0x commented Aug 23, 2022

Adding 2 session key authenticators, one authorized by an ethereum signature, and one authorized by an ethereum transaction.

closes #254

@Orland0x Orland0x marked this pull request as ready for review September 7, 2022 15:10
Copy link
Contributor

@pscott pscott left a comment

Choose a reason for hiding this comment

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

Good code! A couple of changes requested but should be fine!

contracts/starknet/Authenticators/EthSigSessionKey.cairo Outdated Show resolved Hide resolved
contracts/starknet/Authenticators/EthTx.cairo Outdated Show resolved Hide resolved
contracts/starknet/Authenticators/EthTxSessionKey.cairo Outdated Show resolved Hide resolved
contracts/starknet/lib/eth_tx.cairo Outdated Show resolved Hide resolved
contracts/starknet/lib/session_key.cairo Outdated Show resolved Hide resolved
contracts/starknet/lib/stark_eip191.cairo Show resolved Hide resolved
scripts/deploySpace1.ts Outdated Show resolved Hide resolved
scripts/test-crosschain.sh Show resolved Hide resolved
test/crosschain/EthTxSessionKeyAuth.test.ts Outdated Show resolved Hide resolved
):
SessionKey_owner_store.write(session_public_key, eth_address)
let (current_timestamp) = get_block_timestamp()
SessionKey_end_timestamp_store.write(session_public_key, current_timestamp + session_duration)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check for overflow here? What happens if current_timestamp + session_duration overflows? the number will be either negative, or < current_timestamp? This means it simply won't work, so might as well throw an error here right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah nice spot. could also enforce a max session duration?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think a max duration of a year should be fine to start with, wdyt?

Copy link
Contributor Author

@Orland0x Orland0x Sep 22, 2022

Choose a reason for hiding this comment

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

I just put an overflow check for now, some people might just want an indefinite session key to be active so seems unnecessary to limit it.

with_attr error_message("Overflow in Session duration, use smaller value"):
        assert_le(current_timestamp, end_timestamp)
    end

Copy link
Contributor

@pscott pscott left a comment

Choose a reason for hiding this comment

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

Just one question about overflow but otherwise looks good! Very nice work, I want to try it with a UI! :)

@Orland0x Orland0x merged commit 5c8c792 into develop Sep 22, 2022
@Orland0x Orland0x deleted the session_key_auth branch September 27, 2022 09:30
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.

Use session keys to broadcast vote and propose
2 participants