Skip to content

Conversation

@yancyribbens
Copy link
Contributor

The allowed size of ENT is 128-256 bits.

Looks like the allowed entropy size 128-256 bits in the spec. Also added an assertion to check that the entropy is divisible by 4.

@yancyribbens yancyribbens force-pushed the add-entropy-bounds-check branch from 6d8ddce to d695cbe Compare June 29, 2020 08:50
Copy link
Collaborator

@stevenroose stevenroose left a comment

Choose a reason for hiding this comment

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

I agree that we should check the actual length. But I'd prefer to have a single error type for bad entropy bits.

src/lib.rs Outdated
}

if (entropy.len() * 8) < 128 || (entropy.len() * 8) > 256 {
return Err(Error::BadEntropyBitLength(entropy.len() * 8));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'd prefer to use the same error type here. Right now when you get the BadEntropyBitMultiple error at first, you think using 32 or 64 bits is fine but then you'll just bump into the second error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevenroose make sense. this has been updated.

@yancyribbens yancyribbens force-pushed the add-entropy-bounds-check branch from d695cbe to 123516d Compare July 12, 2020 15:28
@yancyribbens yancyribbens force-pushed the add-entropy-bounds-check branch from 123516d to 57c79a3 Compare July 12, 2020 15:32
Copy link
Collaborator

@stevenroose stevenroose left a comment

Choose a reason for hiding this comment

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

perfect, thanks!

@stevenroose stevenroose merged commit 6179d29 into rust-bitcoin:master Jul 18, 2020
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