Skip to content

[Merged by Bors] - Update key derivation to latest EIP-2333#1633

Closed
realbigsean wants to merge 6 commits intosigp:v0.3.0-stagingfrom
realbigsean:update-key-generation-eip-2333
Closed

[Merged by Bors] - Update key derivation to latest EIP-2333#1633
realbigsean wants to merge 6 commits intosigp:v0.3.0-stagingfrom
realbigsean:update-key-generation-eip-2333

Conversation

@realbigsean
Copy link
Member

@realbigsean realbigsean commented Sep 18, 2020

Issue Addressed

Proposed Changes

Updates to match EIP-2333

Additional Info

In order to have compatibility with the eth2.0-deposit-cli, this PR must also be merged

@realbigsean realbigsean added do-not-merge ready-for-review The code is ready for review v0.3.0 For inclusion in v0.3.0 labels Sep 18, 2020
@realbigsean
Copy link
Member Author

Added this to v0.3.0 because it's a breaking change. I tested compatibility with the outstanding eth2.0-deposit-cli pull request and it works. It does not work with the current eth2.0-deposit-cli master

@michaelsproul
Copy link
Member

For backwards-compatibility I guess users can always use v0.2.x to restore their old keys from a mnemonic.

Copy link
Member

@kirk-baird kirk-baird left a comment

Choose a reason for hiding this comment

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

Good stuff :)

@paulhauner
Copy link
Member

I've asked about release timing here: ethereum/staking-deposit-cli#108 (comment)

Copy link

@CarlBeek CarlBeek left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

For backwards-compatibility I guess users can always use v0.2.x to restore their old keys from a mnemonic.

Indeed, this is how we plan to handle it with the launchpad too.

Release timing

The launchpad will be using the new EIP2333 key derivation for Spadina. See ethereum/staking-deposit-cli#108 (comment) for reasoning why.

@realbigsean realbigsean changed the base branch from master to v0.3.0-staging September 22, 2020 16:50
@paulhauner
Copy link
Member

paulhauner commented Sep 22, 2020

The launchpad will be using the new EIP2333 key derivation for Spadina. See ethereum/staking-deposit-cli#108 (comment) for reasoning why.

Thanks Carl!

Given this info, I think it's safe to merge this into the v0.3.0 branch. I'll run bors shortly :)

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Nice!

No functional issues, but I raised a couple of minor code-quality ones.


// info = "" + I2OSP(L, 2)
let mut info = [0; 2];
BigEndian::write_int(&mut info, MOD_R_L as i64, 2);
Copy link
Member

Choose a reason for hiding this comment

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

I think we can replicate this with std to avoid the byteorder dep and explicitly handle the integer cast:

use std::convert::TryFrom;

let info = u16::try_from(MOD_R_L).expect("MOD_R_L too large").to_be_bytes();

let zero_hash = ZeroizeHash::zero();

let mut salt = b"BLS-SIG-KEYGEN-SALT-".to_vec();
let mut hashed_salt = [0; HASH_SIZE];
Copy link
Member

Choose a reason for hiding this comment

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

I think you can do away with the hashed_salt variable:

    let mut salt = b"BLS-SIG-KEYGEN-SALT-".to_vec();
    while output.as_bytes() == zero_hash.as_bytes() {
        let mut hasher = Sha256::new();
        hasher.update(salt);
        salt = hasher.finalize().to_vec();

        let prk = hkdf_extract(&salt, ikm_with_postfix.as_bytes());
        let okm = &hkdf_expand(prk, &info, MOD_R_L);

        output = mod_r(okm.as_bytes());
    }

It looks a bit more like the spec this way, too.

@paulhauner paulhauner added waiting-on-author The reviewer has suggested changes and awaits thier implementation. A0 and removed ready-for-review The code is ready for review labels Sep 22, 2020
@realbigsean realbigsean added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Sep 23, 2020
@realbigsean
Copy link
Member Author

I tested this again after the PR updates and it works. The CI stepped that failed passed for me locally, not sure how to rerun it without pushing another commit.

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Awesome!

bors r+

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Awesome!

bors r+

@bors
Copy link

bors bot commented Sep 23, 2020

Already running a review

bors bot pushed a commit that referenced this pull request Sep 23, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
@paulhauner paulhauner added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Sep 23, 2020
@bors
Copy link

bors bot commented Sep 23, 2020

@bors bors bot changed the title Update key derivation to latest EIP-2333 [Merged by Bors] - Update key derivation to latest EIP-2333 Sep 23, 2020
@bors bors bot closed this Sep 23, 2020
paulhauner pushed a commit that referenced this pull request Sep 26, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
paulhauner pushed a commit that referenced this pull request Sep 26, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
paulhauner pushed a commit that referenced this pull request Sep 27, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
paulhauner pushed a commit that referenced this pull request Sep 28, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
paulhauner pushed a commit that referenced this pull request Sep 29, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
paulhauner pushed a commit that referenced this pull request Oct 1, 2020
## Issue Addressed

#1624

## Proposed Changes

Updates to match [EIP-2333](`https://eips.ethereum.org/EIPS/eip-2333`)

## Additional Info

In order to have compatibility with the eth2.0-deposit-cli, [this PR](ethereum/staking-deposit-cli#108) must also be merged
@realbigsean realbigsean deleted the update-key-generation-eip-2333 branch November 21, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge This PR is ready to merge. v0.3.0 For inclusion in v0.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants